0099ff / dialogflowphp
A PHP-SDK for V1 of the Dialogflow API
Installs: 302
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
Type:package
This package is not auto-updated.
Last update: 2024-03-17 01:59:25 UTC
README
Unofficial PHP library for V1 of the Dialogflow API.
Install
composer require 0099ff/dialogflowphp
Usage
include "vendor/autoload.php"; use DialogflowPHP\Client; $client = new Client('developer_access_token', 'session_id'); $response = $client->query("Hi Chatbot!"); echo $response->result->fulfillment->speech;
Hello, puny human
echo $response->result->score;
0.91000002622604
Agent responses can also be returned as a JSON string:
$response = $client->query("Hi chatbot!", $return_as_json=true); echo $response;
{ "id": "xxxx", "timestamp": "2018-05-05T09:52:25.905Z", "lang": "en", "result": { "source": "agent", "resolvedQuery": "Hi chatbot!", "action": "", "actionIncomplete": false, "parameters": {}, "contexts": [], "metadata": { "intentId": "xxxx", "webhookUsed": "false", "webhookForSlotFillingUsed": "false", "intentName": "Hey" }, "fulfillment": { "speech": "Hello, puny human", "messages": [ { "type": 0, "speech": "Hello, puny human" } ] }, "score": 0.9100000262260437 }, "status": { "code": 200, "errorType": "success" }, "sessionId": "session_id" }