It works pretty well on Slack.com. But what I need is to add this to our website using a code snippet. When I looked up on that, I was able to find out that RASA Webchat (GitHub - mrbot-ai/rasa-webchat: A simple webchat widget to connect with a chatbot ) can be used to add the chatbot to the website. So, I pasted this code on my website inside the < body > tag.
<div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-0.4.1.js"></script>
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "/get_started",
interval: 1000, // 1000 ms between each message
customData: {"userId": "123"}, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: "http://localhost:5500",
socketPath: "/socket.io/",
title: "Title",
subtitle: "Subtitle",
profileAvatar: "http://to.avat.ar",
})
</script>
I want to connect this python chat-bot to the âRasa-webchatâ instead of using Slack. But I donât know how to do that. I tried looking everywhere, But I couldnât find anything helpful on the internet. Can someone help me? Thank you.
In the widget snippet, you need to add your socketUrl and socketPath
OT: I found myself in a similar situation a few weeks ago. Depending on your use case, instead of using the Rasa webchat widget, it could be useful to setup a Messenger bot and just use the Facebook chat widget snippet on your website as well. For me, as I wanted a Messenger bot with all its features (e.g. button types), this was the easier way to do it.
from rasa_core.channels import HttpInputChannel
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_slack_connector import SlackInput
from rasa_core.channels.socketio import SocketIOInput
from rasa_core.agent import Agent
from rasa_core.interpreter import RegexInterpreter
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter)
input_channel = SocketIOInput(user_message_evt="user_uttered", bot_message_evt="bot_uttered", namespace=None)
# set serve_forever=False if you want to keep the server running
s = agent.handle_channels([input_channel], 5004, serve_forever=False)
Iâm getting this error now :
(base) C:\Users\Dilanka's laptop\Desktop\Chatbot\bot>run_app.py
Traceback (most recent call last):
File "C:\Users\Dilanka's laptop\Desktop\Chatbot\bot\run_app.py", line 6, in <module>
from rasa_core.channels.socketio import SocketIOInput
ModuleNotFoundError: No module named 'rasa_core.channels.socketio'
Iâm getting this error on both Anaconda prompt and windows CMD.
(base) C:\Users\Dilanka's laptop>import rasa_core
'import' is not recognized as an internal or external command,
operable program or batch file.
(base) C:\Users\Dilanka's laptop>rasa_core.__version__
'rasa_core.__version__' is not recognized as an internal or external command,
operable program or batch file.
(base) C:\Users\Dilanka's laptop>from rasa_core.channels.socketio import SocketIOInput
'from' is not recognized as an internal or external command,
operable program or batch file.
I am not sure the above error got resolved or not. I believe you have tried the demo Weatherbot based from the Video using Slack. If we want to switch to Socket IO - we have to first socket io then try compiling run_app.py.
More details:
if you look at the error, it says
from rasa_core.channels import SocketIOInput
ImportError: cannot import name âSocketIOInputâ
You can check your installed location of rasa_core and it doesnt have socket.io.py. I did faced the issue and after importing I am able to execute run_app.py. Now I got stuck in receiving messages from front end app (react or javascript app). I am getting the message in the Bot server â405 errorâ (Method not allowed). Any Help is highly appreciated.