Rasa WebChat集成

3
我使用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。但我不知道该如何做到这一点。我尝试在网上寻找帮助,但是没有找到有用的信息。能否有人帮助我?谢谢。


请看这个: https://www.youtube.com/watch?v=wL-6_e0pYbU - Atul Verma
3个回答

3
为了将Rasa Core与您的Web聊天连接,执行以下操作:
  1. Create a credentials file (credentials.yml) with the following content:

    socketio:
        user_message_evt: user_uttered
        bot_message_evt: bot_uttered
    
  2. Start Rasa Core with the following command (I assume you have already trained your model):

    python -m rasa_core.run \
    --credentials <path to your credentials>.yml \
    -d <path to your trained core model> \
    -p 5500 # either change the port here to 5500 or to 5005 in the js script
    

由于您在凭据文件中指定了socketio配置,Rasa Core会自动启动SocketIO输入通道,然后您网站上的脚本会连接到该通道。

要添加NLU,您有两个选项:

  1. 在Rasa Core的run命令中使用-u <path to model>指定经过训练的NLU模型
  2. 运行单独的NLU服务器,并使用端点配置进行配置。这在此处有详细解释。

Rasa Core文档可能也能帮助您。


花了几个小时尝试运行它,只得到输出但聊天室没有回应。127.0.0.1 - - [2019-05-19 21:26:23] "GET /webhooks/chatroom/conversations/581bbacb-9e64-4540-ad8d-0e295218831d/log?nocache=1558290383843 HTTP/1.1" 404 342 0.001577 - Vic Nicethemer
1
感谢您挽救了我的一天,我认为这是官方文档中缺失或隐藏的部分。对于任何遇到CORS问题的人,请尝试在末尾添加“--cors“*””。 - lazurey

1
为了拥有一个网络频道,您需要具备一个前端,它可以发送和接收聊天内容。Scalableminds提供了一个开源项目。请先查看演示。 演示 要将您的Rasa机器人与此聊天室集成,您可以按照下面的Github项目中所示安装聊天室项目。它也适用于最新的0.11 Rasa版本。 Scalableminds的聊天室

花了几个小时尝试让它运行起来,只得到了输出,但聊天没有回应。127.0.0.1 - - [2019-05-19 21:26:23] "GET /webhooks/chatroom/conversations/581bbacb-9e64-4540-ad8d-0e295218831d/log?nocache=1558290383843 HTTP/1.1" 404 342 0.001577 - Vic Nicethemer

0
你面临一个依赖问题,请确认你正在使用的Rasa 版本和 Web-chat 版本。
Web-chat 不支持 Rasa 2+ 版本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接