Botman对话失败($ this-> say)

时间:2018-09-14 15:07:27

标签: php laravel

Botman服务器设置:

-WAMP服务器

-composer 1.7.2

-php 7.2.4

-在C:\ wam64 \ www中运行composer global require“ botman / installer” -Composer文件夹安装在AppData / Roaming /

-botman新chatbot-完成安装过程,并在www中创建文件夹“ chatbot”-给出消息:Botman studio准备好了!建立一个很棒的聊天机器人

-将目录更改为聊天机器人

-Web驱动程序

我有3个文件:

1)包含样式和

的Chat.html
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/assets/css/chat.min.css">
<script id="botmanWidget" src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/chat.js'></script>

2)具有端点和聊天服务器的Index.php

<script>
var botmanWidget = {
            frameEndpoint: '/1/bot/chat.html',
            introMessage: 'Hello, I am a Chatbot',
            chatServer : '/1/bot/chat.php', 
            title: 'My Chatbot', 
            mainColor: '#456765',
            bubbleBackground: '#ff76f4',
            aboutText: '',
            bubbleAvatarUrl: '',
}; 
</script>

<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>

3)chat.php-聊天室的构建

<?php
   namespace app\Http\Conversations;
   require_once 'vendor/autoload.php';
   use BotMan\BotMan\BotMan;
   use BotMan\BotMan\BotManFactory;
   use BotMan\BotMan\Drivers\DriverManager;

   use BotMan\BotMan\Messages\Incoming\Answer;
   use BotMan\BotMan\Messages\Outgoing\Question;
   use BotMan\BotMan\Messages\Outgoing\Actions\Button;  
   use BotMan\BotMan\Messages\Conversations\Conversation;

DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);

$botman = BotManFactory::create($config);

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

class OnboardingConversation extends Conversation
{
    public function run()
    {
        $this->say ('hello');
        $this->ask ('What is your name?', function ($answer) {
            $this->say('Nice to meet you, '.$answer->getText());

        });
    }
}

// Start listening
$botman->listen();
?>

我曾尝试创建一个新的对话,将php artisan botman:make:conversation作为外部类,但是在创建所有文件后均不起作用。

使用上面的代码后,机器人会打开,当我键入xxx时,它会打声招呼你叫什么名字,但getText()失败。有什么明显的我想念的吗?

0 个答案:

没有答案