【问题标题】:Rasa WebChat integrationRasa 网络聊天集成
【发布时间】:2023-04-03 17:56:02
【问题描述】:

通过观看此视频,我使用 Rasa-Core 和 Rasa-NLU 在 slack 上创建了一个聊天机器人:https://vimeo.com/254777331

它在 Slack.com 上运行良好。但我需要的是使用代码 sn-p 将其添加到我们的网站。当我查看它时,我发现 RASA Webchat(https://github.com/mrbot-ai/rasa-webchat:一个简单的与聊天机器人连接的网络聊天小部件)可用于将聊天机器人添加到网站。所以,我将这段代码粘贴到我的网站上的

标签内。
    <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。但我不知道该怎么做。我试着到处寻找,但我在互联网上找不到任何有用的东西。有人能帮我吗?谢谢。

【问题讨论】:

标签: chatbot rasa-nlu rasa-core web-chat


【解决方案1】:

为了将 Rasa Core 与您的网络聊天连接起来,请执行以下操作:

  1. 创建一个包含以下内容的凭据文件 (credentials.yml):

    socketio:
        user_message_evt: user_uttered
        bot_message_evt: bot_uttered
    
  2. 使用以下命令启动 Rasa Core(我假设您已经训练了模型):

    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 &lt;path to model&gt; 指定经过训练的 NLU 模型
  2. 运行单独的 NLU 服务器并使用端点配置对其进行配置。这在here 进行了深入解释

Rasa Core documentation 也可能对您有所帮助。

【讨论】:

  • 花了几个小时尝试启动和运行,只有输出但聊天没有回复 127.0.0.1 - - [2019-05-19 21:26:23] "GET /webhooks/chatroom/对话/581bbacb-9e64-4540-ad8d-0e295218831d/log?nocache=1558290383843 HTTP/1.1" 404 342 0.001577
  • 感谢您挽救了我的一天,我认为这是官方文档中丢失或隐藏的部分。对于遇到 CORS 问题的任何人,请尝试在末尾添加 --cors "*"。
【解决方案2】:

为了拥有一个网络频道,您需要有一个可以发送和接收聊天话语的前端。 scalableminds 有一个开源项目。先看demo

demo

要将您的 Rasa 机器人与此聊天室集成,您可以安装聊天室项目,如下面的 Github 项目所示。它也适用于最新的 0.11 Rasa 版本。

Chatroom by Scalableminds

【讨论】:

  • 花了几个小时试图让它运行起来,只有输出但聊天没有回复 127.0.0.1 - - [2019-05-19 21:26:23] "GET /webhooks/chatroom/对话/581bbacb-9e64-4540-ad8d-0e295218831d/log?nocache=1558290383843 HTTP/1.1" 404 342 0.001577
【解决方案3】:

您正面临依赖问题,请查看您使用的 rasa 版本和网络聊天版本。

网络聊天不支持 rasa 版本 2+

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-26
    相关资源
    最近更新 更多