How Slack kind of taught me how to make my first bot

Despite having its flaws, real-time chat has become an essential part of my day job. In particular, the mix of features Slack offers was there for us when we needed them. However, it's software aimed at corporations, specially in terms of pricing. Small companies frequently need to involve outside contacts and getting priced per user is a weird reminder that your bill goes up if some friend of the company says "hi". Ironically, the free tier is less stressful and more flexible than having to pay per person. You get to have your small team that has the support of one person that comes by once a month or of another small team with whom you share some channels with. Can you know exactly how many people get to talk this month or the next? Why does that minutia need to be a concern?

So how can a lean start-up pay for Slack? Without any viable option that would allow Slack to take their money, they don't. And so, small teams have to face the limitations of the free tier, namely having only their most recent chat history. Which makes it hard to go back and find this or that important thing someone posted a couple of months ago. But fortunately, at least for now, Slack has an API that allows you to build bots. And therefore, since you can't pay with your money, you can at least pay with your time by just building a bot that does the obvious thing: saving your chat history and having some command to just search through it. It's not a perfect solution because you have to give a search result within a sequence of posts to provide context, but it's still the difference between losing that important e-mail forever or just getting it from your own personal bot.

As this was my first bot project, I've discovered how just saving messages is a reliable way to build a bot that can eventually be more than just a toy. You have a basic bot that can do things with messages and a database. You can probably find out interesting things like what were the most active channels last week or even what projects are taking up the majority of people's time. Furthermore, if you consider alternatives to Slack that also support bots (like Discord for example) and you switch platforms, it's possible to take your chat history with you to be searched through even with the exact same command. On the other hand, you can keep your history for as long as you like and then delete it when you really don't need it, not just arbitrarily losing it when Slack decides.

These chat platforms (including open, self-hosted options like Rocket) do get criticized for bringing nothing new to the table when we've already had IRC for decades. But they have extended the use of bots to what is a more accessible and batteries-included chat experience. And I have discovered that bots can not only be really fun to program, but also surprisingly useful. I will very likely talk about some other experiences I had with these automation tools in future articles. See you soon.

Thanks for reading! Please subscribe to the RSS feed, maybe follow my Twitter or learn more about me.

More from 🌍; view from the web
All posts