Running an Automation
Automation is an automated workflow that connects your app and Eshopbox services together. Each automation consists of a trigger, filter, formatter or actions. When you turn your automation on, it will run the action steps every time the trigger event occurs.
Before you start
You must have an automation that is turned ON.
How it works
Automation always starts with the execution of the trigger node.
Fetch request object from a trigger. Triggers can be of 2 types:
Webhook:
Generate a unique reference code for automation using automationId and timestamp.
Register a unique URL for every automation. URL: ……./automation/{automationId}/{refCode}
On every webhook hit:
Validate automationId, state of automation and refCode.
If valid, prepare standard automation object using request object, automationId and push the object to a common pipeline of Orchestrator.
If invalid, log the error and return.
Polling:
Fetch all the polling-based automations that are ON.
Push all such automations in a task queue with trigger data.
Call each respective polling API one by one
Prepare standard automation object using request object and automationId
Push the automation to a common pipeline of Orchestrator.
Orchestrator coordinates the following services:
Get triggerId associated to the automation :
Get the definition of trigger node through handlebar through building block(custom fields) API.
Validate standard automation object with the definition of the trigger node.
If invalid, log standard automation object and return.
If valid, prepare an automation bundle with standard automation object for the orchestrator.
Get automation data:
Get a list of nodes associated with the automation.
Loop over each node:
Based on the type of node, call the respective execution method and pass automation bundle with nodeId.
Get definition of the node using handlebar through building block(custom fields) API.
Prepare the input object for the node execution using automation bundle and validate the input object with the definition of the node. If invalid, log error and return.
If valid, perform operations respectively and return the output object to the orchestrator.
If the execution method is an action execution method, call the Action API and return the output object to the orchestrator.
Add the output object to the automation bundle.
Repeat from step i, if it is not the last node.
Log input and output object in MongoDb with automation id.
The standard input object of Orchestrator:
{
"automationId": "7865478",
"workspaceSlug": "montecarlo",
"output": {
"email": "yashna.chhatwal@eshopbox.com",
"closed_at": null,
"created_at": "2020-01-24T03:54:49-05:00",
"updated_at": "2020-01-24T03:57:30-05:00",
"number": 42,
"note": null,
"token": "c9f5809f3a256c5a979213e370dcc078",
"gateway": "bogus",
"financial_status": "paid",
"confirmed": true,
"total_discounts": "231.10",
"total_line_items_price": "2311.00",
"total_price_usd": "34.49",
"order_number": 1042,
"line_items": [
{
"id": 4361463103533,
"variant_id": 32127273697325,
"title": "Test_Product2",
"quantity": 1,
"sku": "5",
"total_discount": "0.00",
"fulfillment_status": null
},
{
"id": 4361463136301,
"variant_id": 31867472904237,
"title": "zap_Test",
"quantity": 1,
"sku": "zap_Test_BB-1",
"variant_title": "12",
"price": "111.00",
"total_discount": "0.00",
"fulfillment_status": null
}
]
},
"input": {
"status": "paid",
"order_status": "open",
"fulfillment_status": "any"
},
"createdAt": "2020-08-12 06:36:31",
"updatedAt": "2020-08-12 06:36:31"
}
Field Name | Business Purpose | Field type (with size) | Is it a required field? | Is it editable? | Is it Unique? | Specific validations for some field type
| REFERENCE OF OTHER BUILDING BLOCK
|
---|---|---|---|---|---|---|---|
automationId | Unique identifier for this automation | integer | Yes | No | Yes | No | No |
workspaceSlug | Unique identifier for the workspace | String | Yes | No | Yes | No | No |
output | The object received from the trigger of the APP through webhook or polling API | Object | Yes | No | No | No | No |
input | It contains the input designer fields configured against the trigger | Object | No | No | No | No | No |
createdAt | App creation date | string | Yes | No | No | yyyy-mm-dd h:m:s | No |
updatedAt | Last updated date | string | Yes | Yes | No | yyyy-mm-dd h:m:s | No |