Run Workflow

Understand how Run Workflow works and how it can be used to call one workflow from another.

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

How It Works

  1. To call a workflow from another workflow, add the Run Workflow action on canvas and configure it as given below:

If the workflow you are calling contains a tested Return Data on Sync Webhook action, you will also see the sync field in the form which you can set to true or false as per your requirements.

2. Once this is done, click Next, optionally Test the action, and click Done.

Example

Let’s understand how to use Run Workflow with the help of an example.

Let’s say you want to create a workflow where whenever a new contact is created in Zoho CRM, check whether contact type is ‘Customer’ or ‘Employee’ and accordingly post the contact details on the relevant Slack channel.

This scenario can be covered using 2 workflows:

  1. Main workflow

    Whenever a Zoho CRM contact is created, it will check whether the contact type is Customer or Employee. If the contact type is ‘Customer’, it will post the customer details on a specific Slack channel and if the contact type is ‘Employee’, it will call the sub-workflow. Once it receives the Trello membership details from the sub-workflow, it will post its details on a specific Slack channel.

  2. Sub-workflow

    Sub-workflow will use Employee’s Zoho contact details to add them as a member to a specific Trello board and then send Trello membership details back to the main workflow.

Let’s look at the steps that are required to create and configure these workflows.

  1. Set up webhook for sub-workflow

    The Run Workflow action requires the webhook of the sub-workflow in order to trigger it. So, before you configure the Run Workflow 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 Webhook).

    Once this is done, click Next. In the next screen, you can toggle-on the Autoconnect switch to automatically connect the Return Data on Sync Webhook action to the end of the workflow. This action helps you send the response of the workflow back to the webhook (know more about how Return Data on Sync Webhook.

    Since we want to send the details of employee’s Trello membership to the main workflow, toggle-on the Autoconnect switch, click Next, and then click Done.

    This will take you back to canvas. At this point, you can see that the Return Data on Sync Webhook action is automatically connected just before the Stop icon in the workflow.

    Connect the Start icon (now having the webhook icon) to Return Data on Sync Webhook action, test the action, and Save the workflow.

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

  2. Create the main workflow

    We will now create the main workflow where whenever a new Zoho CRM contact is created, the workflow will check whether the contact type is ‘Customer’ or ‘Employee’. If the contact type is ‘Customer’, it will post customer’s Zoho contact details on a specific Slack channel and if the contact type is ‘Employee’, it will call the sub-workflow. When the sub-workflow adds the employee as a member to Trello board and sends the membership details back to the main workflow, the main workflow will post employee’s Zoho contact details and Trello membership details on a specific Slack channel.

    To do this, add and configure the Zoho CRM - New Contact trigger, and Slack - Post Message to Channel, Run Workflow, and Slack - Post Message to Channel actions as given below:

    Workflow Configuration

    • Zoho CRM - New Contact: Select the New Contact trigger and the Zoho CRM account you want to use to set up the trigger. You can alternatively create a new Zoho CRM account.

    • Slack - Post New Message: Select the relevant Slack account and channel on which you want to post the customer’s Zoho contact details. In the Text field, add the ‘Full_Name’, ‘Email’, and ‘Owner.name’ keys.

    • Condition 1 for Zoho CRM - New Contact triggerand Post New Message action: If the contact description is ‘Customer’, execute the Slack - Post New Message action.

      Input: Add the description key listed under list of trigger output in the left-side panel. For example: {{$trigger.Description}}

      Condition: (Text) Exactly Matches

      Expected: Customer

    • Run Workflow: Set up the Run Workflow action for the workflow you want to call.

      Webhook URL: Select the webhook URL for the sub-workflow you want to call. Doing so, will automatically render the input fields associated with the payload data for the selected webhook.

      Note: If the ‘sync’ field is not visible in your Run Workflow action configuration form, then verify that you have tested the ‘Return Data on Sync Webhook’ action in the first step as per the instructions.

      Add the Email key and Full_Name key in the Name and Email ID fields respectively.

      Sync: Since we want to execute this workflow in sync, i.e., fetch the response of the sub-flow and use it in this workflow, set the value of this field to ‘true’.

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

    • Condition 2 for Zoho Contacts - New Contact trigger and Run Workflow action: If the contact description is ‘Employee’, execute the Slack - Post New Message action.

      Input: Add the description key listed under list of trigger output in the left-side panel. For example: {{$trigger.Description}}

      Condition: (Text) Exactly Matches

      Expected: Employee

    • Slack - Post New Message: Select the relevant Slack account and channel on which you want to post the employee’s Zoho contact details and Trello membership details.

      Since we want to use the output of the sub-flow to post the employee contact details on Slack channel, add the response key listed under the ‘Run Workflow’ action output in the Text 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.

  3. Configure the sub-workflow

    The sub-workflow will use employee’s Zoho Contact details to add them to a Trello board and then send the details of the Trello board back to the main workflow.

    To do this, open the sub-workflow for which you had set webhook earlier, add the Trello - Add Member to Board action between webhook trigger and Return Data on Sync Webhook action.

    Configure the workflow as given below:

    Workflow Configuration

    • Trello - Add Member to Board: Since you want to use the parameters passed by the Run Workflow, i.e., the email ID and employee name to add the employee as a Trello board member, add the Nameand Email ID keys listed under the Webhook output in the Full Nameand Email ID fields respectively.

    • Return Data on Sync Webhook: In the Response Data field, Send the Employee details you want to send back to the main workflow.

      In our example, we will send employee name, employee email ID, and employee’s Trello membership ID to the main workflow. To do so, add the idMember, fullName, member_email_id keys in theResponse Data field.

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

    After this, Save the workflow.

  4. Execute the main workflow

    With this, both workflows are configured successfully. Now, whenever a new contact is created in your Zoho CRM account, the following sequence of actions will take place:

    1. The main workflow will compare whether the newly created Zoho CRM contact type is ‘Customer’ or ‘Employee’.
    2. If the contact type is ‘Customer’, the main workflow will post the details of customer’s Zoho contact on a specified Slack channel.
    3. If the contact type is ‘Employee’, the main workflow will call the sub-workflow and pass the name and email ID of the employee to the webhook of the sub-workflow.
    4. The sub-workflow will then fetch the name and email ID of the employee from the webhook and use it to add the employee as a member in a specific Trello board. Once the employee is added as a member in the Trello board, the sub-workflow will send the employee’s name, email ID, and Trello membership details back to the main workflow.
    5. Finally, the main workflow will fetch the response (employee details) sent by the sub-flow and post it on the specified Slack channel.