I am using DIalogflow (api.ai) to create chat interfaces. For now, I only have a simple intent called 'Name' regarding the question e.g. 'Who is John?' which responds 'John is a'. The json output regarding this question from Dialoglow is the following:
{
"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": {}
}
I created a webhook from Dialogflow to a simple app containing a php script deployed on Heroku so as to change the answer for the question e.g. 'Who is John' . My PHP script prints the following answer on Heroku:
{"speech":"This is a too personal question.","displayText":"This is a too personal question.","source":"webhook"}
However as you you can see at the json output above from Dialogflow, I get the following error:
"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 $."
This is the reason why the webhook does not work and I cannot retrieve the answer ('This is a too personal question') from my php script on Heroku back to Dialogflow.
Why am I getting this error since my output is a valid json output?