BotMan Middleware to connect DialogFlow with BotMan
Thank's to @eclips16. The code source was taken from pull request.
composer require genkovich/dialog-flow-bot-man-middleware
GOOGLE_CLOUD_PROJECT=project-id
GOOGLE_APPLICATION_CREDENTIALS=/path/to/security-file.json
- Login at https://dialogflow.cloud.google.com/
- Create NewAgent (or use an existing one)
- Click on "Settings" icon (1)
- Copy your project id (2) into .env file
- Click on project id (2)
- After that you will find "Service accounts" section (click (1) or (2))
- Click on "Create service account", fill "name" field and click "Create"
- On the next step you have to add two roles, "DialogFlow API Admin" and "DialogFlow API Client" and click "Done"
- Now, go to the page "Manage keys"
- Create new key in .json format
- Move downloaded file into project root directory
- Add path to file in .env
$dialogflow = \BotMan\Middleware\DialogFlow\V2\DialogFlow::create('en');
$botman->middleware->received($dialogflow);
$botman->hears('smalltalk.(.*)', function ($bot) {
$extras = $bot->getMessage()->getExtras();
$bot->reply($extras['apiReply']);
})->middleware($dialogflow);
smalltalk.(.*) - there is action name pattern
If you create actions with different prefixes, you can use ->ignoreIntentPattern()
$dialogflow = DialogFlow::create('en')->ignoreIntentPattern();
If you discover a security vulnerability within BotMan, please send an e-mail to Marcel Pociot at m.pociot@gmail.com. All security vulnerabilities will be promptly addressed.
BotMan is free software distributed under the terms of the MIT license.