1. Go to this page and download the library: Download iansltx/api-ai-bridge library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use iansltx\DialogflowBridge\{Middleware, Router, Question, Answer};
// uildFromClosureArray([
'hello' => function(Question $question, Answer $answer) : Answer {
return $answer->withSpeechAndText("Hello {$question->getParam('name', 'world')}!");
}
], function (Question $question, Answer $answer) : Answer {
return $answer->withSpeechAndText("Sorry, I'm not sure what to do here.");
})));
$app->run();
use iansltx\DialogflowBridge\{Middleware, Router, Question, Answer};
// uild($app->getContainer(), [
'hello' => 'helloHandler'
], function (Question $question, Answer $answer) : Answer {
return $answer->withSpeechAndText("Sorry, I'm not sure what to do here.");
})));
$app->run();
$middleware = new Middleware\PSR15($router, function($data) {
return new \Zend\Diactoros\JsonResponse($data);
});
/** @var \Psr\Http\Message\ServerRequestInterface $request */
$question = Question::fromRequest($request); // from a PSR-7 request
/** @var array $data */
$question = new Question($data); // from an array, e.g. by JSON-decoding the web hook request body
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.