Skip to content

Instantly share code, notes, and snippets.

@MarGul
Created June 13, 2018 18:44
Show Gist options
  • Save MarGul/00e6ea6d158b4dafcd7147bc638284bf to your computer and use it in GitHub Desktop.
Save MarGul/00e6ea6d158b4dafcd7147bc638284bf to your computer and use it in GitHub Desktop.
<?php
use App\Http\Controllers\BotManController;
use BotMan\BotMan\Middleware\ApiAi;
$botman = resolve('botman');
$dialogflow = ApiAi::create('the-developer-token-at-dialog-flow')->listenForAction();
// Apply global "received" middleware
$botman->middleware->received($dialogflow);
// Apply matching middleware per hears command
$botman->hears('find_restaurant', function (BotMan $bot) {
// The incoming message matched the "my_api_action" on Dialogflow
// Retrieve Dialogflow information:
$extras = $bot->getMessage()->getExtras();
$apiReply = $extras['apiReply'];
$apiAction = $extras['apiAction'];
$apiIntent = $extras['apiIntent'];
$bot->reply("this is my reply");
})->middleware($dialogflow);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment