简体   繁体   中英

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. Now I am trying to do it with conversation and it is just giving me an JSON response back. Is there any way to send the reply message to the widget?

This is the OnboardConversation.php File

Here is chat.php

Note that when I use from the 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":[]}]}

I want this json response to be sent to widget, how can I do it?

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->hears('Hello', function(BotMan $bot) {
    $bot->startConversation(new OnboardingConversation);
});

You forgot the web driver manager as well

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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