简体   繁体   English

带有小部件的 PHP BotMan 对话实现

[英]PHP BotMan Conversation implementation with widget

I am trying to implement the PHP BotMan with the botman widget, however when I use reply it does send back the reply of the message.我正在尝试使用 botman 小部件实现 PHP BotMan,但是当我使用回复时,它会发回消息的回复。 Now I am trying to do it with conversation and it is just giving me an JSON response back.现在我正在尝试通过对话来做到这一点,它只是给了我一个 JSON 响应。 Is there any way to send the reply message to the widget?有没有办法将回复消息发送到小部件?

This is the OnboardConversation.php File这是OnboardConversation.php 文件

Here is chat.php这是chat.php

Note that when I use from the chat.php请注意,当我从 chat.php 使用

// Give the bot something to listen for.
$botman->hears('Hello', function (BotMan $bot) {
  $bot->reply('Hello too');
});

I do get the response in the chat widget but when I use the conversation I get the following.我确实在聊天小部件中得到了响应,但是当我使用对话时,我得到以下信息。

{"status":200,"messages":[{"type":"text","text":"Hello! What is your firstname?","attachment":null,"additionalParameters":[]}]}{"status":200,"messages":[{"type":"text","text":"Nice to meet you hello","attachment":null,"additionalParameters":[]},{"type":"text","text":"One more thing - what is your email?","attachment":null,"additionalParameters":[]}]} {"status":200,"messages":[{"type":"text","text":"你好!你的名字是什么?","attachment":null,"additionalParameters":[]}]} {"status":200,"messages":[{"type":"text","text":"很高兴认识你,你好","attachment":null,"additionalParameters":[]},{"type ":"text","text":"还有一件事 - 你的电子邮件是什么?","attachment":null,"additionalParameters":[]}]}

I want this json response to be sent to widget, how can I do it?我希望将此 json 响应发送到小部件,我该怎么做?

Do you go straight to the fallback or do you get no reply at all?你是直接回退还是根本没有得到答复?

Also you can try adding BotMan on the first line of the hears function.您也可以尝试在听到功能的第一行添加 BotMan。

$botman->hears('Hello', function(BotMan $bot) {
    $bot->startConversation(new OnboardingConversation);
});

You forgot the web driver manager as well您也忘记了网络驱动程序管理器

$config = [
    'web' => [
        'matchingData' => [
            'driver' => 'web',
        ],
    ]
];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM