Closed MortezaAliyari closed 2 years ago
By "rasa responses" are you referring to messages from user or Rasa chatbot?
There is parameter onSocketEvent
(see README) which allows one to listen and react to some of the socket events, including messages from the bot, but unfortunately that does not include messages from the user. (That event could also be exposed by would require changes to widget source code.)
Dear @rajalala thanks for your response.
Base on your expalnation onSocketEvent
should work for me. I need to listen to messages from rasabot.
for example:
user: "hi"
bot: "Hi there, How can i help you?"
I need use bot response "Hi there, How can i help you?" and send it to my mobile robot.
How could i use below code in my html file?
onSocketEvent={{
'bot_uttered': () => console.log('the bot said something'),
'connect': () => console.log('connection established'),
'disconnect': () => doSomeCleanup(),
}}
thanks in advance.
html code:
<html>
<body>
<script>!(function () {
sessionStorage.clear();// remove chats history
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.1/lib/index.js"),
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
intitpayload: '/greet',
customData: { language: "en" },
socketUrl: "http://0.0.0.0:5005",
params:{
storage: "session" // chats history location is "session", default is "local"
}
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
</script>
</body>
</html>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi, I don't know where is the correct place to ask this question, so if it's the wrong place, sorry about that! I'm using rasa3.1 and everything is working with your HTML file. I want to have access to the rasa response in an HTML file and send it with URL method to my robot? so I need to define a string variable to store received messages as rasa responses and use this message in my own way. I searched a lot but I couldn't find something useful to work correctly. I would be grateful if you give me a hand. thanks.