Overview
An order confirmation message is a transactional message that is sent via an API call after purchase is made.
The API method for an order confirmation message is the "automation templates" method.
Order data sent via the automation templates API method is set in the external variables object. These variables are unique to that send and not stored in Cordial. The data, however, is able to be printed in the message with Smarty (purchaser, product name, shipping address, etc.).
Note: Data that is set in the "contact" object (email, name, etc) is stored in Cordial as contact attributes after a send.
Learn more about the automationtemplates API method.
Creating the Automated Message
Before an API call is made, the automated message must be created first, with the API sending method enabled.
In the navigation menu choose Message Automation > Create New Automation. Provide the necessary information and click Continue.
Fill out the message headers and click Save.
Enter the HTML for the message content.
For this type of transactional message, we will be printing the order data with Smarty that will be referencing external variables passed in the API call.
A simple message HTML example may look like this:
<h2>Thanks for your purchase!</h2> Order ID: {$extVars.orderID}<br> Date: {$extVars.purchaseDate|date_format} <br><br> {foreach $extVars.items as $item} productID: {$item.productID}<br> Name: {$item.name}<br> Price: ${$item.price}<br><br> {/foreach}
Learn more about using Smarty in message content.
After entering the message content and header information, publish the message.
In the left panel under Sending Method, click API and then enable the API sending method.

Now that the message is published and the API sending method enabled, it's time to make the API call to send the message.
Sending the Message Via API
In order for the message to send, we will need to use automationtemplates API method.
POST v2/automationtemplates/{key}/send (sends an automated message).
Note the key for the message when sending with API. You can get the message key in the platform on the API sending method page of the message.

Here is an example API call that would provide the order data for the automated message we just created.
{
"identifyBy": "email", "to":{ "contact":{ "email":"fredgarvin@example.com" }, "extVars":{ "OrderID":"1234", "PurchaseDate":"2017-03-30 12:47:34", "orderTotal":"30.00", "Items":[ { "name":"shirt", "price":"10.00", "productID":"123" }, { "name":"pants", "price":"20.00", "productID":"456" } ] } } }
Notice how the field values (name, price, productID) correspond to the smarty variables.
Learn more about using the identifyBy parameter.
If there are no errors, the final message will look like this:
Thanks for your purchase!
Order ID: 1234Date: Mar 30, 2017
productID: 123
Name: shirt
Price: $10.00
productID: 456
Name: pants
Price: $20.00
In the next article learn how to set up a browse abandon message.
Comments
0 comments
Please sign in to leave a comment.