How to call a workflow from another workflow using ‘Run Flow’ action

There may be times when you wish to extend the overall execution time of your workflow (by default it is set to three minutes) or you wish to create a workflow that acts as a trigger to run other workflows or you simply need to break down a complex workflow into a number of simple workflows. In such scenarios, you can use ‘Run Flow’ action that lets you call one workflow from another workflow. 

In this guide, we will understand the steps to call one workflow from another workflow with the help of an example. 

Let's say you wish to create a workflow that retrieves the details of all Evernote notebooks periodically and checks if all the notebooks are published or not. If the notebook is published, it will post the notebook details on a Slack channel and if it is not published, it will call another workflow which will raise a ticket in Zendesk for that notebook and will post the details of the ticket on a Slack channel. 

Let’s look at the steps that are required to create and configure this workflow.

Step 1: Add and configure actions for the workflow


Add 'Evernote - Get List of Notebooks', 'Loop', 'Slack - Post Message to Channel' and 'Run Flow' actions to the canvas and connect them as shown below:

1.png

Configure each action as given below:

Evernote - Get List of Notebooks: Select authorization for your Evernote account.

Loop: Set ‘Loop Type’ to ‘Each Item’ and add ‘notebooks’ key given on the right hand side of configuration window as an input for ‘Source Array/Object’ field. 

Condition1 for Loop and Slack action: If the notebook is published, execute 'Slack - Post Message to Channel' action. 

   Input: {{$a16.currentValue.published}}

   Condition: (Text) Matches

   Expected: true 

Condition2 for Loop and Run Flow action: If the notebook is not published, execute 'Run Flow' action. 

      Input: {{$a16.currentValue.published}}

     Condition: (Text) Does Not Match

      Expected: true 

Slack – Post Message to Channel: Select the Slack authorization and add the 'currentValue' key listed under the 'Loop' action given on the right hand side of the configuration window as an input for ‘Text’ field. 

Run Flow: This action lets you trigger another workflow available in your account. However, it is important to note that that the other workflow that you wish to run should have ‘Webhook’ as trigger.

Here’s how to configure this action: 

 - Webhook URL: Select/specify the webhook URL of the sub workflow that you wish to call from this workflow. 

 - Webhook Authentication Type: Select the authentication type (Basic Auth or Auth Token) that was used to secure the webhook of the workflow you wish to run, and add the relevant credentials in the subsequent fields. If you wish to provide the credentials at runtime (i.e. when the webhook URL is hit), select 'Select' option from the drop down list. 

   If you have selected 'Basic Auth' method, you will need to provide the following details:

      Username: Enter the username for the specified webhook URL. 

      Password: Enter the password for the specified webhook URL. 

   If you have selected 'Auth Token' method, you will need to provide the following details:

      Auth Token: Enter the auth token for the specified webhook URL. 

  - Parameters: If you wish to pass any data or parameters to the sub workflow you wish call, you can add those parameters here in the JSON format. 


run flow.png

Step 2: Save and run the workflow


Once you have entered all the details, click on 'Next', test the actions, and click on 'Done' to return to the canvas. Click 'Save' to save the workflow. 

Now, click the ‘Run’ icon available on the top right-hand side corner of the dashboard. The workflow will first fetch the details of all notebooks available in your Evernote account. If a notebook is published, its details will be published on the specified Slack channel, and if it is not published, the workflow will call another workflow which will in turn create a ticket in Zendesk for that unpublished notebook and will post the details of the ticket on the specified Slack channel.