我正在使用DIalogflow(api.ai)来创建聊天界面。就目前而言,我只有一个名为“姓名”的简单意图,例如“谁是约翰?”它回应'约翰是'。关于Dialoglow这个问题的json输出如下:
{
"id": "my_project_id",
"timestamp": "2018-03-20T14:41:02.561Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "Who is John",
"action": "",
"actionIncomplete": false,
"parameters": {
"given-name": "John"
},
"contexts": [],
"metadata": {
"intentId": "0fb73421-0d19-4a09-b7e9-1e767041547f",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"webhookResponseTime": 2224,
"intentName": "Identity"
},
"fulfillment": {
"speech": "John is a",
"messages": [
{
"type": 0,
"speech": "John is a"
}
]
},
"score": 1
},
"status": {
"code": 206,
"errorType": "partial_content",
"errorDetails": "Webhook call failed. Error: Failed to parse webhook JSON response: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $.",
"webhookTimedOut": false
},
"sessionId": "491d57cb-0af2-45ac-a658-9e47ec6658ce",
"alternativeResultsFromKnowledgeService": {}
}
我在Dialogflow中创建了一个webhook到一个简单的应用程序,其中包含部署在Heroku上的php脚本,以便更改问题的答案,例如: '谁是约翰'。 我的PHP脚本在Heroku上打印以下答案:
{"speech":"This is a too personal question.","displayText":"This is a too personal question.","source":"webhook"}
但是正如您在Dialogflow上面的json输出中看到的那样,我收到以下错误:
"Webhook call failed. Error: Failed to parse webhook JSON response: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $."
这就是为什么webhook不起作用的原因,我无法从Heroku上的php脚本回到Dialogflow来检索答案('这是一个太个人的问题')。
为什么我收到此错误,因为我的输出是有效的json输出?