作者:夜半MM | 来源:互联网 | 2023-10-13 10:58
Hello,
I have this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| $config = [
'microsoft_app_id' => $this->dbbot->microsoft_app_id,
'microsoft_app_key' => $this->dbbot->microsoft_app_key,
'microsoft_bot_handle' => $this->dbbot->name
];
$millow = BotFactory::create($config, new LaravelCache(), $request, new FileStorage(storage_path('bot')));
$millow->hears('test', function (myBot $bot) use ($id) {
$bot->reply('This is a test!');
});
$millow->middleware(Wit::create('*********'));
$millow->fallback(function (myBot $bot) use ($id) {
$bot->userStorage()->save(['id' => $id], 'bot');
$this->getContact($bot, $id);
$extras = $bot->getMessage()->getExtras();
$entities = $extras['entities'];
try {
$intent = $entities['intent'][0]['value'];
switch ($intent) {
case "greetings":
return $bot->randomReply(trans('bot.random.greetings'));
break;
case "info":
return $bot->reply(trans('bot.random.info', [
'name' => $this->dbbot->name,
'company' => $this->dbbot->company
]));
break;
default:
return $bot->reply('The intent is: ' . $intent);
break;
}
} catch (\Exception $e) {
$bot->reply('Sorry, I did not understand you.');
}
});
$millow->listen(); |
If I type 'test' on the bot, I get the message 'Sorry, I did not understand you.'
If I remove the line
1
| $millow->middleware(Wit::create('*********')); |
and type test, I get the correct reply 'This is a test!'.
I am using Laravel.
Is this a bug or I am doing something wrong?
Thank you.
该提问来源于开源项目:botman/botman
Implemented in
https://github.com/mpociot/botman/commit/66d8da5b2192ad2ac145da2fc7ea6caadc93e2ff