Orders automation

You can transmit orders data to eSputnik in order to:

  • Use the RFM-analysis of your contact database.
  • Send messages related to orders to the clients and perform other actions with contacts.

Create automatic trigger messages associated with the orders (ed, order confirmation and delivering, feedback engaging message about the purchase, etc.) consists of the following stages:

Setting up order transmitting by API

To transfer orders information, it’s necessary to configure a call to the special API /v1/orders method. Due to request, one or several orders (up to 1000) are transmitted. Each order should contain some required fields. Other fields are optional. Send the fields that you might want to use in the letters. Of course, in order to substitute the goods in the letters, it is necessary to transfer orders along with an array of the data on these goods. The request form and fields description are available here.

Example of request:

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

Required fields are shown in bold. An array of items can be omitted if you do not need the information about the items in the letters, or you transmit orders for RFM analysis only.

A successful response to the request will result in a status of 200.

For orders, you can use several statuses. For example, the newly established order, use the INITIALIZED status. For order in the delivery process - IN_PROGRESS. For the paid and delivered order - DELIVERED. For canceled orders - CANCELLED.

Important!

To create an RFM table, only orders in the DELIVERED status are used.

There is also a status for abandoned carts ABANDONED_SHOPPING_CART. Use this status if you are working on the definition of abandoned carts. If you use the Softcube service, then you do not need to configure the API for the abandoned carts.

To update the status or other order data, transmit the updated order with the same externalOrderId. By this parameter, the system determines the uniqueness of orders.

To check whether the order has entered the system and the fields are correctly transmitted, it is possible in the personal account in the Triggers - Orders section. (To check the correctness of data transmitted and substituted, you can operate the Triggers-Orders section in your personal account.) Clicking on the order ID you will see all the fields in JSON format.

Creating emails with dynamic content

To create a message, go to Messages → Messages and click on Create new email.

Creating emails with dynamic content

The system prompts you to select the structure of the letter. For automatic letters, the Trigger letter template suits best. It has a minimal set of blocks, so you do not have to eliminate a lot of unnecessary.

Trigger letter template

Let's say we want to send an order notification in this form:


Hello, Sergey Ivanov! Thank you for your order!
The carrier will ship your order to the address: Dnepr
Payment amount: 15 000 UAH

Order list:

Samsung tablet
5000 UAH

Lenovo Tablet
4000 UAH

Acer Tablet
6000 UAH

The order data 69022 has been sent to you by email@email.com and to the phone 097 111-11-11.

Letter example

This is how a ready-made letter will look like, where the text substituted with the variables. For example, instead of Sergey Ivanov, you substitute the name of the variables that contain the lastname (lastName) and the name (firstName) in the order data.


Important! If you want to report product information in a letter, use the following design:

#foreach($item in $!data.get('items'))  is the beginning of the block
#end - end of block

In the middle of this block, variables that contain data about the goods should be prescripted.

In our example, this is $!item.get('name') (product name) and $!item.get('cost') (product cost).

To make creation and testing process handier, here is a special function that allows you to substitute dynamic data and see the result immediately, without sending.

To get the function on, press three dotted button and go to Create dynamic content. It is available in the editor by clicking on the button with three dots, click Create dynamic content.

Create dynamic content

In the opened window click Set parameters.

 Set parameters

The next to open window, insert JSON-data for the order in the text field.

JSON-data for the order

There is no need to type manually, you can take the data from any order sent to the system. To do this, go to Triggers Orders.

Go to Triggers → Orders

In the order table, click on the ID of any order.

 Order table

You will see a window with the order data. Use this data in the window in the message editor.

Window with the order data

After inserting the order data in the editor, you will see what your email with the substituted data will look like.

Email with the substituted data

If nothing is displayed, then an error in the dynamic content code occurred.

To display the product cards in the email, there are ready-made commodity blocks in the editor. You can use one product blocks spreading the email width. For example, you want to make such a letter:

Cards of items in the email

To do this, staying in selection mode for block insert, click on the Product Cards tabs and select the necessary template. In the example, we use the Micro-block with the items and the price.

Product Cards

As a result, the email is formed as following:

Product Cards in the email

It’s important to make sure that the block is copied the number of times responding the number of items in the order along with correctness of picture, name, and price of the items inserted in each copy.

To begin with, set the cycle (block copying).

You can preview HTML layout by clicking View HTML on dashboard.

Preview HTML layout

In the pop-up window, at the very top of the beginning of the cycle insert the code #foreach($!item in $!data.get('items'), and end of the cycle code #end at the very bottom.

Insert the code

Next, substitute the name of the product and the price, with t the variables. In this example,$!item.get('name') (product name) and  $!item.get('cost') (commodity price).

As a result, the email is formed as following:

The email is formed

Finally, it comes to substitution for the URL of the product page with the URL of the picture. To do this, select our block again and click View HTML.

URL of the picture

For references to the pages of the goods, write $!item.get('url'). For references to images write $!item.get('imageUrl').

Now you can test and validate an operation.

Save the changes done and proceed to create the scenario.

Important

For SMS messages use the same code. For example, the order number can be substituted in the message of such variable $!data.get('externalOrderId'), the sum of the order $!data.get('totalCost').

Creating workflow to trigger mailings

Every time you submit an order via API, there is created an event in the system that can run the workflow. Events are created in several types. each order status has its own type of event that, allows you to configure separate corresponding triggers. The names of the events consist of “order” world along with the status name. The following events are possible: orderINITIALIZED, orderIN_PROGRESS, odrerDELIVERED, orderCANCELLED and orderABANDONED_SHOPPING_CART. The created events are saved in the Event History:

Event in the system that can run the workflow

As event keys, the order identifiers are submitted (the parameter transmitted via "externalOrderId". Order events contain such parameters:

  • orderId - order id in the eSputnik database. The parameter to run the scenario.
  • contactId - contact id in eSputnik
  • EmailAddress - the email address of the buyer (if transferred in the order)
  • SMS - the phone number of the buyer (if transferred in the order).

Important!

Unless email or phone numbers are sent in the order, the system can not associate t the buyer with the contact. Thus the messages cannot be sent to him/her, and no events are created.

To create a workflow, select Triggers → Scripts → Add script:

To create a workflow

Specify the name of the scenario (Order delivered, Order in process, etc.).

The scenario scheme looks like this:

The scenario scheme

The script requires the following blocks:

  • Task block- Obtain an order. By this unit, the system will pull out all the data regarding the order and insert it into email.
  • The Email (or SMS) Block. Select the email (SMS) previously created for this scenario (order notification, leave a feedback, etc.).

Save the scenario.

Sure, you can compose more complex scenarios It can be a series of messages with complex logic instead of one. A feedback letter is usually configured in the order delivery scenario. The timer for sending is set for 1-2 weeks.

Trigger the scenario

After the scenario is created, it should be triggered. To do this, click Set the trigger event, and after that, click on the scenario start button.

Trigger the scenario

In the pop-up window, select the event that will launch the scenario.

Select the event

As a result, the active and processing scenario will look like this:

Processing workflow

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