I'm using the Botfront/rasa-webchat component on a webpage. I want to send the message returned by the bot to a bot libre avatar. TBH I'm not a javascript programmer, most of my work is in python, but I cannot figure out how I can get the result returned by rasa so I can pass it to the avatar SDK. I believe the onSocketEvent may hold the key, but I haven't been able to make that work. Please help. Here's my current (dysfunctional) code.
<html>
<body>
<p>welcome to the class chatbot</p>
<script type='text/javascript' src="https://www.botlibre.com/scripts/sdk.js"></script>
<script type='text/javascript'>
!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.js"),
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
customData: { language: "en" },
socketUrl: "http://localhost:5005",
onSocketEvent: onSocketEvent,
// add other props here
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
SDK.applicationId = "1591399486198011154";
var sdk = new SDKConnection();
var web = new WebAvatar();
web.version = 8.5;
web.connection = sdk;
web.avatar = "37788053";
web.voice = "cmu-slt";
web.voiceMod = "default";
web.width = "300";
web.height = "300";
web.createBox();
web.addMessage("Hello, I am Tuesday. The class chatbot", "", "", "");
web.processMessages();
onSocketEvent={
'bot_uttered': function(e) {console.log(e.bot_uttered)
},
'connect': () => console.log('connection established'),
'disconnect': () => doSomeCleanup(),
};
</script>
</body>
</html>