Run Flow

The Run Flow action enables you to execute an existing workflow from your current workflow. This helps you break down your complex workflow into a series of simple workflows and call them when a certain condition is met.

How it works

To call workflow from another workflow, add the Run Flow action on canvas and configure it as given below:

1-configure.png

Webhook URL: Select/specify the webhook URL of the workflow you want to run. Please make sure that the webhook URL is enabled for that workflow.

Webhook Authentication Type: Select the authentication type that was used to secure the webhook of the workflow you wish to run. By default, the value for this field is set to Select.

If you have selected Basic Auth as an authentication type, you will need to enter the following details,

Username: Enter the username for webhook you want to run.

Password: Enter the password for the specified username.

If you have selected Auth Token as an authentication type, you will need to enter the following details,

Auth Token: Enter the auth token for the webhook you want to run.

Parameters: Enter the parameters you wish to pass to the workflow in JSON format. E.g., {“header”:”value1”}.

Run in Sync: Specify if you wish to run workflow in sync. The value for this field should be set to True when you expect the workflow to return any data.

Delay: Enter the time interval (in seconds) by which you wish to delay the workflow execution. This value should be in the range of 1-900. E.g., if you wish to delay the workflow execution by 2 minutes, enter 120 as an input for this field. This field will be ignored if the value for Run in Sync field is set to True.

Once this is done, click Next, optionally test the action, and click Done

Example

Let's understand how to use Run Flow with the help of an example. Let's say you want 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 the specified Cisco Webex Teams space and if it is not published, it will call another workflow which will create a task in Asana for that notebook and will post the task details on the specified Cisco Webex Teams space.

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

Step 1: Set up webhook for sub-workflow

The Run Flow action requires the webhook of the sub-workflow in order to trigger it. So, before you configure the Run Flow action, its necessary to set up a webhook for the workflow you want to call. To do this, create a blank workflow, double-click the Start icon and set up a webhook (know more about setting up a webhook).

Once this is done, connect the Start icon (now having the webhook icon) to Stop icon, and click Save

We will configure the rest of the sub-workflow later.

Step 2: Create the main workflow

We will now create the main workflow which will fetch all notebooks from Evernote and check whether each notebook is published or not. If a notebook is published, the workflow will post its details on a specific Cisco Webex Teams space and if a notebook is not published, it will call another workflow. 

To do this, add and configure the Evernote - Get List of Notebook, Loop, Cisco Webex Teams - Post New Message, and Run Flow actions as given below:

2-main-workflow.png

Workflow Configuration

1. Evernote - Get List of Notebooks: Select the Evernote authorization you want to use or create a new one.

2. Loop: Set the Loop Type to Each Item and add the notebooks key given under the Get List of Notebooks action output on the right-side of the configuration window, as an input for the Source Array/Object field.

3. Condition 1 for Loop and Post New Message actions: If the notebook is published, execute the Post New Message action.

        Input: Add the published key listed under the currentitem key of the Loop output. For example: {{$a1.currentItem.published}}

        Condition: (Text) Matches

        Expected: True

4. Condition 2 for Loop and Run Flow actions: If the notebook is not published, execute the Run Flow action.

        Input: Add the published key listed under the currentitem key of the Loop output. For example: {{$a1.currentItem.published}}

         Condition: (Text) Does Not Match

         Expected: True

5. Cisco Webex Teams - Post New Message: Select/create a Cisco Webex Teams authorization, specify the space where you want to post the message, and add the currentItem key listed under the Loop action given on the right hand side of the configuration window as an input for the Message field.

6. Run Flow: Set up the Run Flow action for the workflow you want to call.

           Webhook URL: Select the webhook URL associated with the workflow you want to call (only webhook enabled workflows will be displayed in the drop down list).

           Webhook Authentication Type: Specify the authentication type you have set for the webhook of the workflow you want to call. For example, if you have used Auth Token to secure the webhook of your sub-workflow, select the Auth Token method.

           Parameters: Specify the parameter you want to pass to the sub-workflow in JSON ('key':'value'} format. In our example, we want to pass the name of the unpublished notebook to the sub-workflow. To do this, set the key as task_name, and value as currentitem.name. I.e., {"task_name": "{{$a1.currentItem.name}}"}.

Once this is done, click Next, optionally test the action, and click Done. This will take you back to canvas. 

After this, save the workflow.


Step 3: Configure the sub-workflow

The sub-workflow will fetch the notebook name sent through the Run Flow action to the webhook, use it to create a task in Asana, and then post the details of that task on the specified Cisco Webex Teams space.

To do this, open the sub-workflow for which you had set webhook earlier, and add and configure the Asana - Create Task and Cisco Webex Teams - Post New Message actions to it, as given below:

3-sub-workflow.png

Workflow Configuration

1. Asana - Create Task: Since you want to use the parameter passed by the Run Flow (in this case, the name of the notebook) to create a new task, add the body key listed under the webhook output along with the key name of the passed parameter. For example, {{$request.body.task_name}} where task_name is the keyname passed as a parameter.

2. Cisco Webex Teams - Post New Message: Select/create a Cisco Webex Teams authorization, specify the space in which you want to post the message, and add the data key listed under the Asana - Create Task output in the Message field.

Once this is done, click Next, optionally test the action, and click Done. This will take you back to canvas.

After this, save the workflow.

Step 4: Execute the main workflow

Whenever you execute the main workflow, following sequence of actions will take place:

1. It will fetch all notebooks from your Evernote account and check whether each notebook is published or not. 

2. If a notebook is published, it will post the details of that notebook on the specified Cisco Webex Teams space. 

3. If a notebook is not published it will call the sub-workflow and pass the name of the unpublished notebook as a parameter to the webhook of the sub-workflow.

4. The sub-workflow will then fetch the name of the unpublished notebook from the webhook and use it to create a task in Asana.

5. Finally, the sub-workflow will post the details of the created Asana task on the specified Cisco Webex Teams space.