[英]Unable to integrate Dialogflow in botman
Symfony\Component\Debug\Exception\FatalThrowableError.
Symfony\Component\Debug\Exception\FatalThrowableError。 Argument 1 passed to App\Http\Controllers\API\BotManController::App\Http\Controllers\API{closure}() must be an instance of BotMan\BotMan, instance of BotMan\BotMan\BotMan given.
传递给 App\Http\Controllers\API\BotManController::App\Http\Controllers\API{closure}() 的参数 1 必须是 BotMan\BotMan 的实例,给定的 BotMan\BotMan\BotMan 的实例。
I tried to implement NLP APIAI in Botman with the help of documentation provided我尝试在提供的文档的帮助下在 Botman 中实现 NLP APIAI
but I couldn't find the issue.但我找不到问题。 what I have tried is shown in my code below.
我尝试过的内容显示在下面的代码中。
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();
}
Make an explicit call for BotMan
in the function closure dependency injection to avoid confusion with current namespace在 function 闭包依赖注入中明确调用
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);
Hope this helps希望这可以帮助
using \BotMan\BotMan worked instead of using Botman importing use BotMan\BotMan;使用 \BotMan\BotMan 工作,而不是使用 Botman 导入使用 BotMan\BotMan; .Thanks @sally 3301 it worked
.Thanks @sally 3301 它成功了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.