Stubmation
Run Stub Action from JSON
Runs an action on a stub for each Object in a JSON Array.
This stubmation workflow enables the user to run a stub action for each Object in a JSON Array of objects.
This uses the same stubmation as Run Stub Action per row from Sheet with some small differences.
A scenario for this could be:
- You have a list of customers, their names and cell numbers are in a JSON array.
- Each customer's data is in its own object with-in the JSON array.
- You could have used the Read From Sheet task to read this info from a Google Sheet.
- You would like to create a stub for each customer that will send them a WhatsApp and start a conversation
This stubmation will enable you to upload the CSV file and do that.
What Happens behind the scenes
The stubmation will use the data passed to it via the json_data
array, cycle through the array and run the stub action via webhook, as defined in trigger_stubaction
, with the object's data injected into object defined in inject_data_object
.
In our example below, the action create_stub_via_webhook
action will be run on stubref ~~stub.stubref
. The create_stub_via_webhook
action has been defined in the template to use the incoming data and run the Create Stub
task to create the new stub.
It will then pause for the duration as defined in delay_per_row_seconds
, before it moves to the next line's data to run the stub action.
When all lines are processed, it will automatically stop.
Run Stub Action per row from JSON
Flow Data Explained
required array
json_data The JSON data the will be passed to stubmation for processing. This can be explicitly added in or you can use
Value replacement substitution to use data from a variable in stub.data
or stubpost.tasks.task_name.payload.result
. Ensure the data returned is a JSON Array of Objects.
optional string
delay_per_row_seconds Default: 5
This is the time in seconds the workflow will pause between triggering the stub action for each row of data.
required json object
trigger_stubaction Contains all the details of the action that needs to be triggered. These action are triggered via webhook, so the action needs to be Webhook enabled. If the action's webhook has authentication enabled, the authentication should be correct for the action being called.
required string
trigger_stubaction.stubref The stubref for the stub the action needs to run on.
required string
trigger_stubaction.action_name The name of the webhook enabled action that the stubmation workflow needs trigger.
optional string
trigger_stubaction.inject_data_object Default: row_data
The name of the json object the row data will be injected into at stubpost.data.payload
. eg.
optional json object
trigger_stubaction.authorization Contains Webhook authorization data, should the action's webhook the stubmation workflow is to call, require authorization
optional string
trigger_stubaction.authorization.type The type of authorization the actions's webhook is configured for.
optional json object
trigger_stubaction.authorization.keys Contains the keys used to authorize the webhook call
optional string
trigger_stubaction.authorization.keys.token The token used in Bearer type authorization
Duplicate Detection
This will allow you to specify json data key names who's values will be hashed and stored.
When the process runs, it check if the hash exists in the hash store.
- If the hash does exist, it simply does not run the action on the stub and discards the job.
- If the hash does not exist, it creates and stores the hash and then runs the action.
Flow Data Explained
Showing the additional parameters required for duplicate detection.
required json object
trigger_stubaction.duplicate_detection Contains the keys used for duplicate detection
required boolean
trigger_stubaction.duplicate_detection.enable Instructs the workflow to store duplicate detection data and to detect for duplicates.
required JSON Array
trigger_stubaction.duplicate_detection.columns_to_hash This is an array of the json data key names, who's combined contents, will be hashed and stored for duplicate detection.
The duplicate detection is only stored for 4 days. It is then automatically removed.
These names should be as they appear in the json object(s) in the json_data
array being passed.