我使用Rasa-Core和Rasa-NLU观看了这个视频:https://vimeo.com/254777331,成功在Slack上创建了一个聊天机器人。但是我需要将其通过代码片段添加到我们的网站上。当我查询相关信息时发现可以使用RASA Webchat(https://github.com/mrbot-ai/rasa-webchat:一个用于与聊天机器人连接的简单网络聊天小部件)来将聊天机器人添加到网站上。所以,我将此代码粘贴到<body>标签中。
<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>
“Run_app.py”是启动聊天机器人的文件(视频中提供:https://vimeo.com/254777331)。
Here is the code of Run_app.py :
from rasa_core.channels import HttpInputChannel
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_slack_connector import SlackInput
nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter)
input_channel = SlackInput('xoxp-381510545829-382263177798-381274424643-a3b461a2ffe4a595e35795e1f98492c9', #app verification token
'xoxb-381510545829-381150752228-kNSPU0X7HpaS8oJaqd77TPQE', # bot verification token
'B709JgyLSSyKoodEDwOiJzic', # slack verification token
True)
agent.handle_channel(HttpInputChannel(5004, '/', input_channel))
我想将这个Python聊天机器人连接到“Rasa-webchat”,而不是使用Slack。但我不知道该如何做到这一点。我尝试在网上寻找帮助,但是没有找到有用的信息。能否有人帮助我?谢谢。