A new product called BotArena, the world's most informative bot store, has recently launched. So, we thought why not talk more about Chatbots and how one can build one from scratch?
Chatbots are gaining popularity after the F8 conference where Facebook opened its doors to developers and now they can create chatbots for the messenger platform. If you are willing to spend some of your free time, you can easily build your own bot and automate some things.
In this article, we will build a hello world chatbot for Slack using Botkit– a popular and open-source bot development kit written in Node.js.
Create a bot for your team on Slack:
- Go to https://slack.com/apps and click Build in the top right corner.
- Select Something just for my team and click Make a custom integration.
- Click on Bots under Build a Custom Integration menu.
- Give your bot a username and click Add bot integration. Let's use the username, botmaker_hello_bot.
- On the Bot details page, note your API Token. You can create your bot by giving it a name and uploading a profile picture.
- Finally, click Save Integration to save your bot profile.
Install BotKit:
- Open your terminal and run the command npm install botkit to install BotKit.
- Create a js file e.g. slack_hello_bot.js and add the following code:
[su_note note_color=”#d7dfe0″ radius=”7″]var Botkit = require('botkit');
var controller = Botkit.slackbot();
var bot = controller.spawn({
token: “”
})
bot.startRTM(function(err,bot,payload) {
if (err) {
throw new Error(‘Could not connect to Slack’);
}
});
controller.hears([“Hello”,”Hi”],
[“direct_message”,”direct_mention”,”mention”,”ambient”],function(bot,message) {
bot.reply(message,’Hello, how are you today?’);
});
[/su_note]
- Run your bot with the node command slack_hello_bot.js
- Open your Slack team and start talking to your bot
How does it work?
- Botkit simplifies the process of designing and operating bots that live inside Slack.
- It provides a semantic interface for sending and receiving messages, so developers can focus on building core logic without having to worry about API integrations.
- In the code above, we have initialized a slack bot, providing an API token and used bot.hears() to listen to user messages and reply back with bot.reply().
If you wish to explore the latest bots for different platforms or submit your own bot, don't forget to check BotArena!


