/
Running an Automation

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.

  1. Fetch request object from a trigger. Triggers can be of 2 types:

    1. Webhook:

      1. Generate a unique reference code for automation using automationId and timestamp.

      2. Register a unique URL for every automation. URL: ……./automation/{automationId}/{refCode}

      3. On every webhook hit:

        1. Validate automationId, state of automation and refCode.

          1. If valid, prepare standard automation object using request object, automationId and push the object to a common pipeline of Orchestrator.

          2. If invalid, log the error and return.

             

    2. Polling:

      1. Fetch all the polling-based automations that are ON.

      2. Push all such automations in a task queue with trigger data.

      3. Call each respective polling API one by one

        1. Prepare standard automation object using request object and automationId

        2. Push the automation to a common pipeline of Orchestrator.

           

  2. Orchestrator coordinates the following services:

    1. Get triggerId associated to the automation :

      1. Get the definition of trigger node through handlebar through building block(custom fields) API.

      2. Validate standard automation object with the definition of the trigger node.

      3. If invalid, log standard automation object and return.

      4. If valid, prepare an automation bundle with standard automation object for the orchestrator.

    2. Get automation data:

      1. Get a list of nodes associated with the automation.

    3. Loop over each node:

      1. Based on the type of node, call the respective execution method and pass automation bundle with nodeId.

        1. Get definition of the node using handlebar through building block(custom fields) API.

        2. 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.

        3. If valid, perform operations respectively and return the output object to the orchestrator.

        4. If the execution method is an action execution method, call the Action API and return the output object to the orchestrator.

      2. Add the output object to the automation bundle.

      3. Repeat from step i, if it is not the last node.

      4. 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

 

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

 

Related content