Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Build a bot using REST web services and String actions

  • Updated: 8/11/2021
    • Automation 360 v.x
    • Build
    • RPA Workspace

Build a bot using REST web services and String actions

Use the custom app authentication to generate the access token to interact with Salesforce REST APIs and build a bot using the Automation 360 REST Web Service and String Operation actions.

Prerequisites

Ensure you have the following to build the bot:

Procedure

  1. Log in to the Control Room.
  2. On the left pane, click Automation.
    A list of available bots and forms is displayed.
  3. Click Create a bot icon.
  4. In the Name field, enter ConnectToAPIwithOAuth.
  5. Click Create & Edit.
  6. In the Actions page, click Variables to create a new variable:
    1. In the Name field, enter sClientId.
    2. In the Type field, select String.
    3. In the Default value field, paste the value from the Consumer Key field of the OAuth validation app.
    4. Click Create.
  7. Create a new sClientSecret variable, Type > String, Default value > Consumer Secret, paste the value.
  8. Create a new sUserName variable, Type > String, Default value > enter the SalesForce login user name.
  9. Create a new sPassword variable, Type > String, Default value > enter the SalesForce login password.
  10. Create a new sSecurityToken variable, Type > String, Default value > Security Token, paste the value.
  11. Create a new dResponse variable, Type > Dictionary and Subtype > String.
  12. Create a new sExtractedValue variable, Type > String.
  13. From the Actions pane, select REST Web Services > Post method and place it under the Start of the bot flow.
    1. In the URI field, enter https://ap17.salesforce.com/services/oauth2/token?grant_type=password&client_id=$sClientId$&client_secret=$sClientSecret$&username=$sUsername$&password=$sPassword$$sSecurityToken$. Replace ap17 with your Salesforce instance number.
    2. In the Authentication Mode drop-down list, select No Authentication.
    3. In the Content type drop-down list, select JSON (application/json).
    4. In the Assign the output to a variable drop-down list, select dResponse - Dictionary of Strings.
  14. From the Actions pane, drag Message box to the bot flow. In the Enter the message to display field, enter $dResponse{Body}$.
  15. From the Action pane, click String > Extract Text.
    1. In the Source string field, enter $dResponse{Body}$.
    2. In the Before or after Start after text, enter "access_token":", Occurrence, enter 1, select AND, End before text, enter ",", Occurrence, enter 1. If no match found, return, select Source String. Number of characters to get, select All, click Trim the extracted text (remove blank spaces), and click Remove Enter from the extracted text.
    3. In the Assign the output to a variable drop-down list, select sExtractedValue - String.
  16. From the Actions pane, drag Message box to the bot flow. In the Enter the message to display field, enter $sExtractedValue$.
  17. From the Actions pane, select REST Web Services > Post method.
    1. In the URI field, enter https://ap17.salesforce.com/services/data/v36.0/sobjects/Account . Replace ap17 with your Salesforce instance number.
    2. In the Authentication Mode drop-down list, select No Authentication.
    3. Click Header > Custom Headers > (Add):
      1. In the Name field, enter Authorization.
      2. In the Value field, enter Bearer $sExtractedValue$.
    4. In the Content type drop-down list, select JSON (application/json).
    5. In Custom Parameters, enter the following code:
      {
      "Name" : "Text passed through A2019 REST API"}
    6. In the Assign the output to a variable drop-down list, select dOutput -Dictionary of Strings.
  18. From the Actions pane, drag Message box. In the Enter the message to display field, enter $dOutput{Body}$.
  19. From the Action pane, select String > Extract text.
    1. In the Source string field, enter $dOutput{Body}$.
    2. In the Before or after Start after text, enter "id":", Occurrence, enter 1, select AND, End before text, enter ",", Occurrence, enter 1. If no match found, return, select Source String, Number of characters to get, select All, click Trim the extracted text (remove blank spaces), and click Remove Enter from the extracted text.
    3. In the Assign the output to a variable drop-down list, create a new sURLValue by clicking the plus sign, Type > String.
    4. Click Create & Select.
  20. From the Actions pane, drag Message box. In the Enter the message to display field, enter $sURLValue$.
    A message from the bot displays a URL value 0014R00002gIcsZQAS. Use the value to validate the data in your Salesforce account: https://<yourinstance>.salesforce.com/<sURLValue>. For example: https://ap17.salesforce.com/0014R00002gIcsZQAS.
Send Feedback