I want to use BotMan to create a chatbot that will search inside a databse starting from the user input.
Botman will hear for a phrase that will contain also the parameter to search like this: "search for name" or "search product by id" and similar. I'm reading about web driver but I'm not sure on how to setup it for this task. What is the correct configuration to achieve this and I need to write a middleware to manage this task?
you can use Dialogflow for this purpose
I want to use an offline solution, Dialogflow is great for natural language but will not be useful for the scope of my app.
You can create a tabel (hear FULLTEXT, reply TEXT)
$botman->hears('{hear}', function ($bot, $hear) {
$results = DB::table('simple_conversation')
->selectRaw("*, MATCH (hear) AGAINST (? IN NATURAL LANGUAGE MODE) AS score", [$hear])
->whereRaw("MATCH (hear) AGAINST (? IN NATURAL LANGUAGE MODE)" , [$hear])
->havingRaw('score > ?', [0])
->orderByRaw('score DESC')
->get();
if(count($results)>0){
$bot->reply($results[0]->reply);
}
else{
$bot->reply('I dont understand <b>'.$hear.'</b>');
// send report
}
});
How about this?
Most helpful comment
You can create a tabel (hear FULLTEXT, reply TEXT)
How about this?