Custom output payloads with socket.io

Hello developer & community,

I connected my angular frontend directly to rasa with socket.io connector. Sending responses with text, buttons and image works fine. Now I tried to send a custom payload as mentioned here https://rasa.com/docs/rasa/responses#custom-output-payloads. But the frontend only recieves undefined.

image

Then i tried it this way https://rasa.com/docs/action-server/sdk-dispatcher#collectingdispatcherutter_message with the dispatcher and a json_message. The response was also undefined in frontend.

The custom data is always in the console debug:

0|rasa | {‘sender_id’: ‘c481a32619ff40dbb02c3ac0b46b673c’, ‘event’: ‘bot’, ‘timestamp’: 1609840839.4135976, ‘metadata’: {‘template_name’: ‘utter_custom_test’}, ‘text’: None, ‘data’: {‘elements’: None, ‘quick_replies’: None, ‘buttons’: None, ‘attachment’: None, ‘image’: None, ‘custom’: {‘blocks’: [{‘type’: ‘section’, ‘text’: {‘text’: ‘Make a bet on when the world will end:’, ‘type’: ‘mrkdwn’}, ‘accessory’: {‘type’: ‘datepicker’, ‘initial_date’: ‘2019-05-21’, ‘placeholder’: {‘type’: ‘plain_text’, ‘text’: ‘Select a date’}}}], ‘room’: ‘c481a32619ff40dbb02c3ac0b46b673c’}}}

So I checked the " rasa/core/channels/socketio.py" and found a difference in these two functions: image image I don’t know why the room is added as an key to the json_message and not as an parameter to the emit(…, room=…) function like in _send_message.

I hope you have some ideas to solve this issue.

Also it is not easy to understand how some response variables work. There is no example for elements or attachments in https://rasa.com/docs/rasa/responses#custom-output-payloads. The custom output payload is defined as “custom” key in domain, but as json_message in the dispatcher. The “buttons” key in the domain changes to “quick_replies” in the response. The Response Format https://rasa.com/docs/rasa/next/nlg#response-format-1 doesn’t contain quick_replies or mentions that keys can change their names.

1 Like

I ran a few more tests on the socket.io connector. I think the issue is in the socketio channel. This is what i did: Copied the “rasa/core/channels/socketio.py” implementation into my rasa open source folder. Added it as a custom connector in the credentials.yml:

sockettest.SocketIOInput:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

Changed the method send_custom_json in class SocketIOOutput from: image

to:

image

Now I recieve the custom output payloads in my frontend. Please fix this asap, I need it for chatbot development. Thank you.

Just found the same issue on github Custom output payloads inconsistent documentation · Issue #5461 · RasaHQ/rasa · GitHub, where it has been categorized as an bug and not fixed since March.

So I would assume that this channel implementation is intentend but wasn’t included in the documentation?

@RGK Any update about this? has this been resolved yet?

I came up to this too and tried the custom fix but I believe this not the best solution!

@OmarFarag95 Unfortunately I got no update on this issue. I haven’t checked if it is fixed, because I changed my chatbot platform.

Hi, can anyone here help me with my issue: How to override socketio.py to handle custom paylods