How to start developing a slack bot with interactive buttons

And how you can do that through https proxy.

In summer 2016 slack introduced API feature for making bots with interactive messages. I think it is not necessary to explain why it will help to create a more user-friendly bots.

Just look at examples:

text commands flow
buttons flow
Your bots won’t have to parse human language as much if you let users make direct choices. The result is a new way of building apps for Slack, one that relies less on complex multi-step interactions, while letting you increase user engagement — Slack Developer Blog post.

Now we’re gonna see how to develop a bot with this cool new feature.

API for message buttons well documented and looks easy to use. But the problem is that it is required to use http connection in order to send responds to our bot.

Though it is really hard to set up this in local environment. Fortunately, there are a few solutions, for example the localtunnel. During development this tool is useful for temporarily exposing a compatible webhook url.

Localtunnel allows you to easily share a web service on your local development machine without messing with DNS and firewall settings.

Run your bot for example on 9292 port and then type:

lt --port 9292

And get a link like this

Which you can put into section “Interactive Messages” on your slack app settings. And start developing in local environment.

Now everything seems to be fine, but turns out the localtunnel doesn’t really work well and sometimes crashes. To resolve it I made a gem localtunnel-restarter which keeps localtunnel working.


localtunnel-restarter --port 9292 —-subdomain bot9292

If something happens with proxy server it will be automatically restarted with subdomain and port from options.

Show your support

Clapping shows how much you appreciated Kirill Shevchenko’s story.