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 transfer by API
- creating emails with dynamic content
- creating scenarios to trigger mailings
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:
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.
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.
To create a message, go to Messages → Messages and click on Create new email.
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.
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
The order data 69022 has been sent to you by email@example.com and to the phone 097 111-11-11.
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.
In the opened window click Set parameters.
The next to open window, insert JSON-data for the order in the text field.
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.
In the order table, click on the ID of any order.
You will see a window with the order data. Use this data in the window in the message editor.
After inserting the order data in the editor, you will see what your email with the substituted data will look like.
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:
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.
As a result, the email is formed as following:
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.
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.
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:
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.
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.
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').
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:
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).
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:
Specify the name of the scenario (Order delivered, Order in process, etc.).
The scenario scheme looks like this:
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.
In the pop-up window, select the event that will launch the scenario.
As a result, the active and processing scenario will look like this: