When using Actions, you may need to perform functions or create branches in the pipeline based on the outcome of your action. In this article, we talk how to do this for Custom Actions and Standard Actions. We start off with Custom Actions and then talk about Standard Actions later in the article.
See our short video on using a Custom Action
Custom Action
Custom Actions return JSON response body and response status, both of which can be referenced for use with Decisions or other functions.
Prerequisites
Create a Decision for a Success Status from a Custom Action
A Decision function can be used to check for a successful response (200 status code) after running a Custom Action. Be sure to connect your Decision to the Custom Action prior to configuring the Decision. Once you connect the Decision to the Custom Action, you will find a "Previous Action" option that starts with "Status of Action..." followed by the name of the Custom Action node. Set the operator to Equals True (checked box) to identify a success status. Setting the condition to false would mean an error occurred with the Custom Action request.
In the screenshot above, the name of the action node is Get Last Typeform Submission. The condition for evaluating the status is Status of Action Get Last Typeform Submission. Setting the condition to Equals True (check box checked) sets the filter to allow a success status.
Reference the JSON Response Body after a Custom Action
The JSON response from running a Custom Action can be referenced by using a token with this format:
{{Action Result From <node-name>}}
This will give you the full response payload from the request performed by the Custom Action.
{{Action Result From <node-name>.jsonProperty}}
Use the dot notation to reference individual properties in the JSON response.
The JSON response from your Custom Action request can be used within the context of your pipeline. Make sure you have the structure of the JSON response in order to set the dot notation correctly. Running a test on your Custom Action can help you view the response for the API request.
Example
Let's say you are using a Custom Action with node name "Get Records" and the API request returns this JSON response body:
{
"total_items": 2,
"items":
[
{
"created_at": "2021-12-13T23:24:24Z",
"record_id": "n3gBoMggCFNn",
"type": "A",
},
{
"created_at": "2021-12-13T23:05:37Z",
"record_id": "x3NBozWgCNFP",
"type": "B",
}
]
}
If you would like to reference the value for total_items the token would be:
{{Action Result From Get Records.total_items}}
If you would like to reference the first record_id in the array of items, the token would be:
{{Action Result From Get Records.items[0].record_id}}
Standard Actions
There are some differences in how Standard Actions (Actions provided out of the box in Syncari) expose their output compared to Custom Actions.
Create External Record
Create External Record action exposes the following tokens. Note the token below starts with "Result From" instead of "Action Result From" with Custom Actions.
{{Result From <node-name>.isSuccess}} -This token can be used in Decision to check if Action was successful.
{{Result From <node-name>.id}} -This token returns the id of the record in external system.
{{Result From <node-name>.syncariId}} -This token returns the Syncari Id of the record that was created in the external system.
All these tokens are available only when "
Update External Record
{{Result From <node-name>.isSuccess}} - This token can be used in Decision to check if Action was successful.
{{Result From <node-name>.results}} - As this action can update multiple external records, this token returns a list. Each element of list contains following fields - isSuccess, id and syncariId corresponding to each updated record.
All other standard actions expose only one token - {{Action Result From <node-name>.status}}. This token can be used in Decision to check if Action was successful.