Testing Rasa Socket.IO Channel

Rasa supports general purpose API access via a REST or Websocket channel. This post discusses use of a web SocketIO Tool to test your Rasa socket channel.

The Rasa Websocket channel is documented here and the source code is here.

Configuring Websockets in Rasa

Enabling the Websockets channel is described here. The default socket.io endpoint is http://<host>:<port>/socket.io. As you can see from the docs, the socket events that will be used for receiving user events and posting bot responses are configurable but I’ll assume you’re using the suggested default event names of user_uttered and bot_uttered.

Rasa Chat Widgets

There are two chat widgets for Rasa that use the socket channel. The Botfront rasa-webchat widget and the Rasa provided “official Rasa Chat Widget”.

You’ll find documentation on the Rasa widget here and here. I don’t use the Rasa widget because it is not open source and as of this writing, it is not actively maintained.

Testing the Rasa Websocket

There’s a great web tool for testing the Rasa websocket channel at https://amritb.github.io/socketio-client-tool.

For this example, I’m going to assume we have configured a Rasa chatbot with it’s websocket at https://website-demo.rasa.com/socket.io and we’re using the default event names for user and bot utterances.

{"path": "/socket.io", "forceNew": true, "reconnectionAttempts": 3, "timeout": 2000, "sid":"test_session_id","upgrades":["websocket"],"pingTimeout":20000,"pingInterval":25000}
  • Press Connect and you should establish a connection to the Rasa socket channel
  • Under the Listen tab, enter bot_uttered and click Add
  • Go to the Emit tab, enter user_uttered in the Event name field and click Add

If you were able to successfully connect to your socket channel, you should now be able to enter a message and send it to the bot. To do this:

  • Select the user_uttered event name and in the message field
  • Enable the JSON data switch
  • Enter an example message like the one here and click the Emit button.
{"message":"hi","session_id":"test_session_id"}

With the enhanced Socket channel, you can add metadata:

{"message":"hi","session_id":"test_session_id","metadata":{"language":"en","bot":"ris"}}