Defining X-SMTPAPI header - sendgrid

Question 1: Do I need to strictly follow the order while defining the X-SMTPAPI
header related order mentioned in the doc ?
The doc(http://sendgrid.com/docs/API_Reference/SMTP_API/) mentions it like this:
{
"to": [
"ben#sendgrid.com",
"joe#sendgrid.com"
],
"sub": {
"%name%": [
"Ben",
"Joe"
],
"%role%": [
"%sellerSection%",
"%buyerSection%"
]
},
"section": {
"%sellerSection%": "Seller information for: %name%",
"%buyerSection%": "Buyer information for: %name%"
},
"category": "Orders",
"unique_args": {
"orderNumber": "12345",
"eventID": "6789"
},
"filters": {
"footer": {
"settings": {
"enable": 1,
"text/plain": "Thank you for your business"
}
}
}
}
So, my email header in this case would look like the following in coldfusion:
<cfset myheaderdefinition = XMLFormat('X-SMTPAPI|{
"to": [
"ben#sendgrid.com",
"joe#sendgrid.com"
],
"sub": {
"%name%": [
"Ben",
"Joe"
],
"%role%": [
"%sellerSection%",
"%buyerSection%"
]
},
"section": {
"%sellerSection%": "Seller information for: %name%",
"%buyerSection%": "Buyer information for: %name%"
},
"category": "Orders",
"unique_args": {
"orderNumber": "12345",
"eventID": "6789"
},
"filters": {
"footer": {
"settings": {
"enable": 1,
"text/plain": "Thank you for your business"
}
}
}
}
') >
Question #2: Does the way I have defined my header looks good?
More clarifications on Question #1:
1.1 Do I need to use to,sub,role,section etc in the same order as mentioned? OR can I skip one of these if I am not using these?
1.2 How would I determine what sendgrid is expecting for unique_args and other fields?

1 - 1.1 You may use any number of SMTPAPI parameters in any order you wish, in the JSON object you provide SendGrid. You may omit those you are not using. The sample provided in the SendGrid docs is only that, not a requirement.
1.2 unique_args and the rest of the parameters are fields only meant for you. SendGrid is not expecting anything. As you provide parameters SendGrid will execute on them as explained in SMTPAPI Documentation.
2 Your setup does not look right, although I am not intimately familiar with ColdFusion, it does not look as though you are correctly defining an email header. I would point toward my previous answer to your previous question as to how to set that up.
However, based on this and previous questions, I must ask, are you sure you want to use SendGrid's SMTPAPI or just use SMTP to send email to SendGrid?
The SMTPAPI provides much additional functionality to email, based upon parameters provided to it through a JSON object. However, sending through SMTP simply transports your message to SendGrid using the protocol of SMTP.
EDIT: To further check your SMTPAPI Header, you may want to use the SMTPAPI Header Validator

Related

Recipient detail in SendGrid Dynamic Template

I need to send a payload to multiple recipients in SendGrid. I use the Dynamic Templates to construct the email body, and all is working fine.
I would like to add a 'Hi {{recipientName}}' line to the email but I cannot find any documentation on it, is it possible?
I cannot include the recipient detail in the payload as a single payload goes out to many recipients
Use personalizations.
Personalizations allow you to override these various metadata for each email in an API request.
Your request will look like this:
{
"from": "gilbert#techmail.com",
"template_id": "YOUR TEMPLATE ID",
"personalizations": [
{
"to": [
{
"email": "john#example.com"
}
],
"substitutions": {
"%fname%": "John",
"%CustomerID%": "C001"
},
},
{
"to": [
{
"email": "peter#example.com"
}
],
"substitutions": {
"%fname%": "Peter",
"%CustomerID%": "C005"
},
"send_at": 1629723541
}
]
}
and it will go as a single request.
Also look at this github comment.

How to use roomHint and structureHint with smarthome actions on Google

We are currently setting un a Smarthome action, and we would like to provide roomHint on the first sync (not on request sync) as it's really tedious to set up rooms on the first sync, but it does not work.
We tried to name rooms in english and also in italian, (as it's not really clear from the documentation if there is a list on room names that we can use?) but no way.
So can you please give us a hint how to use the roomHint field?
Also in the API doc we've found structureHint, does it work? The documentation for SYNC intent does not mention this field.
Here is our SYNC intent with one device and room, we took office from the example JSON:
{
"requestId": "3582198904737125163",
"payload": {
"agentUserId": "xyz#qwertyz.com",
"devices": [
{
"id": "deviceID",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.OnOff"
],
"name": {
"name": "Lampadina",
"defaultNames": [
"Lampadina_XYZ"
],
"nicknames": [
"Lampadina"
]
},
"willReportState": false,
"customData": {
"modelType": "DEVICE"
},
"roomHint": "office"
}
]
}
}
Thanks
Unfortunately, I believe the structureHint is only in the HomeGraph API sync response.
It cannot be used in the Sync intent.
If someone can tell me I'm wrong and how to use it, you'd be a hero.

Facebook Workplace Account Management API - Update user

I have a workplace application,
I wish to change emailIds of the user via API,
I found that Account Management API
can be used to modify user details via API calls.
My use-case is to modify user email via the Account Management API, which comes under urn:scim:schemas:core:1.0 schema extension,
I wish to overwrite the existing email with the one I would specify in the requestBody,
From the documentation, I've come up with the following request -
Url endpoint -
https://someCompanyName.facebook.com/scim/v1/Users/ HTTP/1.1
Method type -
POST
Request body-
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:facebook:auth_method:1.0"
],
"userName": "abc",
"name": {
"formatted": "Julius Caesar"
},
"emails": ["abc#gmail.com"],
"urn:scim:schemas:extension:facebook:auth_method:1.0": {
"auth_method": "password"
}
}
Is it correct? What modifications do I need to make to the request?
in order to change the emails of a user you have to do a PUT request to the address https://www.facebook.com/scim/v1/Users/{userId}
and you have to change in your payload the email address:
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:facebook:auth_method:1.0"
],
"userName": "abc",
"name": {
"formatted": "Julius Caesar"
},
"emails": [
{
"primary": true,
"type": "work",
"value": "newemail#gmail.com"
}
],
"urn:scim:schemas:extension:facebook:auth_method:1.0": {
"auth_method": "password"
}
}
Hope it helps

How can I add a large JSON object to a header in Postman?

The SendGrid API needs some large JSON in the X-SMTPAPI custom header field.
How can I enter & edit this in Postman?
E.g.:
{
"to": [
"ben#sendgrid.com",
"joe#sendgrid.com"
],
"sub": {
"%name%": [
"Ben",
"Joe"
],
"%role%": [
"%sellerSection%",
"%buyerSection%"
]
},
"section": {
"%sellerSection%": "Seller information for: %name%",
"%buyerSection%": "Buyer information for: %name%"
},
"category": [
"Orders"
]
}
it should be easy to do.
Just modify your postman header request as illustrated in the screenshot below.

Mandrill sending to multiple people as separate message via the REST API

I'm trying to send out mails using mandrill. The problem is that when I add multiple recipients to the 'to' parameter, it sends out the same mail multiple times with ALL the recepients in the 'to' list. I was expecting the same mail to be sent out individually to every person in the to list. Am I missing something ?
{
"key": "app-key",
"template_name": "platform-invite",
"template_content": [
{
"name": "connection",
"content": "<a class=\"mcnButton \" title=\"Lets Go\" href=\"http://someurl\" target=\"_blank\" style=\"font-weight: normal;letter-spacing: normal;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;\">Lets go</a>"
},
{
"name": "mailbody",
"content": "<p>Hi </p>\n<p>I would like you to be a ... Tic tic tic...</p>"
}
],
"message": {
"subject": "My subject line over herer",
"from_email": "superman#mydomain.co",
"to": [
{
"email": "person1#gmail.com,
"type": "to"
},
{
"email": "person2#gmail.com",
"type": "to"
},
{
"email": "person3#gmail.com",
"type": "to"
},
{
"email": "person4#gmail.com",
"type": "to"
}
],
"merge_vars": {}
},
"async": false,
"ip_pool": "Main Pool"
}
There's an option in your Sending Options to expose recipients to one another. You can uncheck that box to not show everyone's information in the 'to' header. The option(s) you select in the Sending Options are used by default for your account. You can override any of these options in individual API calls. In this case, you could use the preserve_recipients parameter to override the current default that's set for your account.