PHPでwebhookを作成し、コンテキストパラメータを読み取る機能が必要な場合は、次のヘルプが必要です。ダイアログフローでphp webhookを使用してコンテキストパラメータを読み取る方法
どうすればいいのか理解できますか?ここで
は私の例JSONです:私はを参照できるようにしたい{
"id": "6e774dc2-2323-42b3-bd3c-ab64930f8b92",
"timestamp": "2017-12-22T21:12:19.094Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "Yes",
"action": "Triage.Triage-yes",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "triage-followup",
"parameters": {
"triagecriteria": [],
"roomEntity.original": "",
"roomname": "300",
"roomnames.original": "living",
"roomid": "200",
"context": "",
"roomnames": [
"living"
],
"counter": "400",
"roomEntity": "100",
"triagecriteria.original": ""
},
"lifespan": 3
}
],
"metadata": {
"intentId": "ecd4a2e5-65a0-41b2-ac72-edcf4d2e73f2",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"webhookResponseTime": 203,
"intentName": "Triage - yes"
},
"fulfillment": {
"speech": "Yes",
"source": "agent",
"displayText": "No",
"messages": [
{
"type": 0,
"speech": "Yes"
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success",
"webhookTimedOut": false
},
"sessionId": "db8c1a4e-fa0c-4257-a536-78b63879eef9"
}
[結果] [コンテキスト] [パラメータ]
私は
$update_response = file_get_contents("php://input");
$update = json_decode($update_response, true, 512, JSON_BIGINT_AS_STRING);
を使用してしようとしています値にアクセスする$ update ["results"] ["Contexts"] ["Parameters"] ["roomid"]
JSONデコードを試しましたか? – singh
はいJSONデコードを使用して解析しています。 – PrabS
私は$ update_response = file_get_contents( "php:// input")を使用しています。 $ update = json_decode($ update_response、true、512、JSON_BIGINT_AS_STRING); $ update ["results"] ["Contexts"] ["Parameters"] ["roomid"] – PrabS