How can we help?

Custom Actions

Tal Bereznitskey
Tal Bereznitskey
  • Updated

Learn how to send custom HTTP requests and Webhooks to any 3rd party software.

Introduction

Custom actions are an advanced workflow feature that allow you to interact with any third-party software that has an API. Here are some examples of what can be achieved:

  • Integrating with Zapier / Workato / Make by sending a webhook
  • Sending a message to Microsoft Teams or Google Chat
  • Creating a Jira or ServiceNow ticket
  • Sending a highly customized message to Slack
  • Interacting with software built in-house
  • Sending a webhook from Torii

Prerequisites

  1. The third-party software has a public REST/GraphQL API.
  2. The third-party API provides the action you want via a standard HTTP request.

How to Use?

Start by creating a workflow in Torii from the Workflows page and add a trigger that will control when the workflow should run.

Step 1 — Add a custom action to a workflow

Now, add the "Custom action (HTTP Request)" by picking it from the list:

 

Step 2 — Add description (optional)

We recommend adding a short description that briefly describes what the custom action is supposed to do.

 

Step 3 — Choose HTTP method

Pick the method of the HTTP request:

 

Step 4 — Choose URL

Choose the URL to send the request to. In this example, we are using a Zapier webhook:

You can use @ to customize the URL field. It may require to press [space] before, use @ to open the placeholders selection, select a placeholder and then remove the [space].

 

Step 5 — Add Query Parameters (optional)

You can now add Query Parameters to the request by providing key and value pairs.

 

You can use @ to customize the value field.

 

Step 6 — Add headers (optional)

If your request requires additional headers, for authentication, for example, you can add them as key-value pairs:

You can use @ to customize the value field.

By default, the body is sent with Content-Type of "application/json". If you wish to use a different content type:

1. Adjust the Content-Type header with either application/x-www-form-urlencoded or multipart/form-data

2. Keep the "body" (step 7 below) as JSON and it will be sent based on the selected content type

 

Step 7 — Add body (optional)

You can add a body with a valid JSON payload. In this example, we are sending a JSON payload and using the @ to add customization:

For GraphQL, make sure to add spacing between the opening { and closing } curly braces inside your query. Without the spaces, you may get [invalid placeholder] message. Example of how to construct a GraphQL query:
{ "query": "{ allFilms { edges { node { id } } } }" }

 

For "application/x-www-form-urlencoded" or "multipart/form-data" requests, keep using JSON to define the form fields and they will be sent based on the selected content type.

 

Step 8 — Add response mapping (optional)

Using the response mapping you can chain custom action's output and use it as another action's input — map the HTTP response and use it as a placeholder in subsequent actions. Mapping is only relevant when the response is a valid JSON, it is not allowed to use the characters {}, as the mapping key.

 

Example

The mapping key (left-side) is the name that will be used to refer to this mapping. The mapping value (right-side) is where to read the value from. For this Response Body:

{
app: {
id: 1,
name: 'Torii',
users: ['Alice', 'Bob']
}
}
 
You can use the following mapping to get the application name, and the first user:
image-8.png
 
And use it in another action as a placeholder:
image (68).png

 

Testing the Custom Action

You can test the custom action by clicking the Run now button of the workflow.

You can also test your actions in Postman before building them in Torii.
 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request