Example of using the Run action

The Run action from the Task Bot package enables you to run and pass values to one or more child bots. In this example, you use the Run action to pass two values from a parent bot to the child bot; the child bot adds the values and passes the sum back to the parent bot.

This example demonstrates the following:
Modularization
Modularization separates a Task Bot into several bots, where each bot is built with all the actions necessary to perform one specific function of the greater task.
In this example, you build a single child bot to add the values. You can build several child bots, with each performing a different mathematical operation, and edit the parent bot to call whichever one you want to use.
Reusability
Reusability enables the user to build a bot once, and then use that bot to automate many processes.
The child bot contains only the actions necessary to add the values and print them to a Message Box. Also, the bot adds two variables instead of hard-coded values. As a result, this bot can be reused for any task that involves an addition operation.
Data control
Because the child bot accepts and returns values only through the use of variables, it does not hold data. This minimizes the chance of data leakage.

Procedure

To run a Task Bot from the current task, perform these steps:

Build the child bot.

  1. Open a new bot.
    1. On the left panel, click Automation.
      A list of available bots and forms is displayed.
    2. Click Create a bot.
    3. Enter the bot name AddChildBot.
    4. Enter the folder location Bots\TaskBotExample.
      To change where your bot is stored, click Choose and follow the prompts.
    5. Click Create and Edit.
  2. Create the following variables:
    • v1: number type; use as input
    • v2: number type; use as input
    • nSum: number type
    • sSum: string type; use as output
  3. Use a Number > Assign action to perform the mathematical operation.
    1. Double-click or drag the Number > Assign action.
    2. In the Select the source string variable/ value field, enter the following expression: $v1$ + $v2$
    3. Select nSum from the Select destination number variable list.
  4. Use the Number > To string action to convert the value so it can be printed to a Message Box.
    1. Double-click or drag the Number > To string action.
    2. In the Enter a number field, enter the following expression: $nSum$
    3. Select sSum from the Assign output to variable list.
  5. Click Save.
  6. Click Close.

Build the parent bot.

  1. Open a new bot.
    1. On the left panel, click Automation
      A list of available bots and forms is displayed.
    2. Click Create a bot.
    3. Enter the bot name MathBot.
    4. Enter the folder location \Bots\TaskBotExample.
      To change where your bot is stored, click Choose and follow the prompts.
    5. Click Create and Edit.
  2. Create a Dictionary variable of Any subtype named dSums to accept the values passed from the child bot.
    Use the Any subtype to enable the parent bot to accept String, Number, or Boolean type values.
  3. Insert a Task Bot > Run action to specify the values for the mathematical operation and the output variable to hold the sum.
    1. Double-click or drag the Task Bot > Run action.
    2. Click Browse to navigate to Bots\TaskBotExample\AddChildBot.
    3. Enter the following values in the Input values fields:
      • v1: 12
      • v2: 54
    4. Select dSums from the Assign output to variable list.
      Note: Use a Dictionary variable to hold the output of the Run action in order to make the parent bot more versatile. This way a parent bot can handle different child bots regardless of whether they return a single value or several values.
  4. Use a Message Box to retrieve and print the sum.
    The variable sSum retrieved from the child bot is a key in the Dictionary variable dSums.
    Note: You must know the variable names from the child bot to extract them from the parent bot. The interface does not automatically import the variable names to the parent bot.
    1. Double-click or drag the Message box action.
    2. Enter $dSums{sSum}$ in the Message to display field.
  5. Click Save.
  6. Click Run.
    The bot runs and the Message Box appears containing the sum 66.