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.
I tried to implement NLP APIAI in Botman with the help of documentation provided
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
$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