Build a bot to extract and translate text

Build a bot to extract text from a page and use a prebuilt Bot Store bot to translate the text into English.

Prerequisites

Procedure

  1. Log in to the Enterprise Client.
  2. Click New.
  3. In the Automate window, click Workbench.
  4. Open the Variable Manager, click Add, and add the following variable names:
    1. vExtractedText: stores the extracted text from the website.
    2. vOutputLanguage: stores the target language text.
    3. vTranslatedText: stores the translated English text.
  5. From the Commands tab, select and drag the Open Program/File command to the Actions List.
  6. In the Open Program/File window, perform these steps:
    1. Step 1: Program/File Path: Browse and select the Google Chrome executable file. Find the file location on your machine, which can be: C:\Program Files (x86)\Google\Chrome\Application. In the Application folder, select chrome.exe.
    2. Step 2: Start in Path: You can skip this step.
    3. Step 3: Parameters: Enter the URL for the Automation Anywhere translate page: https://www.automationanywhere.com/automationanywherelabs/translate.html
    4. Click Save to close the command.
    The first command appears in the Actions List.
  7. Click Save to save your bot as Tutorial2_Translate.atmx.
    By default, the bot is saved in the My Tasks directory.
  8. Click Run to test it.
  9. From the Commands tab, select and drag the Object Cloning command to the Actions List.
  10. In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome. Verify that the target browser session is open in its own window.
  11. With the Object Cloning window open, click and hold the Capture button. While still holding the left mouse button, highlight the Text to Decode block of text until a red border blinks around it. Now release the button.
    1. In the Select Action to Perform drop-down list, select Get Property.
    2. In the Select Property drop-down list, select HTML InnerText .
    3. In the Assign to Variable drop-down list, select vExtractedText.
    4. Click Save.
  12. From the Commands tab, select the String Operation , click the + sign, and select and drag the Before-After command to the Actions List.
    1. In the String Operation window, in the Source String text box, enter vExtractedText.
    2. In the Before (Optional) field, enter Text to Decode.
    3. In the Assign the output to variable field, enter vExtractedText.
    4. Click Save.
  13. In a new browser window, navigate to http://botstore.automationanywhere.com. Search for the Bing Translate Bot, download and install it.
  14. In Workbench, click the MetaBots tab. Select and drag BingTranslate.mbot to the Actions List. In the MetaBot window, set the following input and output parameters:
    1. In the Input Parameters field, add values for the following parameters:
      • vInputText: vExtractedText
      • vOutputLanguage: vOutputLanguage
    2. In the Output Parameters field, add a value for the vOutputText: vTranslatedText.
    3. Click Save.
  15. In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome.
  16. With the Object Cloning window open, click and hold the Capture button. While still holding the left mouse button, highlight the Enter Translated Message Here to Validate input field until a red border blinks around it. Now release the button.
    1. In the Select Action to Perform drop-down list, select Set Text.
    2. In the Text to Set field, enter vTranslatedText.
    3. Click Save.
  17. In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome.
  18. With the Object Cloning window open, click and hold the Capture button. While still holding the left mouse button, highlight the Submit button until a red border blinks around it. Now release the button.
    1. In the Select Action to Perform field, select Left Click.
    2. Click Save.
  19. Save your bot and click Run.