Example of passing a value between bots

Learn how to pass a value from one Task Bot to another by using a dictionary variable.

Build a parent Task Bot and a child Task Bot that do the following:
  • The parent bot prompts the user to enter a song title and passes it to the child bot.
  • The child bot takes the input string and returns a new string to the parent bot.
  • The parent bot receives the string that the child bot passes as a dictionary.

Procedure

  1. Build a child bot.
    1. From the Control Room interface, go to the Automation tab.
    2. Click Create New > Bot.
    3. Enter the name for the bot as GetSongDetails.
    4. Click Create and Edit.
  2. Create a variable named sMySong.
    1. In the Variables panel, click the Create variable button.
    2. In Type, select String if it is not already selected.
    3. In Name, enter sMySong.
    4. Select the Use as input and Use as output check boxes.
    5. Click Create.
  3. To build a return string, use the String > Assign action.
    1. From the Actions panel, find the String > Assign action, and add it to the child bot flow.
    2. In Select the source string variable(s)/ value, enter I love $sMySong$ too!.
      During runtime, $sMySong$ in the output string will be replaced with the value that the parent bot passes to the child bot.
    3. In Select the destination string variable, select sMySong to store the new string.
    4. Click Save.
  4. Build the parent bot.
    1. On the left panel, click Automation.
      A list of available bots and forms is displayed.
    2. Click Create New > Bot.
    3. Enter the name for the bot as FavoriteSong-Parent
    4. Click Create and Edit.
  5. Create a variable named sMySong.
  6. Use the Prompt > For value action to capture a song title.
    1. From the Actions panel, find and add the Prompt > for value action to the parent bot flow.
    2. In the Prompt window caption field, enter Favorite Song.
    3. In the Prompt message field, enter Type the title of your favorite song.
    4. In the Assign the value to a variable field, enter sMySong.
    5. Click Save.
  7. Use the Task Bot > Run action to call the child bot:
    1. From the Actions panel, find and add the Task Bot > Run action to the parent bot flow.
    2. In Task Bot to run, select Control Room and then click Choose.
    3. Click Browse and navigate to the folder that contains the child bot and select GetSongDetails.
    4. In Input values, select Set sMySong and then enter $sMySong$ in the variable field.
    5. In Save the outcome to a variable (option), select Dictionary and then create a variable named dOutput.
    6. Click Save.
  8. Use the Message box action to display the string that the child bot returns.
    1. From the Actions panel, find and add the Message box > Message box action to the parent bot flow.
    2. In Enter the message box window title, enter Automation Anywhere Enterprise Client.
    3. In Enter the message to display, enter $dOutput{sMySong}$.
      The name of the output variable that the child bot uses is used as the key for retrieving the value from the dictionary variable.
    4. Click Save.
  9. Test the bot.
    1. Click Run to run the bot.
      After bot is deployed, the Favorite Song input box opens.
    2. In the Favorite Song input box, enter a song title.
    3. Click OK.
      A message box should display the string that the child bot returns. If no value returns, then review the procedure to assign the incoming value to a dictionary key and a variable.