Search code examples
python-3.xchatbotslack-apirasa-nlurasa-core

Rasa buttons appearing as text in Slack


I’ve created buttons in RASA as shown below:

templates:
  utter_greet:
  - text: 'Hello! How can I help?'
    buttons:
    - title: "Technical"
      payload: '/Technical'
    - title: "Enquiry"
      payload: '/Enquiry'
    - title: "Orientation"
      payload: '/Orientation'
    - title: "Help Desk"
      payload: '/Help'

It works fine in console(if i type “/Technical” it matches with Technical intent and performs the corresponding action correctly) but when I integrate it with slack the buttons still appear as text as shown below:

Mounika [12:58 PM]
Hi

XYZ APP [12:58 PM]
Hello! How can I help?
1: Technical (/Technical)
2: Enquiry (/Enquiry)
3: Orientation (/Orientation)
4: Help Desk (/Help)

Any help on how to replicate buttons in slack?

Note: Python version: 3.5.6 RASA NLU: 0.11.4 RASA CORE: 0.8.2


Solution

  • I created my Slack Input and Output channels and wrote the necessary code to redirect to the slack page and send and receive messages. But I missed defining a function that links my code written in RASA to create buttons with Slack buttons which is why I was not able to see the buttons in slack though the actions were being performed correctly. Following is the code for the same.

        def _convert_to_slack_buttons(self, buttons):
            return [{"text": b['title'],
                     "name": b['payload'],
                     "type": "button"} for b in buttons]
    

    Thanks for your response!