xBlog

BLOG

Making Slack messages interactive for your Rasa chatbot

Making Slack messages interactive for your Rasa chatbot
hadji mehdi

hadji mehdi

24 June, 2020 Β· 3min πŸ“–

Slackbot with Rasa

Where we Left

This is a continuation of the previous article: A journey to build and deploy your chatbot with Rasa and Slack. In the first part, we had a discussion about Rasa Stack. We then used two components of Rasa namely Rasa NLU and Rasa Core to build a fully functional chatbot and pushing it to Slack using Ngrok. We also saw how to design a conversation flow for a Rasa chatbot and use an external API.

Objective

In this article, We are going to make messages interactive by adding buttons, date pickers, and approve/deny option. To do so, we are going to make use of The Slack interactive message framework. I highly recommend that you read Part 1 before attempting this part.

Slack interactive messages

We will see some key points which are essential but we will not detail Slack interactive message framework. Why ? Because it is very well explained on the site! But also because I would like to show you how to do it from Rasa part

Interactive messages are much like other messages, only they contain buttons, a variety of menus types, or they have some custom actions available. Rather than remaining mostly static, interactive messages evolve over time. You try any of the slack interactive messages here

Message buttons and menus may travel almost anywhere a message goes.

And for sure, we can Attach them:

  • To our messages that Rasa bot sends.

How to do it ?

First of all, we have to configure our Slack app:

  1. go to Interactivity & Shortcuts, and turn it on :

Use the same Ngrok URL of your Rasa server in this format under the Request URL field:

That's it ! !

2. Now, We are going to update our domain.yml file so Rasa can tell Slack to use interactive components : buttons, date pickers, multi select buttons...

Wait ! Something is missing here ! ! Slack uses JSON for its components, and in the other hand, Rasa uses YAML (domain is a YAML file)...

Don't worry about it ! a simple conversion can do the trick, all you have to do is to pick the component you need and rewrite it with YAML format, finally your domain.yml will look like this :

Congratulations ! You have added some style to your bot responses :

Add date picker :

output:

P.S: We can specify an initial date by adding

accessory:
  type: datepicker
  initial_date: 2020-06-24

Add list of elements:

output :

Add buttons :

output :

Read Part 1 here

Useful resources :

  1. Building block
  2. Making messages interactive
  3. block elements

Thanks for reading!

signature

hadji mehdi has no other posts

Aloha from xHub team πŸ€™

We are glad you are here. Sharing is at the heart of our core beliefs as we like to spread the coding culture into the developer community, our blog will be your next IT info best friend, you will be finding logs about the latest IT trends tips and tricks, and more

Never miss a thing Subscribe for more content!

πŸ’Ό Offices

We’re remote friendly, with office locations around the world:
🌍 Casablanca, Agadir, Valencia, Quebec

πŸ“ž Contact Us:

🀳🏻 Follow us:

Β© XHUB. All rights reserved.

Made with πŸ’œ by xHub

Terms of Service