Deploy webchat ngrok socket io

hi i try to use rasa webchat but i can’t make it work

WebChat.default.init({ selector: "#webchat", initPayload: "/get_started", interval: 1000, // 1000 ms between each message customData: { "sender": "django" }, // arbitrary custom data. Stay minimal as this will be added to the socket socketUrl: "", title: "Connect", subtitle: "The bot which connects people", profileAvatar: "", showCloseButton: true, fullScreenMode: false, hideWhenNotConnected: false,
</script> from rasa.core.agent import Agent from rasa.core.interpreter import RasaNLUInterpreter from rasa.core.channels.socketio import SocketIOInput from rasa.utils.endpoints import EndpointConfig from rasa.core.interpreter import NaturalLanguageInterpreter

# load your trained agent
interpreter = NaturalLanguageInterpreter.create('./models/20190809-043054/nlu')
agent = Agent.load('./models/20190809-043054/core', interpreter=interpreter)

input_channel = SocketIOInput(
# event name for messages sent from the user
# event name for messages sent from the bot
# namespace to use for the messages

# set serve_forever=False if you want to keep the server running
s = agent.handle_channels([input_channel], http_port=5005,route='/webhooks/',cors="*")

socketio: user_message_evt: user_uttered bot_message_evt: bot_uttered session_persistence: true

rasa: url: “http://localhost:5002/api

when i run rasa run --endpoints endpoints.yml i get engineio.server - http://localhost:63342 is not an accepted origin.

i didn’t fix it yet :frowning: can someone help me pleaase

1 Like

Hi @SallemiDorsaf. Hmm, I think you problem is related to the endpoint URLs. I can see that WebChat gets an ngrok socketUrl with the port 5005, but you agent uses /webhooks route. Do you have ngrok instance running on 5005 port? Also, is there a specific reason you use ngrok for custom action server (action_endpoint) config?

Can you test the connection when you remove the route configuration from the agent.handle_channels configuration and start the ngrok instance on the same port (5005)?

hi @Juste i removed the route configuration from the agent.handle_channels and start the ngrok instance on 5005 i still get same problem there is no specific reason to use ngrok but i didn’t found step by step documentation to deploy my bot can you help me ? thank you

I just found my old writeup on how to do it. Can you try following it and checking if that works? Connect rasa to a web site with the recommeded plataform. It uses a slightly older versions of the Rasa NLU and Core, but the main process should be the same.

Also, for the sake of simplicity, I would suggest first testing it with a local custom action server: EndpointConfig(url='http://localhost:5055/webhook')

i get this error

1 Like