Im new to Botman.
I try to implement a simple function to test how it works, but I keep getting empty response, it look like botman do not hears my message.
I installed botman without studio since, I'm trying to keep things simple. I also installed a webdriver as it says in documentation.
In my project I use JWT as an authentification, so i created a protected route like this:
Route::group(['middleware' => ['assign.guard:user', 'jwt.auth']], function () {
Route::post(
'/',
'UserBotManController@startConversation'
)->name('botman.user.start');
});
The controller looks like this:
<?php
namespace Project\UI\Api\Controllers\User\Botman;
use App\Http\Controllers\Controller;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
class UserBotManController extends Controller
{
public function startConversation()
{
$config = [];
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$botman = BotManFactory::create($config);
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
$botman->listen();
}
}
No when I send a request to this route a get empty response:
Looks like botman can't hear my message...
I try to looked inside with: dd($botman->getDriver());
And I see that the content has all the data:
Can any one help me to understand, how I can make it work?
Ok, so finally I found a solution. I have checked what request it sends from https://botman.io website and it is Form Data, not JSON.
diver
field must be set to web
!
Hope it will help someone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.