0099ff / dialogflowphp
Dialogflow API V1 的 PHP-SDK
dev-master
2018-05-22 14:10 UTC
This package is not auto-updated.
Last update: 2024-09-29 04:47:58 UTC
README
Dialogflow API V1 的非官方 PHP 库。
安装
composer require 0099ff/dialogflowphp
用法
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;
你好,渺小的人类
echo $response->result->score;
0.91000002622604
代理响应也可以作为 JSON 字符串返回
$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" }