I am learning how to create Dialogflow based NLP chatbot using PHP and Botman.io . I wrote a simple code that should be working, but the botman is not replying to my messages.
I have walked through the documentation and official online course from botman.io , but it did not help because they have the exact same code.
Please take a look at my code botman.php file, if it is not hard:
use App\Http\Controllers\BotManController;
use BotMan\BotMan\Middleware\Dialogflow;
use function GuzzleHttp\json_decode;
use BotMan\BotMan\Interfaces\Middleware\Received;
$botman = resolve('botman');
$dialogflow_token = 'it is secret'
$dialogflow = Dialogflow::create(dialogflow_token)->listenForAction();
$botman->middleware->received($dialogflow);
$botman->hears('weathersearch', function($bot){
$extras = $bot->getMessage()->getExtras();
$location = $extras['apiParameters']['geo-city'];
$url = 'http://api.apixu.com/v1/current.json?key=38b39a718abc4c6da25112826190108&q='.urlencode($location);
$response = json_decode(file_get_contents($url));
$bot->reply('The weather in' . $response->$location->$name . ', ' . $response->$location->$country . 'is: ');
$bot->reply($response->current->condition->text);
$bot->reply('Temperature: '.$response->current->temp_c. ' Celcius');
})->middleware($dialogflow);
?>
The bot should be responding to the messages like "what is the weather in California" by giving current weather temperature and condition, i.e 25C Sunny