Slack integration error with interactive components

Hi @mina.fsh, @stephens, @athenasaurav. Same error for me with very default configuration: Everythink OK wile chatting, but once button (interactivity) should be pressed error occured. File “/Users/evios/opt/anaconda3/lib/python3.7/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

Detailed debug: 2020-04-14 22:53:57 DEBUG rasa.core.tracker_store - Recreating tracker from sender id ‘UT4KC4Q4U’ 2020-04-14 22:53:57 DEBUG rasa.core.processor - Received user message ‘hey’ with intent ‘{‘name’: ‘greet’, ‘confidence’: 0.9118240223407343}’ and entities ‘[]’ 2020-04-14 22:53:57 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 47 events. 2020-04-14 22:53:57 DEBUG rasa.core.policies.memoization - Current tracker state [{‘prev_action_listen’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_ask_domain’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_action_listen’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_ask_domain’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_action_listen’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}] 2020-04-14 22:53:57 DEBUG rasa.core.policies.memoization - There is no memorised next action 2020-04-14 22:53:58 DEBUG rasa.core.policies.mapping_policy - The predicted intent ‘greet’ is mapped to action ‘utter_ask_domain’ in the domain. 2020-04-14 22:53:58 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_2_MappingPolicy 2020-04-14 22:53:58 DEBUG rasa.core.processor - Predicted next action ‘utter_ask_domain’ with confidence 1.00. 2020-04-14 22:53:58 DEBUG rasa.core.processor - Action ‘utter_ask_domain’ ended with events ‘[BotUttered(‘Welcome to Knowledge Base Assistant. Which skills you would like to improve? You can easily change domain in future by simply ask assistant to ‘change domain’ or alike request:)’, {“elements”: null, “quick_replies”: null, “buttons”: [{“payload”: “/set_domain{“domain”: “Agile”}”, “title”: “Agile skills”}, {“payload”: “/set_domain{“domain”: “Startup”}”, “title”: “Startup skills”}], “attachment”: null, “image”: null, “custom”: null}, {}, 1586894038.061376)]’. 2020-04-14 22:53:58 DEBUG slack.web.slack_response - Received the following response: {‘ok’: True, ‘channel’: ‘D011ZUAKES0’, ‘ts’: ‘1586894038.004400’, ‘message’: {‘bot_id’: ‘B011ZUAK6J0’, ‘type’: ‘message’, ‘text’: “Welcome to Knowledge Base Assistant. Which skills you would like to improve? You can easily change domain in future by simply ask assistant to ‘change domain’ or alike request:)”, ‘user’: ‘U011ZUAK7V2’, ‘ts’: ‘1586894038.004400’, ‘team’: ‘TT539R8V6’, ‘bot_profile’: {‘id’: ‘B011ZUAK6J0’, ‘deleted’: False, ‘name’: ‘EnderTuring’, ‘updated’: 1586879448, ‘app_id’: ‘A012GNFGESC’, ‘icons’: {‘image_36’: ‘https://a.slack-edge.com/80588/img/plugins/app/bot_36.png’, ‘image_48’: ‘https://a.slack-edge.com/80588/img/plugins/app/bot_48.png’, ‘image_72’: ‘https://a.slack-edge.com/80588/img/plugins/app/service_72.png’}, ‘team_id’: ‘TT539R8V6’}, ‘blocks’: [{‘type’: ‘section’, ‘block_id’: ‘qlP9’, ‘text’: {‘type’: ‘plain_text’, ‘text’: “Welcome to Knowledge Base Assistant. Which skills you would like to improve? You can easily change domain in future by simply ask assistant to ‘change domain’ or alike request:)”, ‘emoji’: True}}, {‘type’: ‘actions’, ‘block_id’: ‘UHo’, ‘elements’: [{‘type’: ‘button’, ‘action_id’: ‘olkTx’, ‘text’: {‘type’: ‘plain_text’, ‘text’: ‘Agile skills’, ‘emoji’: True}, ‘value’: ‘/set_domain{“domain”: “Agile”}’}, {‘type’: ‘button’, ‘action_id’: ‘c47Nm’, ‘text’: {‘type’: ‘plain_text’, ‘text’: ‘Startup skills’, ‘emoji’: True}, ‘value’: ‘/set_domain{“domain”: “Startup”}’}]}]}} 2020-04-14 22:53:58 DEBUG rasa.core.policies.memoization - Current tracker state [{‘prev_utter_ask_domain’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_action_listen’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_ask_domain’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_action_listen’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_ask_domain’: 1.0, ‘slot_domain_0’: 1.0, ‘intent_greet’: 1.0}] 2020-04-14 22:53:58 DEBUG rasa.core.policies.memoization - There is no memorised next action 2020-04-14 22:53:58 DEBUG rasa.core.policies.mapping_policy - The mapped action, ‘utter_ask_domain’, for this intent, ‘greet’, was executed last so MappingPolicy is returning to action_listen. 2020-04-14 22:53:58 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_2_MappingPolicy 2020-04-14 22:53:58 DEBUG rasa.core.processor - Predicted next action ‘action_listen’ with confidence 1.00. 2020-04-14 22:53:58 DEBUG rasa.core.processor - Action ‘action_listen’ ended with events ‘[]’. 2020-04-14 22:53:58 DEBUG rasa.core.tracker_store - Tracker with sender_id ‘UT4KC4Q4U’ stored to database 2020-04-14 22:53:58 DEBUG rasa.core.lock_store - Deleted lock for conversation ‘UT4KC4Q4U’. 2020-04-14 22:53:58 WARNING rasa.core.channels.slack - Received message on unsupported channel: D011ZUAKES0 [2020-04-14 22:54:01 +0300] [15799] [ERROR] Exception occurred while handling uri: ‘http://edd4eeb3.ngrok.io/webhooks/slack/webhook’ Traceback (most recent call last): File “/Users/evios/opt/anaconda3/lib/python3.7/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 “/Users/evios/opt/anaconda3/lib/python3.7/site-packages/sanic/app.py”, line 976, in handle_request response = await response File “/Users/evios/opt/anaconda3/lib/python3.7/site-packages/rasa/core/channels/slack.py”, line 356, in webhook metadata = self.get_metadata(request) File “/Users/evios/opt/anaconda3/lib/python3.7/site-packages/rasa/core/channels/slack.py”, line 329, in get_metadata slack_event = request.json File “/Users/evios/opt/anaconda3/lib/python3.7/site-packages/sanic/request.py”, line 167, in json self.load_json() File “/Users/evios/opt/anaconda3/lib/python3.7/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

1 Like

Hi @mina.fsh Is the error resolved for you? If so, please explain how did you go with the error.

I’m facing exactly the same error after deploying my chatbot on slack. Tried troubleshooting following the steps mentioned by others, but no joy.

Please help. Thanks.

@evios @rajas.black Hi, welcome to Rasa forum. :slight_smile:

Unfortunately my problem persists and I could not find a solution yet.

Hi @mina.fsh

I figured out the issue. It’s resolved and working fine. Thanks everyone.

Let me know if we can connect offline and try to resolve. It becomes cumbersome to troubleshoot by going to and fro.

@rajas.black Nice job. How can I connect to you to get the solution?

Yes i am wondering how can we connect :thinking:

Can you please write shortly what you did in here, so other people can also use it later?

I made sure my credential files are right. I made sure the action server is running. Action server has only one resource, so you can either run interactive or shell or the ngrok. So after the action server is running, i started a public domain from ngrok and installed the app from slack. It is working as expected.

Make sure the credentials are correct, i.e., the bot user token authID.

Regards, Rajesh

@rajas.black can you please show me how you coded your buttons in domain file. I think that might lead me to the problem I have. For me the credentials are correct. about running the actions, so first you use the command rasa run actions and then you start the domain from ngrok, while the actions are not being used in rasa x or any other resource, right? I do the same. that’s why I believe my problem can be related to wrong structure in the domain file for the slack buttons.

@mina.fsh Just an example below. My domain file is .yml and not .json

responses: utter_example - buttons: - payload: ABC - title: ABC

yes we did this all but the bot is working fine with text messages but not with the buttons. how did you made buttons work in slack. i read another issue on forum where PR was raised in sdk Slack buttons fail silently - #7 by akelad but no update in it since then.

1 Like

I am not sure if I have understood your question as you intend to, but i can give a throw at it. Make sure the buttons (payload) are tagged with the relevant (text) choice the user makes.

Are we running into the same problem?

There’s something different about the interaction payload:

The payload will be sent to your specified request URL in an HTTP POST. The body of that request will contain a payload parameter. Your app should parse this payload parameter as JSON.

https://api.slack.com/messaging/interactivity#components

Pretty sure @JiteshGaikwad has the answer!

hey @cck197, check this issue in this I have mentioned the workaround that I did to overcome this issue:

I am not pretty sure whether this is a reliable solution :sweat_smile:

2 Likes

LOL I’d just bodged in the exact same hack:

cck197@ubuntu:~/rasa/rasa$ diff --color /home/cck197/rasa/venv2/lib/python3.6/site-packages/rasa/core/channels/slack.py ./rasa/core/channels/slack.py
356,357c356
<                         #metadata = self.get_metadata(request)
<                         metadata = {"out_channel": payload["channel"]["id"], "users": payload["user"]["id"]}
---
>                         metadata = self.get_metadata(request)

@cck197 great :+1: , glad that it helps…

Yes, thank you! I never would have got this far without your video, and I appreciate your hard work filing the bug report.

1 Like

Thanks for following the video :blush:

The more I think about this, the more I think I’m doing it wrong. Otherwise, wouldn’t more people be running into the same problem? I developed a minimum viable bot first using Rasa X. Now I’m trying to connect it to some channels. If I ever do SMS or voice, will I be able to use buttons? I don’t think so.

Perhaps I need a better way to prompt the user for input?