【问题标题】:PHP BotMan Conversation implementation with widget带有小部件的 PHP BotMan 对话实现
【发布时间】:2018-06-11 21:57:38
【问题描述】:

我正在尝试使用 botman 小部件实现 PHP BotMan, 但是,当我使用回复时,它确实会发回消息的回复。现在我正在尝试通过对话来做到这一点,它只是给了我一个 JSON 响应。有没有办法将回复消息发送到小部件?

This is OnboardConversation.php 文件

这里是chat.php

注意当我从chat.php中使用时

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

我确实在聊天小部件中得到了响应,但是当我使用对话时,我得到了以下内容。

{"status":200,"messages":[{"type":"text","text":"你好!你的名字是什么?","attachment":null,"additionalParameters":[] }]}{"status":200,"messages":[{"type":"text","text":"很高兴认识你你好","attachment":null,"additionalParameters":[]}, {"type":"text","text":"还有一件事 - 你的电子邮件是什么?","attachment":null,"additionalParameters":[]}]}

我希望将此 json 响应发送到小部件,我该怎么做?

【问题讨论】:

    标签: php chatbot botman


    【解决方案1】:

    您是直接返回后备,还是根本没有得到回复?

    您也可以尝试在 hears 函数的第一行添加 BotMan。

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

    你也忘记了网络驱动管理器

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

    【讨论】:

      猜你喜欢
      • 2020-04-16
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 2023-02-23
      • 2012-12-27
      相关资源
      最近更新 更多