问题描述
控制器:
?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 (将#修改为@)