Websocket Channel - making external calls

Hello there

I am currently developing a chatbot using Rasa Open Source. I make use of webchat (https://github.com/botfront/rasa-webchat) to integrate the chatbot in a website. In order to do so, I have configured the credentials.yml as follows: socketio: user_message_evt: user_uttered bot_message_evt: bot_uttered session_persistence: true

I get my assistant to work on a dummy index.html where I can chat with it, everything works fine! Now to my question: I want to externally send a message to the bot (not via the actual chat widget). The message should look something like /greet{“entity1”: “value1”, “entity2”: “value2”}. Looking at the rasa docs, I sent the following POST request to http://localhost:5005/socket.io (since rasa is running on localhost:5005): { “message”: " /greet{“entity1”: “value1”, “entity2”: “value2”}" }

What happens is I get the following response: The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO)

Do you know where the issue is? All I want is to basically trigger an intent with entities with a POST in order to have to bot display the response in the chat widget again.

Kind regards

@BotEnthusiast can you please share the rasa --version. I’m guessing you are using 3. x ? also confirm with me are you able to chat with the bot using the index.html file locally?

Correct, I am currently using Rasa 3.0.6 with Python 3.8.12 Yes exactly, I am running rasa (rasa run --enable-api --cors “*”) as well as the action server (rasa run actions) both locally. By opening the index.html file location in my browser, I am able to chat with the bot locally, everything works just fine!

Kind regards

@BotEnthusiast

Try to use ngrok and then test the external calls.

@nik202 Even when I’m using ngrok, same thing… 400 bad request with the message “The client is using an unsupported version of the Socket.IO or Engine.IO protocols”.

Btw I’m testing the POST-calls with Postman and I’m sending the request to the address <ngrok_url>/socket.io/

The screenshot shows the difference: The external POST-call (using Postman) results in the 400 Bad request. When sending the same message via Chat-Widget, the 200 OK POST-request takes place.

Rasa

I am quite lost and do not really know how to make these POST-calls from somewhere else than the actual widget possible…

Kind regards

@BotEnthusiast no worries, together will solve the issue.

Can you share a few things with me?

  1. rasa --version whilst activating env.
  2. error message you are getting on the rasa server terminal [updated action to rasa ]
  3. why are you using ngrok and postman for what purpose
  4. Are you using any Chat-Widget if yes which one and share snippet code.

Thanks

Hi nik

  1. In my active environment, I have the following versions: Rasa → 3.0.6, Rasa SDK → 3.0.4, Rasa X → not used, Python → 3.8.12

  2. When I make the call, nothing happens at the action server terminal. However, this is also the case for when the call works (using the widget). But this should be okay, I don’t see any issue with the action server!

  3. I am using ngrok because you said I should try it. The scenario right now is as follows: I use “ngrok http 5005”, “rasa run actions” and “rasa run --enable-api --cors “*””. I then open my index.html, which opens an empty page with the chat widget. If I then chat with the bot, everything works fine! I now use Postman in order to try and make a POST-request without actually chatting to the bot (which is my goal)! As soon as I do this POST request to <ngrok_url>/socket.io/, I get the error 400 with the above mentioned message.

  4. Yes, I am using rasa-webchat from botfront (GitHub - botfront/rasa-webchat: A feature-rich chat widget for Rasa and Botfront). The code I am using is the following:

Of course, I replace the ngrok link with the new one provided and use it as the socker URL. As I mentioned before, if I use the chat widged in a regular manner, everything works just fine!

Kind regards

Apologies, I was asking for the rasa server running on port and wrote action server.

Can you use this command: rasa run -m models --enable-api --cors "*" --debug

This seems fine to me.

When you run the above-mentioned command, please share the full traceback with a screenshot.

So I ran the command u suggested (rasa run -m models --enable-api --cors "*" --debug) while having the index.html file open. The result was the following:

Everything above the red line happens because the index.html file is open. Even with all this, I can still chat with the widget and everything works fine. However, something with the WebSocket connection still seems to be weird.

Everything below the red line is what I get when I use Postman to send a POST-request to the ngrok-address (in this case: https://096b-2a05-dcc0-f-f700-69a9-55e6-127e-1891.ngrok.io/socket.io). In ngrok, I just get a 400 Bad Request message.

I hope this helps. Thank you very much :slight_smile:

Kind regards

@BotEnthusiast share me ngrok running screenshot where you run the command ngrok http 5005

OR

I guess you need to authenticate the ngrok token.

It will remove the Session-Expires and make it (Free) 24/7

So, create an account and authenticate, and do let me know.

I request you please tag me @ nik202 next time.

@nik202

I just created a ngrok account and I don’t think there is any issue with ngrok itself… This is what the ngrok looks like when running and making 1 call using Postman:

This is what the Postman looks like:

Still, this is the error I get in the console where rasa is running:

I tried to also upgrade and downgrade different versions accoring to this post: python - The client is using an unsupported version of the Socket.IO or Engine.IO protocols Error - Stack Overflow But also, this did not solve the issue… I do not know where the issue might be

Kind regards

I was finally able to solve it! I had to use the SocketIO channel on Postman (Postman Now Supports Socket.IO | Postman Blog), connect to the instance of ngrok and then send an event “user_uttered” with the payload of the message ( for example { “message” : “Hey” } ) and then listen to events called “bot_uttered”. This finally resulted in successful calls as well as responses.

@nik202 Thank you very much for all you effort!

Hi, I’m also trying to test my bot in postman via web socket but instead of ngrok I’m using docker. I am trying to send user_uttered event as the following picture and listening to bot_uttered, but I’m not getting any response, even I don’t see any logs of any message in the command line.