This discussion applies to any integration, but as an example I'll talk about Messenger. Also, to give context, my backend is written in Java.
From what I've read, for custom scenarios (e.g. Account Linking), we shouldn't use API.AI directly. Instead, the "Callback URL" in Messenger settings (developer.facebook.com) should point to our own hosted app, which in turn calls api.api.ai/v1/query. Is that correct?
Secondly, my Intent in API.AI already has Use webhook ticked. I assume the flow of logic would be as follows:
Messenger → my app (webhook for Messenger) → api.ai → my app (webhook for api.ai)
Apparently it's not the case—API.AI never calls the webhook.
This is the JSON I sent to API.AI:
{"query":"hey","originalRequest":{"source":"facebook","data":{"object":"page","entry":[{"id":"xxx","time":yyy,"messaging":[{"sender":{"id":"zzz"},"recipient":{"id":"xxx"},"timestamp":yyy,"message":{"mid":"aaa","seq":bbb,"text":"hey"}}]}]}},"v":"20170704","sessionId":"1","lang":"en"}
And this is the response from API.AI:
{
"id": "xxx",
"timestamp": "yyy",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "hey",
"speech": "",
"action": "",
"parameters": {
"greeting": "hey"
},
"metadata": {
"inputContexts": [],
"outputContexts": [],
"intentName": "greeting",
"intentId": "zzz",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"contexts": []
},
"score": 1.0
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "1"
}
Does it mean that my app should call the webhook (which is the same app but different endpoint) itself?
