Order Automation

You can send order data to eSputnik to:

  • Do an RFM analysis of your contact base;
  • Send transactional order-related messages;
  • Segment your audience.

To send triggered order emails you need to:

  1. Set up order transfer through API;
  2. Create a message with dynamic content;
  3. Create a workflow.

1. Set up order transfer through API.

To transfer orders, you need to send a request using the /v1/orders API method. You can transfer up to 1000 orders in one request.

Every time you send an API order, the system creates an event that can trigger a workflow. You can create different events for different order statuses which allows to set triggers for each change in the order status.

Events have names that consist of two parts: the world order and its name, for example, orderINITIALIZED, orderIN_PROGRESS, orderDELIVERED, orderCANCELLED, orderABANDONED_SHOPPING_CART. To see the created events, go to Automation > Event history.

Event history

Each event contains required parameters and can contain optional parameters.

  • ${eventKey} - event unique key transferred in externalOrderId. Used as order identifiers;
  • ${orderId} - event ID in eSputnik. Required to assign the event to a workflow;
  • ${contactId} - contact ID in eSputnik;
  • ${EmailAddress} - contact email address provided it’s transferred in the event;
  • ${SMS} - contact phone number provided it’s transferred in the event.

Important!

If no email or phone is transferred in the event, the system can’t match the contact with the order and can’t send messages to such contacts.

To substitute parameter values in messages, fields with event parameters need to be sent in the form of an array.

Required parameters for the order array: externalOrderId, externalCustomerId, totalCost, status, date, email or phone.

Required parameters for the items array: externalItemId, name, quantity, cost, url, imageUrl.

You don't need to transfer the items array if you don't use product data in emails or send orders only to use in RFM analysis.

See the full list of order fields with descriptions.

Request body example:

{

"orders": [{

"externalOrderId": "100500",

"externalCustomerId": "12345",

"totalCost": 1000,

"status": "INITIALIZED",

"date": "2017-03-08T09:30:00+02:00",

"email": "mail@example.com",

"phone": "380942583691",

"firstName": "John",

"lastName": "Smith",

"currency": "USD",

"shipping": 10,

"discount": 0,

"deliveryMethod": "express",

"paymentMethod": "cash",

"deliveryAddress": "First str. 1",

"items": [{

"externalItemId": "200600",

"name": "Super Device",

"category": "devices",

"quantity": 1,

"cost": 990,

"url": "http://example.com/item/200600",

"imageUrl": "http://example.com/item/200600/image.png",

"description": "High quality"

}]

}]

}

If the request is successful, the server will return the 200 status code.

Important!

Only orders with the DELIVERED status are used to build the RFM table.

Only orders with the DELIVERED status can be used to calculate revenue from campaigns (add-on).

Orders with the DELIVERED status can be used to build segments with the following conditions: average check, order count, last order date.

Example of the segment

There is an ABANDONED_SHOPPING_CART status that can be used for abandoned carts. Use it if you track abandoned carts at an external platform. If you use wen tracking, you don’t need to send abandoned cart events through API.

To update the status or other order data, send an updated order with the same externalOrderId parameter. It’s used to determine the uniqueness of orders in the system.

To check whether the order is sent to the system with all the parameters, go to Automation > Orders. Click the order ID to see all the fields in JSON format.

Important!

For each unique contact, transfer a unique externalCustomerId parameter with the phone number that will be the same in the order and in the contact card.

  • If you’ve already sent the order with this externalCustomerId value, the system will automatically assign a new order to the same contact.
  • If the externalCustomerId value is new, the system will match it by phone number and email.

2. Create a message with dynamic content.

As an example, we’ll use an order confirmation email and add to it dynamic order details. You can create any other email using the same principles.

1. Go to Messages > Messages and open the necessary email or create a new one.

2. Use Velocity to add dynamic variables to where personal contact data should be substituted. The number of variables and their names will depend on your copy.

Dynamic variables in email

3. To mark the beginning and end of a block of code with dynamic content, click the structure with variables. Open Code editor and add #foreach($item in $!data.get('items')) and #end at the beginning and end of the block, correspondingly.

Structure with variables

Note. You need to add these code snippets to each structure with dynamic variables.

4. To add a dynamic variable for an image, click the necessary image > URL and insert:

  • $!item.get(‘imageUrl’) in Image path;
  • $!item.get(‘url’) in Link (Other);
  • $!item.get(‘name’) in Alternative text.

Adding a variable for the image

To preview the email with substituted data, click Additional settings > Configuring dynamic content.

Configuring dynamic content

Enter order parameters in the JSON format.

Order parameters

You can take order parameters from any corresponding order event. Go to Automation > Orders, click any event and copy the parameters.

Orders

Click View message. If there are errors in the code, you will see the corresponding error description. Dynamic content won’t be displayed if there are errors in the code.

Message error

If everything is right, variables will be substituted in the template and you will see the email as the contact will receive it.

Email with substituted content

The same Velocity code can be used to substitute data in other messages.

3. Create a workflow.

1. Go to Automation > Workflows and click New workflow.

2. Enter title and optionally description and tags.

3. Build a workflow of the following blocks:

  • Start;
  • Task. In Task name, select Get order.
  • Email (or SMS). In Message, select the created message with dynamic content.
  • End.

Example of workflow

4. Click Save.

You can create a more complex workflow that would include a series of messages and extra conditions like timer, checking, etc.

To launch the workflow, go to the workflow list in Workflows and click Trigger configuration of the necessary workflow.

Workflow list

In On event > Event type, select the event that will trigger the workflow and set unique events processing. Click Apply.

Trigger confirmation

Click Start and confirm it. The workflow status will change to Active.

Any Questions?
We’re always happy to help!
Request a Callback
Fill in the form, and our specialists will call you back as soon as possible.
Request a Callback
Chat Support
We’re waiting for your questions!
Send a Chat Message
Email
Contact the eSputnik support team
Send an Email