Working with Action Responses

Mike Jones
Mike Jones
  • Updated

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 HTTP Actions and Standard Actions. We start off with Custom HTTP Actions and then talk about Standard Actions later in the article.

See our short video on using a Custom HTTP Action

Custom HTTP Action

Custom HTTP 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 HTTP Action

A Decision function can be used to check for a successful response (200 status code) after running a Custom HTTP Action. Be sure to connect your Decision to the Custom Action prior to configuring the Decision. Once you connect the Decision to the Custom HTTP Action, you will find a "Previous Action" option that starts with "Status of Action..." followed by the name of the Custom HTTP 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 HTTP Action request. 

decision-custom-action.png

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 HTTP Action

The JSON response from running a Custom HTTP 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 HTTP 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 HTTP 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 HTTP Action can help you view the response for the API request.

Example

Let's say you are using a Custom HTTP 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}}

Reference the Response Headers after a Custom HTTP Action

{{Headers From Action <node-name>}} 
This will provide you with the response headers from the request performed by the Custom HTTP Action. 

Reference the Response Status Code after a Custom HTTP Action

{{Status Code From Action <node-name>}} 
This will provide you with the response status code (200, 404 etc.) from the request performed by the Custom HTTP Action.

 

Standard Actions

There are some differences in how Standard Actions (Actions provided out of the box in Syncari) expose their output compared to Custom HTTP 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 HTTP 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 attributes - 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.

Share this

Was this article helpful?

3 out of 4 found this helpful