閱讀及檢閱 Automation Anywhere 文件

Automation 360

關閉內容

內容

開啟內容

Example of passing a value between bots including video clips

  • 已更新:2022/01/03
    • Automation 360 v.x
    • 組建
    • Enterprise

Example of passing a value between bots including video clips

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

To pass values between TaskBots, use any variable type in the child bot and a dictionary variable in the parent bot. This example uses a string variable called sMySong in the child bot.

程序

  1. Build the child bot with the following steps:
    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 FavoriteSongs
    4. Enter the folder location as Bots\TaskBotExample.
    5. Click Create and Edit.
  2. Create the variable: sMySong and select both check-boxes: use as input and use as output for this variable.
  3. Use the Prompt > For value action to capture a song name.
    1. Find the action Prompt > for value and double-click or drag the action into your flow.
    2. In the Prompt window caption field, enter Add a song.
    3. In the Prompt message field, enter Type in a favorite song.
    4. In the Assign the value to a variable field, enter sMySong.
      註: In the List display mode, your child bot should be one line of code:

      Prompt: For value

  4. Click Save and then click Close.
  5. Build the parent bot with the following steps:
    1. From the Control Room interface, select Bots > My bots.
    2. Click Create New > Bot.
    3. Enter the name for the bot as GetFavoriteSongs.
    4. Enter the folder location as Bots\TaskBotExample.
    5. Click Create and Edit.
  6. Create the following two variables:
    1. sMySong: select string as the subtype
    2. sPassedSong: select dictionary as the type and string as the subtype
  7. Use the Task Bot > Run action to call the child bot:
    1. Find the action Task Bot > Run and double-click or drag the action into your flow.
    2. In the Task Bot to run field, select Control Room and click Choose.
    3. Click Browse, navigate to Bots\TaskBotExample, and select FavoriteSongs.
    4. In the section Input values, select Set sMySong.
    5. In the Save the outcome to a variable (option), select Dictionary, and then select sPassedSong.
    6. Click Save.
  8. Use the action Dictionary > Get to accept the value returned from the child bot.
    1. Find the action Dictionary > Get and double-click or drag the action into your flow.
    2. In the Dictionary Variable field, select sPassedSong.
    3. In the Key field, select sMySong.
    4. In the Assign the output to variable field, select sMySong.
    5. Click Save.
  9. Use a Message box action to report what was returned from the child bot:
    1. Find the action Message box and double-click or drag the action into your flow.
    2. In the field Enter the message box window title, enter What do you like?.
    3. In the Enter the message to display field, enter You said, $sMySong$.
    4. Click Save.
      註: In List display mode, your parent bot should look like this:
      Start
      Task Bot: Run and assign output to variable
      Dictionary: Get value of the key "sMySong" from SsPassedSongS
      Message box "You said, $sMySong$"
      End
  10. Click Run to deploy your bot.
    When prompted to Set input variables, click Confirm. Follow the prompts and a message box should return the same value you entered for your song. If no value is returned, ensure you have performed the steps to assign the incoming value to a dictionary key and a variable.
傳送意見反饋