PHP code example of gambry / dialogflow-webhook
1. Go to this page and download the library: Download gambry/dialogflow-webhook 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/ */
gambry / dialogflow-webhook example snippets
if ($webhook_json = json_decode($request_body, TRUE)) {
$request = new \DialogFlow\Model\Webhook\Request($webhook_json);
$intent_name = $request->getResult()->getIntent()->getIntentName();
if ($intent_name === 'HelloWorld') {
$fulfillment = new \DialogFlow\Model\Fulfillment();
$fulfillment->setText('Hi from the fulfilment!');
$response = new \DialogFlow\Model\Webhook\Response();
$response->setFulfillment($fulfillment);
echo json_encode($response);
}
}