Symfony\Component\Debug\Exception\FatalThrowableError.传递给App\Http\Controllers\API\BotManController::App\Http\Controllers\API{closure}()的参数1必须是BotMan\BotMan的实例,BotMan\BotMan\BotMan给定的实例。
我试图借助提供的文件在Botman中实现NLP应用程序。
但我找不到问题。下面的代码显示了我尝试过的内容。
use BotMan\BotMan\Middleware\ApiAi;
public function handle(Request $request){
$config = ['web'=>['matchingData'=>['driver'=>'web']]];
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$doctrineCacheDriver = new \Doctrine\Common\Cache\PhpFileCache('cache');
$botman = BotManFactory::create($config, new DoctrineCache($doctrineCacheDriver));
$dialogflow = ApiAi::create('dialog_flow_client_token')->listenForAction();
$botman->middleware->received($dialogflow);
// Apply matching middleware per hears command
$botman->hears('intent-action-name', function (BotMan $bot){$extras = $bot->getMessage()->getExtras();
$apiReply = $extras['apiReply'];$apiAction = $extras['apiAction'];$apiIntent = $extras['apiIntent'];
})->middleware($dialogflow);
$botman->listen();
}发布于 2019-10-18 11:06:27
在函数闭包依赖项注入中显式调用BotMan以避免与当前命名空间混淆
$botman->hears('intent-action-name', function (\BotMan\BotMan $bot) {
$extras = $bot->getMessage()->getExtras();
$apiReply = $extras['apiReply'];
$apiAction = $extras['apiAction'];
$apiIntent = $extras['apiIntent'];
})->middleware($dialogflow);希望这能有所帮助
发布于 2019-10-18 11:24:25
使用\ Botman \BotMan工作,而不是使用BotMan导入使用BotMan\BotMan;.Thanks @sally3301它工作了
https://stackoverflow.com/questions/58449435
复制相似问题