Deploy webchat ngrok socket io

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

Title
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: "http://6892a642.ngrok.io:5005", title: "Connect", subtitle: "The bot which connects people", profileAvatar: "https://rasa.com/assets/img/demo/rasa_avatar.png", showCloseButton: true, fullScreenMode: false, hideWhenNotConnected: false,
    })
</script>

connector.py: 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
action_endpoint=EndpointConfig(url="http://6892a642.ngrok.io:5055/webhook")
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
user_message_evt="user_uttered",
# event name for messages sent from the bot
bot_message_evt="bot_uttered",
# socket.io namespace to use for the messages
namespace=None
)

# 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

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