gambry / dialogflow-webhook
DialogFlow Webhook Fulfillment PHP sdk
Installs: 8 632
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 60
Open Issues: 0
Requires
- php: >=7.3
Requires (Dev)
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2024-12-27 18:32:37 UTC
README
This is an unofficial php sdk for Dialogflow Fulfillment.
If you are looking for Detect Intent and Agent APIs php sdk have a look a the official repo.
Dialogflow: Build brand-unique, natural language interactions for bots, applications and devices.
Install:
Via composer:
$ composer require gambry/dialogflow-webhook
Usage:
In your webhook request handler:
require_once __DIR__.'/vendor/autoload.php'; 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); } }
Note: depending by the way you handle the request the library auto-loading, the $request_body
variable and the way to return the $response
may vary.