O'Reilly logo

Building Slack Bots by Paul Asjes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Simple to-do example

With the basics of Redis covered, we shall now move on to create a simple to-do Slack bot. The aim of this bot is to allow users to create a to-do list, allowing them to add, complete, and delete a task from this list as they go about their day.

This time, we will start with a skeleton of what we want and build each feature step by step. Start by adding this new command to your bot:

bot.respondTo('todo', (message, channel, user) => { let args = getArgs(message.text); switch(args[0]) { case 'add': break; case 'complete': break; case 'delete': break; case 'help': channel.send('Create tasks with \`todo add [TASK]\`, complete them with \`todo complete [TASK_NUMBER]\` and remove them with \`todo delete [TASK_NUMBER]\` or \`todo delete ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required