微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

博特曼Laravel除介绍性消息外,未在laravel中回复

如何解决博特曼Laravel除介绍性消息外,未在laravel中回复

控制器:

?PHP
   namespace App\Http\Controllers;
  use BotMan\BotMan\BotMan;
  use Illuminate\Http\Request;
 use BotMan\BotMan\Messages\Incoming\Answer;
 class chatbotController extends Controller
   {
 public function handle()
{
    $botman = app('botman');
    $botman->hears('hi',function($bot) {
        $this->askName($botman);
    });
    $botman->hears('{message}',function($botman,$message) {           
        if ($message == 'Something electronic like a phone or TV') {
            $this->tree1($botman);
        }elseif($message == 'A trip to my favorite destination'){
            $this->tree2($botman);
        }
        elseif($message == 'Something else'){
            $this->tree3($botman);
        }
    }); 
         }
          public function tree1($botman)
      {
      $botman->ask('Choose 1: a)Phone. /n b) TV /n c) something else',function(Answer $answer) {
        $category = $answer->getText();
    }

视图为:

  <!doctype html>
     <html>
<head>
    <Meta charset="utf-8">
    <Meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Myffer chatbot</title>
    <script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
  
</head>
<body>
</body>

 <script>
    var botmanWidget = {
        aboutText: 'Myffer',introMessage: "Hi,how are you. My name is Matt and I will make sure you get the best 
 possible deal. Tell me,which type of product you are looking for?"
    };
     </script>

     </html>

这发送介绍性消息,然后不回复? 我也想添加一些条件语句。像bot给出2个选项,然后单击其中一个bot会显示消息并询问其他问题 我对laravel和botman还是陌生的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。