Finding your way around the world of bots as a web developer

What I learned about development and UX from building my first Slack bot

Shay DeWael
Slack Platform Blog
5 min readJun 21, 2017

--

Before I started working at Slack, the only time I had used the Slack platform was to configure a simple incoming webhook for a previous internship. It’s been a big leap to move from web development to building bots. But here I am, a few bots and one tutorial later.

The tutorial walks the reader through creating TalkBot, a bot that uses Twilio and Firebase APIs to send and receive SMS messages from Slack. When I was working on it, I realized bot development and web development have some things in common: I’m still coding in Javascript, and I’m designing for a similar type of person. But once I dug in to bot building, I realized it requires an entirely different way of thinking through app design as compared to web development.

And that’s what I’m going to focus on today: what it means to build a bot when you’re coming from the context of web development, and what that means for you if you’re thinking about building an app for Slack.

I’ll be referencing my Talkbot tutorial throughout this article — check it out on Github. It’ll take you through using the Slack Platform, Twilio, and Firebase to build a fully-functioning Slack bot.

Wait…which API am I supposed to use?

Slack has three different APIs you can use: the Web, Events, and Real Time Messaging API. When I first began developing a Slack app, I wasn’t entirely sure which one I should be using. My first intuition was to use the RTM API. I was building a bot, so I figured I would want to be receiving and sending as much information as my app could handle. Oh, I was wrong.

As I started development, it became clear pretty quickly that using a WebSocket-based API would be a lot more complex than subscribing to specific events. So I abandoned WebSocket connections and pivoted to the Events API, which allowed me to listen to certain events and send the information to an endpoint.

To interact with Slack users, I looked to the Web API. It is made up of HTTP methods, so it was quick to get up and running. The Web API also features added flexibility for sending messages and other standard methods. For instance, I was able to use message menus with my app, which would not have been possible if I had used the RTM API alone.

Together, the Events and Web APIs served as great starting points for Slack development, without dealing with the unnecessary overhead of multiple sockets and connected users. As I worked through the basic configuration and API endpoints setup for my bot, I started to think about how designing a bot was different from designing the web apps I was used to.

From web apps to Slack bots

If you’ve seen the show Futurama, you probably know that Bender is a robot that, as his name suggests, bends things. Sure, he can hold a conversation and has been trained to enjoy a human refreshment or two, but the task he was programmed to perform time and time again was bending.

Bender is extraordinarily effective at bending things…especially the professor

That’s how I’ve begun to think about bots: they need to be effective at the tasks they’re expected to perform, however narrow or broad those tasks may be. But past that, they need to communicate well. They must work seamlessly into whatever environment they find themselves in.

This was a shift in mindset from the world of web development, where you’re typically developing the environment for your application. The design decisions you’re forced to make when building a bot, even as a developer, introduced a set of problems I had never been exposed to.

When I was creating TalkBot, I knew the bot was going to be relaying messages from Twilio to Slack and back. I had to think of some method to organize those messages in Slack. If the bot I created just sent messages from Twilio to Slack without any context, it would be annoying and unnecessarily spammy for everyone.

…so I used threads.

The TalkBot tutorial walks through creating a thread interface in Slack to reply to incoming SMS messages from Twilio

Threads make it possible for Talkbot to keep conversations with a unique phone number in a centralized place. I could keep someone’s messages in one place, reply to them from the same thread, and then mark the thread as done with a ✅ reaction.

Another aspect I put a lot of thought into: user onboarding. When you install an app like Slack, Monument Valley, or Facebook to your phone, you’re walked through the app when you open it for the first time. But with bots, you’re installing an app to another app; the onboarding experience is limited to the constraints of that user interface.

But there is more than one way to onboard a user.

Slack developers often choose to message the installer directly, teaching them how to use the bot and giving the user a chance to customize it for their Slack team.

TalkBot sends a message to the user that installed it onto the team, then saves that channel as the default

Just like any other app, you have to think about how the end user is going to be interacting with your product. The constraints of the existing interface force you to be focused on the end user’s goals, so that their experience with your bot aligns with what they want and expect from the existing environment.

Using the community

One thing that especially helped me improve my bot development was learning to utilize Slack’s developer community. Slack helps support a community called Bot Developer Hangout. It has a slough of archives with questions and solutions that I’ve run into countless times. And if a question isn’t there, you can just ask it. There are some really amazing developers with successful Slack apps who hang out on there.

You can also try checking out the Slack Platform documentation site, which covers a lot and has an extensive library of sample code. We also have an incredible developer support team who are waiting to hear from you at developers@slack.com.

Designing bots can be overwhelming at first, but the opportunity is too large to ignore for developers. Once you think through the design challenges, bots give you an opportunity to surface up the benefits of an app into the conversations your users are already having. And the library of resources and sample code can help guide you through the early steps of creating, designing, and developing your first bots.

If you’re interested in using threads, connecting your Slack app with external APIs, or just want to try out the Web and Events API, check out my tutorial on GitHub. 🎉

--

--