Send multiple emails to same user in single SendGrid request - sendgrid

{
"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?

Related

How to send scheduled push notification using rest api in flutter

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"
}
}

Can SendGrid webhook events include custom_args from personalizations?

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"
}
}

How to send an email with variables using Mailjet API v3.1?

I just want to know why when I send variables using a template, the Mailjet API doesn't replace them, even the fakeFirstname doesn't show.
I just see {{var:FirstName:"fakeFirstName"}}
Here is my payload :
{
"Messages": [
{
"From": {
"Email": "senderEmail",
"Name": "senderName"
},
"To": [
{
"Email": "userEmail",
"Name": "userName"
}
],
"Subject": "subject",
"TextPart": "",
"HTMLPart": "",
"TemplateID": TemplateId,
"TemplateLanguage": true,
"Variables": {
"FirstName": "otherName"
}
}
]
}
Thanks for the helpers.

Send mail from Mailhog to Gmail but gmail can't receive mail

I'm try to use api in mailhog
Get /api/v1/messages
[
{
"ID": "ZOif6IQhqZgViFi2HO4e8KBSJBAzlwwJ-92rCBccNU8=#mailhog.example",
"From": {
"Relays": null,
"Mailbox": "developer-send-mail",
"Domain": "gmail.com",
"Params": ""
},
"To": [
{
"Relays": null,
"Mailbox": "developer-recv-mail",
"Domain": "gmail.com",
"Params": ""
}
],
"Content": {
"Headers": {
"Message-ID": [
"ZOif6IQhqZgViFi2HO4e8KBSJBAzlwwJ-92rCBccNU8=#mailhog.example"
],
"Received": [
"from smtp.gmail.com by mailhog.example (MailHog)\r\n id ZOif6IQhqZgViFi2HO4e8KBSJBAzlwwJ-92rCBccNU8=#mailhog.example; Mon, 22 Nov 2021 18:30:16 +0000"
],
"Return-Path": [
"<developer-send-mail#gmail.com>"
]
},
"Body": "test my message\r\nnew1\r\nmulti line",
"Size": 33,
"MIME": null
},
"Created": "2021-11-22T18:30:16.822037969Z",
"MIME": null,
"Raw": {
"From": "developer-send-mail#gmail.com",
"To": [
"developer-recv-mail#gmail.com"
],
"Data": "test my nessaje\r\nnew1\r\nmulti line",
"Helo": "smtp.gmail.com"
}
},
]
and I
Post /api/v1/messages/ZOif6IQhqZgViFi2HO4e8KBSJBAzlwwJ-92rCBccNU8=#mailhog.example/release
Body
{
"Host": "smtp.gmail.com",
"Port": "587",
"Username": "developer-send-mail#gmail.com",
"Password": "MyMailPassword",
"Mechanism": "PLAIN",
"Email": "developer-send-mail#gmail.com"
}
Response code: 200
but in gmail developer-recv-mail#gmail.com can't receive this email
In your post value for release endpoint, you specify an Email value of developer-send-mail#gmail.com. Since this value is the recipient, I believe this should be developer-recv-mail#gmail.com from the sound of it?
https://github.com/mailhog/MailHog/blob/master/docs/APIv1.md#post-apiv1messages-message_id-release

Action On Google, webhook response with actions.intent.NEW_SURFACE

Trying to implement NEW_SURFACE in webhook response (Google Assistant vocal calling Dialogflow calling a webhook).
When I have web browser capability I display my cards, but I when to redirect the user to his phone when he is from the Google Home.
This is my error in Action On google :
{
"responseMetadata": {
"status": {
"code": 10,
"message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
"details": [
{
"#type": "type.googleapis.com/google.protobuf.Value",
"value": "{\"id\":\"28ef98e1-caec-4e1f-9a14-8fda597e8a06\",\"timestamp\":\"2018-08-17T12:31:10.735Z\",\"lang\":\"fr-ca\",\"result\":{},\"alternateResult\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1534509012113\"}"
}
]
}
}
}
And this is my webhook response :
{
"fulfillmentMessages": [],
"payload": {
"google": {
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "TEST CHANGE SURFACE"
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.NEW_SURFACE",
"inputValueData": {
"#type": "type.googleapis.com/google.actions.v2.NewSurfaceValueSpec",
"context": "To show you an image",
"notificationTitle": "Check out this image",
"capabilities": [
"actions.capability.SCREEN_OUTPUT"
]
}
}
]
}
]
}
},
"source": "google"
}
Need help please ;-)