Creating a SlackBot with Node-RED and IBM Bluemix

Jouni Leino

Siili participated in a workshop which introduced IBM Bluemix cloud services. The workshop was a lot of fun as we explored Integrations, APIs, various services and databases.


I wanted to create a Santa Claus SlackBot that listens to Christmas wishes, stores those in a database and sends an instant response to the user. In order to run my app in the cloud, I first deployed a sample application into IBM Bluemix and then modified it to fit my needs. I used the Node-RED Starter -application and some ChatBot npm-packages.
Find them here.





For chat connectivity I needed two custom integrations for Slack.

  1. Bot
  2. Incoming WebHook


A bot needs to have a name and a description. The bot is added as a regular user on the selected Slack channel.


Node-RED provides a very nice user interface where you can implement the application wiring. Each node operates the data in a specified way. The Slack-nodes take input and push output. Function-nodes implement programming logic in Javascript and parse data. The Cloudant DB is super easy to use. The database is created automatically on the first time we run the application with a DB connection. No database structure is required to be created. Debugging-nodes provide an easy way to display how the data is parsed in each step.




The switch statement is looking whether the Slack text posted by the user contains a certain sequence of characters.




The following function parses user and wishes from the payload. It also removes the “I wish for” –string from the payload.




Another function then concatenates the username, static string and the users wish.




Now Santa Claus´s response is ready to be submitted back to Slack. The bot response can also be formatted so I replace the bot´s username santa.claus with a more proper “Santa Claus” and add an icon for the bot users profile. The entire response is then returned to Slack as JSON.




So let's go to our Slack channel #ibmbluemixworkshop and type in a Christmas wish.

“I wish for …”




Our Bot gives a customized response and stores the wish in the database.




Merry Christmas!




We are technology independent and have partnered with all major technology vendors such as IBM, Microsoft, Amazon and Oracle. In case you need a bot or any other type of digital solution built on top of these fine platforms, we’re more than happy to help.