# Rasa Slack Buttons Fix

**URL:** <https://forum.rasa.com/t/rasa-slack-buttons-fix/29780>\
**Category:** Rasa Open Source\
**Created:** [June 4, 2020, 2:31pm UTC](https://forum.rasa.com/t/rasa-slack-buttons-fix/29780 "2020-06-04T14:31:02Z")\
**Posts on this page:** 2\
**Page:** 1

<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, 2:31pm UTC](https://forum.rasa.com/t/rasa-slack-buttons-fix/29780/1 "2020-06-04T14:31:02Z")

</div>

Hey guys.

As you know at the moment Slack buttons don’t work when integrating the bot with Slack. I’ve done some reading on the issue and this seems to be the latest:

> <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 😄

It’s a known issue with the `get_metadata` function and the request object.

I can apply the workaround on my local machine, but our Rasa X implementation still suffers from the problem. Any update on when the fix will be released?

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [June 15, 2020, 11:08am UTC](https://forum.rasa.com/t/rasa-slack-buttons-fix/29780/2 "2020-06-15T11:08:25Z")

</div>

Hi @arneverster thanks for mentioning that. There should be a pull request open for this fix now: [Slack Button Fix and Threaded Messaging by b-quachtran · Pull Request #6020 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/pull/6020)
