Closed Jqii closed 2 years ago
The ask
method only works inside a conversation class. Inside the hears
method, you need to start a new conversation like $bot->startConversation(new YourConversationClass());
The
ask
method only works inside a conversation class. Inside thehears
method, you need to start a new conversation like$bot->startConversation(new YourConversationClass());
It doesn't work even if you are using conversation class (in a non-studio project). Any help @christophrumpel ?
@christophrumpel i m using botman with symfony and i have the same problem with , the ask method not working even in conversation ! Can u help me ?
Here is a working example with WebDriver
:
`<?php
namespace App\Http\Controllers;
use BotMan\BotMan\BotManFactory; use BotMan\BotMan\Cache\LaravelCache; use BotMan\BotMan\Drivers\DriverManager; use BotMan\Drivers\Web\WebDriver;
class EntryPointController extends Controller { public function __invoke() { $config = []; DriverManager::loadDriver(WebDriver::class);
// Create an instance
$botman = BotManFactory::create($config, new LaravelCache(), app()->make("request"));
$botman->hears("Hi", function ($bot) {
$bot->reply("Hello!");
});
$botman->listen();
}
}`
in route.php
Route::post('botman', EntryPointController::class);
hi , im using laravel 5.7 and botman 2.0 without the botman studio. When i using the ask() method with the controller i provide below,
example conversation
ME: hi BOT: Enter name ME: jq
by right it should reply , u enter jq and Conversation End,
by now the bot is return me nothing, is anything i done wrong?
note : when i using botman studio can, but i install in my project the ask method are not function
my controller
namespace App\Http\Controllers;
use BotMan\BotMan\BotMan; use Illuminate\Http\Request; use BotMan\BotMan\BotManFactory; use BotMan\BotMan\Drivers\DriverManager;
class BotManController extends Controller { public function handle() {
$config = [ 'botframework' => [ 'app_id' => env('MICROSOFT_APP_ID'), 'app_key' => env('MICROSOFT_APP_KEY'), ] ]; DriverManager::loadDriver(\BotMan\Drivers\BotFramework\BotFrameworkDriver::class); $botman = BotManFactory::create($config); $botman->hears('Hi', function ($bot) { $bot->ask('Enter name ', function(Answer $answer) { $this->say('u enter '.$answer->getText(); $bot->say('Conversation End'); }); }); $botman->listen(); } }