# Rasa Slack Integration

**URL:** <https://forum.rasa.com/t/rasa-slack-integration/27616>\
**Category:** Tutorials, Resources & Videos\
**Created:** [April 16, 2020, 5:46pm UTC](https://forum.rasa.com/t/rasa-slack-integration/27616 "2020-04-16T17:46:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [April 16, 2020, 5:46pm UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/1 "2020-04-16T17:46:36Z")

</div>

Hello Community, I have created a video tutorial on the integration of Rasa bot over Slack, Check it out.

[![](https://img.youtube.com/vi/YsOcE8pCXsk/maxresdefault.jpg "Integrating RASA Chatbot with Slack Channel") ](https://www.youtube.com/watch?v=YsOcE8pCXsk)

Check out the Restaurant Bot demo integrated with Slack:

[![](https://img.youtube.com/vi/6Dl_kpkU8tc/maxresdefault.jpg "Restaurant Bot Demo over Slack") ](https://www.youtube.com/watch?v=6Dl_kpkU8tc)

**Note** : _While developing this bot, I had used Rasa v.1.9.7 and there was some issue with the slack connector of Rasa, I have found a temporary fix, I have mentioned this in the [issue](https://github.com/RasaHQ/rasa/issues/5704)._

I hope this helps 😊.

---

<div class="post-metadata">

**Author:** ![cck197](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/cck197/32/7901_2.png) [@cck197](https://forum.rasa.com/u/cck197)\
**Post date:** [April 23, 2020, 12:41am UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/2 "2020-04-23T00:41:21Z")

</div>

Super helpful, should be linked from the docs.

Now how do I make my buttons work??

---

<div class="post-metadata">

**Author:** ![cck197](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/cck197/32/7901_2.png) [@cck197](https://forum.rasa.com/u/cck197)\
**Post date:** [April 23, 2020, 3:32am UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/3 "2020-04-23T03:32:23Z")

</div>

Three hours later, I still can’t make the buttons work! You hint at the end of the video. Can I see your `domain.yml` file? My buttons work fine in the `rasa shell` but not with Slack. When I click on the button, I get the following exception thrown in the console running

`rasa run --enable-api --cors "*" -vv`

```auto
Traceback (most recent call last):
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/sanic/request.py", line 173, in load_json
    self.parsed_json = loads(self.body)
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/sanic/app.py", line 976, in handle_request
    response = await response
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
    return self.gen.send(None)
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/rasa/core/channels/slack.py", line 356, in webhook
    metadata = self.get_metadata(request)
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/rasa/core/channels/slack.py", line 329, in get_metadata
    slack_event = request.json
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/sanic/request.py", line 167, in json
    self.load_json()
  File "/home/cck197/rasa/venv2/lib/python3.6/site-packages/sanic/request.py", line 176, in load_json
    if not self.body:
sanic.exceptions.InvalidUsage: Failed when parsing body as json

```

My buttons look like this:

```auto
  utter_ask_permission:
    -
        text: "How would you feel if I asked you some questions?"
        buttons:
          -
            payload: /startc
            title: "Go on"

```

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [April 23, 2020, 4:30am UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/4 "2020-04-23T04:30:34Z")

</div>

hey @cck197, I have updated the `slack` connector so that it will parse the button click response from the slack successfully. I will show it in the other part of the video. Sorry as of now I can’t share `slack` connector file as there are some changes needs to be done, but I will share it soon 😅

---

<div class="post-metadata">

**Author:** ![arneverster](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/arneverster/32/9376_2.png) [@arneverster](https://forum.rasa.com/u/arneverster)\
**Post date:** [June 4, 2020, 10:58am UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/6 "2020-06-04T10:58:06Z")

</div>

Any updates on the button stuff? 🙂

---

<div class="post-metadata">

**Author:** ![arneverster](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/arneverster/32/9376_2.png) [@arneverster](https://forum.rasa.com/u/arneverster)\
**Post date:** [June 4, 2020, 12:33pm UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/7 "2020-06-04T12:33:56Z")

</div>

> <https://github.com/RasaHQ/rasa/issues/5704>
>
> \<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING.… If you don't know your Rasa version, use \`rasa --version\`. 
> Please format any code or console output with three ticks \`\`\` above and below.
> If you are asking a usage question (e.g. "How do I do xyz") please post your question on https://forum.rasa.com instead --\>
> 
> \*\*Rasa version\*\*: 1.9.6
> 
> \*\*Python version\*\*: Python 3.7.6
> 
> \*\*Operating system\*\* (windows, osx, ...): windows
> 
> \*\*Issue\*\*: The Slack connector is not able to handle the button payload response from the slack. 
> 
> 
> 
> \*\*Error (including full traceback)\*\*:
> \`\`\`
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sanic\\request.py", line 173, in load\_json
> self.parsed\_json = loads(self.body)
> ValueError: Expected object or value
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sanic\\app.py", line 976, in handle\_request
> response = await response
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\rasa\\core\\channels\\slack.py", line 356, in webhook 
> metadata = self.get\_metadata(request)
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\rasa\\core\\channels\\slack.py", line 329, in get\_metadata
> slack\_event = request.json
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sanic\\request.py", line 167, in json
> self.load\_json()
> File "c:\\users\\jitesh\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\sanic\\request.py", line 177, in load\_json
> raise InvalidUsage("Failed when parsing body as json")
> sanic.exceptions.InvalidUsage: Failed when parsing body as json
> \`\`\`
> Below is the output of the error in slack:
> 
> !\[issue\_1\](https://user-images.githubusercontent.com/49223934/80071475-535b4100-8562-11ea-80c1-846ae1a06f3e.PNG)
> 
> 
> when I tried to find where the issue lies, I got to know that the \`request\` object that was received from slack was in the \`req.form\` and the issue occurs when getting the \`metadata\` value on the below line:
> 
> https://github.com/RasaHQ/rasa/blob/002b892f573541b42a05b783df64424f959ff9e8/rasa/core/channels/slack.py#L356 
> since the \`get\_metadata\` function uses \`req.json\` to set the values for \`metadata\` and \`req.json\` isn't there so it throws the above error.
> 
> So as a workaround, I tried to update the connector and it worked for me:
> 
> \`\`\`
> @slack\_webhook.route("/webhook", methods=\["GET", "POST"\])
> async def webhook(request: Request) -\> HTTPResponse:
> if request.form:
> output = request.form
> payload = json.loads(output\["payload"\]\[0\])
> if self.\_is\_interactive\_message(payload):
> sender\_id = payload\["user"\]\["id"\]
> text = self.\_get\_interactive\_response(payload\["actions"\]\[0\])
> if text is not None:
> # metadata = self.get\_metadata(request)
> out\_channel = payload\["channel"\]\["id"\]
> users = payload\["user"\]\["id"\]
> metadata = {'out\_channel': out\_channel, 'users': users}
> return await self.process\_message(
> request, on\_new\_message, text, sender\_id, metadata
> )
> elif payload\["actions"\]\[0\]\["type"\] == "button":
> # link buttons don't have "value", don't send their clicks to bot
> return response.text("User clicked link button")
> return response.text(
> "The input message could not be processed.", status=500
> )
> \`\`\`
> I am getting the values for \`metadata\` from the \`payload\`.
> 
> Below is the output from the slack after updating the connector: 
> 
> !\[issue-2\](https://user-images.githubusercontent.com/49223934/80071558-7554c380-8562-11ea-9386-0a5952dcee4b.PNG)
> 
> I don't know whether it's a reliable workaround solution😅 would like to know your thoughts on this 😄

---

<div class="post-metadata">

**Author:** ![tim.blackbird](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tim.blackbird](https://forum.rasa.com/u/tim.blackbird)\
**Post date:** [May 16, 2021, 2:53pm UTC](https://forum.rasa.com/t/rasa-slack-integration/27616/8 "2021-05-16T14:53:06Z")

</div>

Any plans on getting these Videos back up on YT? Maybe they are out of date, which is understood
