how to pass the date-time parameter in fcm body?
I tried passing event_time in the notification body but it is not working.
{
"registration_ids": [
"fNsi-sHiQDSWcNdx5Y2Nf9:APA91bEewR3VbuPVJO3qFDlcmqS6rp5fZilITgZJfl61JOsje6OEP13RjhxAn-0JRzf0-u8Mg-OBAKxRKtKRtpeisZagHJZsNYa_zat--1iyemwUSxdZIMRt2jxfZMiZ9Od4mk2DmznG",
"fyYtfww_QzOTVh1aFyOaTZ:APA91bFih7TD9Q04kb03Ju1zUJ66N_2yMwo2dUCr_ZJJs-NKv3AaEAimGV2lxm7kgIsVlJSXRmrau-VFZ_52AS9tqobl-vP7iXbOOT35kdEFVEROMotr4AiksD2b5vE_TWWyai3BbH9E"
],
"notification": {
"body": "killed",
"title": "killed title",
"android_channel_id": "push_notification",
"sound": false
},
"data": {
"body": "data body",
"title": "Data",
"_id": 34534
},
"android": {
"priority": "high"
}
}
Related
I'm using a dynamic template in SendGrid to send transactional emails that typically go to multiple recipients in the personalizations field. The message body includes custom_args that are shared among all recipients, and in personalizations, both custom_args and dynamic_template_data specific to each recipient. Webhook events return the shared custom_args, but none of the recipient-specific custom_args. Is there a way to get events together with the personalized custom_args? Here's an example request body where we add a userId custom_arg for each recipient:
{
"from": {
"email": "sender#example.com",
"name": "Example Sender"
},
"personalizations": [
{
"to": [
{
"email": "recipient1#example.com",
"custom_args": {
"userId": "63r20acm4xfv"
}
}
],
"dynamic_template_data": {
"subject": "New Article",
"description": "Read the lastest news on...",
"documentId": "624dxnpvhw8g",
"host": "https://localhost:8000",
"userId": "63r20acm4xfv"
}
}
],
"custom_args": {
"documentId": "624dxnpvhw8g"
}
}
And the webhook events we receive (the "documentId" custom arg is reported, but not the "userID" custom_arg from personalizations):
[
{
"documentId": "624dxnpvhw8g",
"email": "recipient1#example.com",
"event": "processed",
"sg_event_id": "cHJvY2Vzc2VkLTI3MTk3NzMzLUtTUEJOaVpGUXpXb05KblctVDBNRkEtMA",
"sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
"sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
"sg_template_name": "DEFAULT TEMPLATE",
"smtp-id": "<redacted>",
"timestamp": 1662128000
},
{
"documentId": "624dxnpvhw8g",
"email": "recipient1#example.com",
"event": "delivered",
"ip": "<redacted>",
"response": "250 Message received",
"sg_event_id": "ZGVsaXZlcmVkLTAtMjcxOTc3MzMtS1NQQk5pWkZReldvTkpuVy1UME1GQS0w",
"sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
"sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
"sg_template_name": "DEFAULT TEMPLATE",
"smtp-id": "<redacted>",
"timestamp": 1662128002,
"tls": 1
}
]
Ugh - the custom_args in personalizations was at the wrong level. After moving the custom_args up to the same level as the dynamic_template_data, it worked fine and the values are included in the webhook events.
The example from the question was changed to:
{
"from": {
"email": "sender#example.com",
"name": "Example Sender"
},
"personalizations": [
{
"to": [
{
"email": "recipient1#example.com",
}
],
"custom_args": {
"userId": "63r20acm4xfv"
}
"dynamic_template_data": {
"subject": "New Article",
"description": "Read the lastest news on...",
"documentId": "624dxnpvhw8g",
"host": "https://localhost:8000",
"userId": "63r20acm4xfv"
}
}
],
"custom_args": {
"documentId": "624dxnpvhw8g"
}
}
I am able to send interactive message with "button" type and 3 buttons with image header.
But sending interactive message with "list" type and same image header fails with error:
{
"meta": {
"api_status": "stable",
"version": "2.39.4"
},
"errors": [
{
"code": 1008,
"title": "Required parameter is missing",
"details": "Failed building interactive message. Invalid Header."
}
]
}
Is it possible that "list" interactive messages doesn't support "image" header without stating it in documentation?
Successful "button" interactive payload (image URL changed):
{
"to": "972000000000",
"type": "interactive",
"interactive": {
"body": {
"text": "Select a branch for the takeaway by writing the name/number"
},
"action": {
"buttons": [
{
"reply": {
"id": "MQ==",
"title": "1"
},
"type": "reply"
},
{
"reply": {
"id": "Mg==",
"title": "2"
},
"type": "reply"
}
]
},
"type": "button",
"header": {
"image": {
"link": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png"
},
"type": "image"
}
}
}
Successful "button" interactive message result:
Failed "list" interactive payload (image URL changed):
{
"to": "972000000000",
"type": "interactive",
"interactive": {
"body": {
"text": "Select a branch for the takeaway by writing the name/number"
},
"action": {
"button": "Options",
"sections": [
{
"rows": [
{
"id": "MQ==",
"title": "1"
},
{
"id": "Mg==",
"title": "2"
},
{
"id": "Mw==",
"title": "3"
},
{
"id": "NA==",
"title": "4"
},
{
"id": "NQ==",
"title": "5"
},
{
"id": "Ng==",
"title": "6"
},
{
"id": "Nw==",
"title": "7"
},
{
"id": "OA==",
"title": "8"
},
{
"id": "OQ==",
"title": "9"
},
{
"id": "MTA=",
"title": "10"
}
]
}
]
},
"type": "list",
"header": {
"image": {
"link": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png"
},
"type": "image"
}
}
}
Well, it does state it in the docs. I'm just blind:
Kinda weird though "image" header not supported for "list".
I'm reading the Facebook Send API and events docs, and I'm surprised to see some examples define the message at the top level of the JSON object hierarchy (here for "text message")
{
"sender":{
"id":"<PSID>"
},
"recipient":{
"id":"<PAGE_ID>"
},
"timestamp":1458692752478,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"text":"hello, world!",
"quick_reply": {
"payload": "<DEVELOPER_DEFINED_PAYLOAD>"
}
}
}
While others examples have a different object structure:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
Here is seems like the object is the first example is instead contained in a messaging array. I can't find either what id corresponds to in this second example : there is no table detailing the fields on why the hierarchy is different here.
Finally, there is another example with a different structure:
{
"object": "page",
"entry": [
{
"id": "<PAGE_ID>",
"time": 1583173667623,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1583173666767,
"message": {
"mid": "m_toDnmD...",
"text": "This is where I want to go: https:\/\/youtu.be\/bbo_fZAjIhg",
"attachments": [
{
"type": "fallback",
"payload": {
"url": "<ATTACHMENT_URL >",
"title": "TAHITI - Heaven on Earth"
}
}
]
}
}
]
}
]
}
Are these differences documented elsewhere? Why do they exist in the first place? Why is messaging an array? Can it contain multiple messages at once?
{
"headers": {},
"endpoint": "mail/send",
"method": "POST",
"queryParams": {},
"baseUri": "",
"body": {
"from": {
"name": "Test",
"email": "test#noreply.com"
},
"subject": "Test Send Grid Mail Service",
"personalizations": [
{
"to": [
{
"email": "user#test.com"
}
],
"subject": "Test Send Grid Mail Service",
"custom_args": {
}
},
{
"to": [
{
"email": "user#test.com"
}
],
"subject": "Test Send Grid Mail Service",
"custom_args": {
}
}
],
"content": [
{
"type": "text/html",
"value": "Hi"
}
]
}
}
I'm using this request body to send multiple emails(in this case 2 emails) to the same user but the send grid is sending only one email. Is there a way to send multiple emails to the same user multiple times(in this case 2 emails) in a single send grid request?
My issue:
I have two responses, but my chat return only one specified "the speech", but i need that return the two, like do the console of api
example of response JSON from API:
{
"id": "XXXXXXXXXXX",
"timestamp": "2017-07-12T20:08:48.101Z",
"lang": "es",
"result": {
"source": "agent",
"resolvedQuery": "Hello how are you?",
"action": "",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "intent",
"parameters": {},
"lifespan": 1
}
],
"metadata": {
"intentId": "XXXXXXXXXXXXXXXXXXXXXXXX",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "welcome"
},
"fulfillment": {
"speech": "Hello!",
"messages": [
{
"type": 0,
"speech": "Hello!"
},
{
"type": 0,
"speech": "Bye!"
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": ""
}
I need show the black messages.