A simple Bot for Slack with Heroku and Ruby

A simple Bot for Slack with Heroku and Ruby

I'm continuing my exploration of communications APIs by playing around with the Slack API. This week I've created a little Welcome Bot that leverages the Slack APIs to respond to messages and some other events, such as when a user joins a group. Purely by coincidence my manager added me to a new Slack group today. There was however, no Welcome Bot.

If you're interested in my earlier effort to make a simple SMS notification application for Shopify leveraging Twilio you can read about it here.

Slack make it super easy to develop against there APIs. They have a slew of information on there Building Slack Apps page. I highly recommend having a quick read if you're interested. This app in particular is focused on the real time events API. I started by working through the example provided for in Slack Ruby Onboarding Tutorial. This was particularly useful as they had already setup some example event handlers plus they had built the OAuth authentication portion which meant that I didn't have to figure that out. I will need to learn a bit more on that are soon.

Just like last time I am hosting this application on Heroku so that I don't have to have anything running locally. I had a couple of false starts with the setup for this one as I had never used Rack. This meant a little bit of puzzlement until I figured out how to update the Procfile to use the Config file. Eventually I got it sorted and was able to follow through on the steps to getting my application up and running. This includes setting up some specific URLs in Slack and like last time adding the Heroku application URL into the setup files. I also updated the application to leverage .env files and added the ability for the bot to tell a random joke. It pulls the jokes down from Icanhazdadjoke. Here is a picture of the messaging in action.

I want to give a shout out today to Chris Castle (@crc) who saw my previous post and sent me a coupon for extra Heroku hours on the free tier. It was much appreciated! This time around there was a heap less frustrations as I already have a development environment up and running and I've kind of figured our Heroku and some more Ruby. If you're interested in seeing the code check it out on Github here.

Views are my own and do not necessarily reflect those of my employer Oracle.

Toby Allen

Solving your customer identity challenges with Auth0 - Senior Solutions Engineer | CISSP | CCSP

7 年

Apparently I need to tweak the Heroku side of things. The bot keeps getting disconnected or in Heroku terms, "Dyno idling". Looks like I need to move up to a paid plan.

回复

要查看或添加评论,请登录

Toby Allen的更多文章

社区洞察

其他会员也浏览了