Mai jos este răspunsul I a lua când încarc o imagine ca atașament pe messenger facebook. Am folosit dialogflow.com și integrate de tratare a mea webhook în nodejs folosind funcția AWS Lambda, API Gateway si AWS CloudWatch Jurnale. Puteți servi, de asemenea webhook cerere și de imprimare jurnale. Scrierea console.log () într-adevăr a ajutat pentru a imprima obiectului trimis de la messenger Facbook la webhook nostru.
exports.handler = (event, context, callback) => {
console.log(event);
console.log(event.originalRequest.data.message.attachments[0].payload.url);
};
Vei primi adresa URL obiect eveniment tipărit în jurnalele de cloudwatch: Aici , în cazul obiecta URL - ul este: https://scontent-ort2-2.xx.fbcdn.net/v/t34.18173-12/30776728_1969968496378460_1504397895_n.png?_nc_cat = 0 & _nc_ad = zm & _nc_cid = 0 & oh = 4aad83994a5501d1c50f7e2e6c7d50ea & oe = 5ADBEF72
{
"originalRequest": {
"source": "facebook",
"data": {
"sender": {
"id": "2037600292946778"
},
"recipient": {
"id": "592499574453638"
},
"message": {
"attachments": [
{
"payload": {
"url": "https://scontent-ort2-2.xx.fbcdn.net/v/t34.18173-12/30776728_1969968496378460_1504397895_n.png?_nc_cat=0&_nc_ad=z-m&_nc_cid=0&oh=4aad83994a5501d1c50f7e2e6c7d50ea&oe=5ADBEF72"
},
"type": "image"
}
],
"mid": "mid.$cAAJAFU4_rqppFAhJFli4sL-nvI2y",
"seq": 274
},
"timestamp": 1524222785882
}
},
"id": "323b2069-1fb3-4643-9cab-a36562286069",
"timestamp": "2018-04-20T11:13:06.117Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "FACEBOOK_MEDIA",
"speech": "",
"action": "",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "facebook_media",
"parameters": {},
"lifespan": 0
},
{
"name": "generic",
"parameters": {
"facebook_sender_id": "2037600292946778"
},
"lifespan": 4
}
],
"metadata": {
"intentId": "52d18e01-1ff2-4e35-af42-bc2de65fa38b",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"intentName": "attachment intent"
},
"fulfillment": {
"speech": "Received an image",
"messages": [
{
"type": 0,
"speech": "Received an image"
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success",
"webhookTimedOut": false
},
"sessionId": "d815740b-4f6d-432b-991d-c1125ceb2665"
}