BACK

A2019 Tutorial: How to build a Twilio Package

Develop a custom package for Automation Anywhere Enterprise A2019 to expand on the existing actions available for use. In this tutorial, you’ll be creating a Twilio package to send SMS and place voice calls using Twilio API.

Pre-requisites

Basic understanding of programming concepts, JDK 11, using a Java IDE (IntelliJ will be used for this tutorial), and an understanding of using actions in Automation Anywhere Enterprise A2019.

Getting Started with Twilio:

You’ll need several pieces of data from the Twilio platform which will be mapped as mandatory input for the bot to work properly.

  1. SID Twilio String Identifier:
    a. Refer to this page on what an SID is and how to access yours on your trial/full account: https://www.twilio.com/docs/glossary/what-is-a-sid

  2. Twilio Auth Token:
    a. Refer to this page on how to access or change your Auth Token: https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them

  3. From Number:
    a. With a Twilio paid account, you actually buy an outgoing number that’s used to send and receive text messages.
    b. For trial accounts, the number you can use for outbound messages can be found here: https://www.twilio.com/console/sms/getting-started/build
    Note: on trial accounts, all messages are prefixed with something like “Trial message from Twilio:” – this wouldn’t appear when an account is upgraded beyond trial.

  4. To Number:
    a. On a trial account, you can only send text messages to confirmed phone numbers (presumably your own)
    Be sure to verify your number with Twilio before attempting to send a test message. Use the following page to send yourself a test message before using the bot to send a message: https://www.twilio.com/console/sms/getting-started/build
    b. On a full account, you can send text messages to any number that Twilio supports.

Steps to build a package

  1. Unzip the contents of the SDK package to your IdeaProjects directory and name the folder from A2019.10-package-sdk-1.0.0 to Twilio

    1. By default this is C:\Users\<User>\IdeaProjects

  2. In IntelliJ IDEA, go to File>Open and navigate to: C:\Users\<User>\IdeaProjects\Twilio and select to open the project.

  3. Open the settings.gradle file in the root of the project

    1. This file only has a single parameter which is the rootProject.name – this value is used for naming the compiled jar on build.

    2. Set the rootProject.name = ‘Twilio’

  4. Update the package.template file located at src > main > resources > package.template
    1. “name” is the name of the package itself, change this from “A2019DemoPackage” to “Twilio”
    2. “label” and “description” from the package.template file are using the [[label]] and [[description]] notation, that means they are references to the locales json file which we’ll update next.
  5. The package name and label also need to be updated in the locales json. Locales files are used so that the bot’s labels, fields, description, etc. can easily be translated to other languages

    1. To update the locales json, Navigate to src > main > resources > locales > en_US.json.

    2. Change the label and description fields

      From:

      "label" : "A2019DemoPackage", 
      "description" : "Provides actions for A2019DemoPackage operations"

      To:

      "label" : "Twilio",
      "description" : "Send SMS and make call using Twilio API"

       

    3. Delete all other remaining labels from the en_US.json. We’ll be adding some more later, but we wont be using anything but the label and description from what is there now.
  6. In the build.gradle file, add the following line as the last line within dependencies section as shown in the screenshot below, that would indicate the dependency should be downloaded:
    implementation group: "com.twilio.sdk", name: "twilio", version: "7.52.0"

  7. Create a new package by going to src > main > java > com.automationanywhere.botcommand.samples.commands and right clicking and selecting New>Package
    1. Name the new package: com.automationanywhere.botcommand.twiliomessenger.commands
  8. Create a new Java Class by right clicking on the twilio.commands package that is created, and selecting New>Class
    1. Name the new class SMS
    2. Also create one more class MakeCall
  9. After creating a new class SMS, open the SMS Class
    1. Add the following lines above the class definition
      //BotCommand makes a class eligible for being considered as an action.
      @BotCommand

    2. The @BotCommand annotation will turn red in intelliJ because the corresponding reference to the BotCommand class is missing. Highlight over the missing reference and select “Import Class”

    3. Below the @BotCommand annotation but before the SMS class definition, insert the following lines to define the package labels for the Automation Anywhere Enterprise A2019 UI

      //CommandPkg adds required information to be displayed on GUI.
      @CommandPkg(
      //Unique name inside a package and label to display.
              label = "[[SMS.label]]",
              name = "[[SMS.name]]",
              description = "[[SMS.description]]",
              node_label = "[[SMS.node_label]]",
              icon ="twilio.svg",
              //Return type information. return_type ensures only the right kind of variable is provided on the UI.
              return_type = DataType.STRING,
              return_label = "[[SMS.return_label]]",
              return_required = true)
    4. Notice that the @CommandPkg annotation self resolved. (If yours doesn’t, follow the process we used for resolving the @BotCommand annotation).

    5. We need to define the execute annotation within our class to set the entry point for our action. Insert the following lines INSIDE the SMS class:

      //Identify the entry point for the action. Returns a StringValue because the return type is String.
      @Execute
      public StringValue sendSMS(
              //Idx 1 would be displayed first, with a credential box for entering the value.
              @Idx(index = "1", type = CREDENTIAL)
              //UI labels.
              @Pkg(label = "[[SMS.SID.label]]",   default_value_type = STRING, description = "[[SMS.SID.description]]")
              //Ensure that a validation error is thrown when the value is null.
              @NotEmpty SecureString authSID,
      
              @Idx(index = "2", type = CREDENTIAL)
              @Pkg(label = "[[SMS.AuthToken.label]]",   default_value_type = STRING, description = "[[SMS.AuthToken.description]]")
              @NotEmpty SecureString authToken,
      
              @Idx(index = "3", type = TEXT)
              @Pkg(label = "[[SMS.SenderNumber.label]]", default_value_type = STRING, description = "[[SMS.SenderNumber.description]]")
              @NotEmpty String senderNumber,
      
              @Idx(index = "4", type = TEXT)
              @Pkg(label = "[[SMS.RecipientNumber.label]]", default_value_type = STRING, description = "[[SMS.RecipientNumber.description]]")
              @NotEmpty String recipientNumber,
      
              @Idx(index = "5", type = TEXT)
              @Pkg(label = "[[SMS.MessageBody.label]]", default_value_type = STRING, description = "[[SMS.MessageBody.description]]")
              @NotEmpty String  messageBody
      )
    6. CREDENTIAL, TEXT and STRING will turn red. For CREDENTIAL and TEXT, Highlight over the missing reference and select Alt + Enter. The following lines will be added to the import section at the top above @BotCommand
      import static com.automationanywhere.commandsdk.model.AttributeType.CREDENTIAL;
      import static com.automationanywhere.commandsdk.model.AttributeType.TEXT;

       

    7. For STRING, Highlight over the missing reference and select Alt + Enter. The following lines will be added to the import section at the top above @BotCommand
      import static com.automationanywhere.commandsdk.model.DataType.STRING;

       

    8. The sendSMS function inside of our class is not yet complete…only the definition of its inputs have been defined. Right below the lines we just inserted, insert the following code to perform our send SMS logic from within a try/catch block and return the results as a string:
      {
          String result = "";
      
          try{
              //Business logic to send out SMS
              Twilio.init(authSID.getInsecureString(),authToken.getInsecureString());
              Message msg = Message.creator(
                      new com.twilio.type.PhoneNumber(recipientNumber),
                      new com.twilio.type.PhoneNumber(senderNumber),
                      messageBody)
                      .create();
              result = msg.getSid();
          }catch(Exception e){
              throw new BotCommandException(e.getMessage(), e);
      
          }
          //Return StringValue.
          return new StringValue(result);
      
      }

       

    9. Add the following lines in the import section to the import section at the top above @BotCommand
      import com.twilio.Twilio;
      import com.twilio.rest.api.v2010.account.Message;

       

    10. Code below shows the full code in SMS class for your reference:
      package com.automationanywhere.botcommand.twiliomessenger.commands;
      import com.automationanywhere.botcommand.data.impl.StringValue;
      import com.automationanywhere.botcommand.exception.BotCommandException;
      import com.automationanywhere.commandsdk.annotations.*;
      import com.automationanywhere.commandsdk.annotations.rules.NotEmpty;
      import com.automationanywhere.commandsdk.model.DataType;
      import com.twilio.Twilio;
      import com.twilio.rest.api.v2010.account.Message;
      import static com.automationanywhere.commandsdk.model.AttributeType.CREDENTIAL;
      import static com.automationanywhere.commandsdk.model.AttributeType.TEXT;
      import static com.automationanywhere.commandsdk.model.DataType.STRING;
      import com.automationanywhere.core.security.SecureString;
      
      //BotCommand makes a class eligible for being considered as an action.
      @BotCommand
      
      //CommandPkg adds required information to be displayed on GUI.
      @CommandPkg(
      //Unique name inside a package and label to display.
              label = "[[SMS.label]]",
              name = "[[SMS.name]]",
              description = "[[SMS.description]]",
              node_label = "[[SMS.node_label]]",
              icon ="twilio.svg",
              //Return type information. return_type ensures only the right kind of variable is provided on the UI.
              return_type = DataType.STRING,
              return_label = "[[SMS.return_label]]",
              return_required = true)
      
      public class SMS {
      
          //Identify the entry point for the action. Returns a StringValue because the return type is String.
          @Execute
          public StringValue sendSMS(
                  //Idx 1 would be displayed first, with a credential box for entering the value.
                  @Idx(index = "1", type = CREDENTIAL)
                  //UI labels.
                  @Pkg(label = "[[SMS.SID.label]]",   default_value_type = STRING, description = "[[SMS.SID.description]]")
                  //Ensure that a validation error is thrown when the value is null.
                  @NotEmpty SecureString authSID,
      
                  @Idx(index = "2", type = CREDENTIAL)
                  @Pkg(label = "[[SMS.AuthToken.label]]",   default_value_type = STRING, description = "[[SMS.AuthToken.description]]")
                  @NotEmpty SecureString authToken,
      
                  @Idx(index = "3", type = TEXT)
                  @Pkg(label = "[[SMS.SenderNumber.label]]", default_value_type = STRING, description = "[[SMS.SenderNumber.description]]")
                  @NotEmpty String senderNumber,
      
                  @Idx(index = "4", type = TEXT)
                  @Pkg(label = "[[SMS.RecipientNumber.label]]", default_value_type = STRING, description = "[[SMS.RecipientNumber.description]]")
                  @NotEmpty String recipientNumber,
      
                  @Idx(index = "5", type = TEXT)
                  @Pkg(label = "[[SMS.MessageBody.label]]", default_value_type = STRING, description = "[[SMS.MessageBody.description]]")
                  @NotEmpty String  messageBody
          ) {
              String result = "";
              
              try{
                  //Business logic to send out SMS
                  Twilio.init(authSID.getInsecureString(),authToken.getInsecureString());
                  Message msg = Message.creator(
                          new com.twilio.type.PhoneNumber(recipientNumber),
                          new com.twilio.type.PhoneNumber(senderNumber),
                          messageBody)
                          .create();
                  result = msg.getSid();
              }catch(Exception e){
                  throw new BotCommandException(e.getMessage(), e);
      
              }
              //Return StringValue.
              return new StringValue(result);
      
          }
      }

      Follow the same steps for MakeCall Class as we did for the SMS class, lets see how it looks like:

  10. Open the MakeCall Class.

    1. Add the following line above the class definition:

      //BotCommand makes a class eligible for being considered as an action.
      @BotCommand

       

    2. The @BotCommand annotation will turn red in intelliJ because the corresponding reference to the BotCommand class is missing. Highlight over the missing reference and select “Import Class”

    3. Below the @BotCommand annotation but before the MakeCall class definition, insert the following lines to define the package labels for the Automation Anywhere Enterprise A2019 UI.

      //CommandPkg adds required information to be displayed on GUI.
      @CommandPkg(
              //Unique name inside a package and label to display.
              label = "[[MakeCall.label]]",
              name = "[[MakeCall.name]]",
              description = "[[MakeCall.description]]",
              icon ="twilio.svg",
              //Return type information. return_type ensures only the right kind of variable is provided on the UI.
              return_type = DataType.STRING,
              return_label = "[[MakeCall.return_label]]",
              node_label = "[[MakeCall.node_label]]",
              return_required = true)

       

    4. Notice that the @CommandPkg annotation self resolved. (If yours doesnt, follow the process we used for resolving the @BotCommand annotation).

    5. We need to define the execute annotation within our class to set the entry point for our action. Insert the following lines INSIDE the MakeCall class:

      //Identify the entry point for the action. Returns a StringValue because the return type is String.
          @Execute
          public StringValue PlaceCall(
      
                  //Idx 1 would be displayed first, with a credential box for entering the value.
                  @Idx(index = "1", type = CREDENTIAL)
                  //UI labels.
                  @Pkg(label = "[[MakeCall.SID.label]]",   default_value_type = STRING, description = "[[MakeCall.SID.description]]")
                  //Ensure that a validation error is thrown when the value is null.
                  @NotEmpty SecureString authSID,
      
                  @Idx(index = "2", type = CREDENTIAL)
                  @Pkg(label = "[[MakeCall.AuthToken.label]]",   default_value_type = STRING, description = "[[MakeCall.AuthToken.description]]")
                  @NotEmpty SecureString authToken,
      
                  @Idx(index = "3", type = TEXT)
                  @Pkg(label = "[[MakeCall.SenderNumber.label]]", description = "[[MakeCall.SenderNumber.description]]")
                  @NotEmpty String senderNumber,
      
                  @Idx(index = "4", type = TEXT)
                  @Pkg(label = "[[MakeCall.RecipientNumber.label]]", default_value_type = STRING, description = "[[MakeCall.RecipientNumber.description]]")
                  @NotEmpty String recipientNumber,
      
                  @Idx(index = "5", type = TEXT)
                  @Pkg(label = "[[MakeCall.CallMessage.label]]", default_value_type = STRING, description = "[[MakeCall.CallMessage.description]]")
                  @NotEmpty String  messageBody
          )

       

    6. The MakeCall function inside of our class is not yet complete…only the definition of its inputs have been defined. Right below the lines we just inserted, insert the following code to perform our place Call logic from within a try/catch block and return the results as a string:
      {
              String result = "";
              try{
                  //Business logic to place voice call
                  Twilio.init(authSID.getInsecureString(),authToken.getInsecureString());
                  Call call = Call.creator(new PhoneNumber(recipientNumber), new PhoneNumber(senderNumber),
                          new com.twilio.type.Twiml(messageBody)).create();
                  result = call.getSid();
              }catch(Exception e){
                  throw new BotCommandException(e.getMessage(), e);
              }
              //Return StringValue.
              return new StringValue(result);
          }

       

    7. Code below shows the full code in MakeCall class for your reference:
      package com.automationanywhere.botcommand.twiliomessenger.commands;
      
      import com.automationanywhere.botcommand.exception.BotCommandException;
      import com.automationanywhere.commandsdk.annotations.*;
      import com.automationanywhere.commandsdk.annotations.rules.NotEmpty;
      import com.automationanywhere.commandsdk.model.DataType;
      import com.twilio.Twilio;
      import com.twilio.rest.api.v2010.account.Call;
      import com.twilio.type.PhoneNumber;
      import static com.automationanywhere.commandsdk.model.AttributeType.CREDENTIAL;
      import static com.automationanywhere.commandsdk.model.AttributeType.TEXT;
      import static com.automationanywhere.commandsdk.model.DataType.STRING;
      import com.automationanywhere.core.security.SecureString;
      import com.automationanywhere.botcommand.data.impl.StringValue;
      
      //BotCommand makes a class eligible for being considered as an action.
      @BotCommand
      
      //CommandPkg adds required information to be displayed on GUI.
      @CommandPkg(
              //Unique name inside a package and label to display.
              label = "[[MakeCall.label]]",
              name = "[[MakeCall.name]]",
              description = "[[MakeCall.description]]",
              icon ="twilio.svg",
              //Return type information. return_type ensures only the right kind of variable is provided on the UI.
              return_type = DataType.STRING,
              return_label = "[[MakeCall.return_label]]",
              node_label = "[[MakeCall.node_label]]",
              return_required = true)
      
      
      public class MakeCall {
          //Identify the entry point for the action. Returns a StringValue because the return type is String.
          @Execute
          public StringValue PlaceCall(
      
                  //Idx 1 would be displayed first, with a credential box for entering the value.
                  @Idx(index = "1", type = CREDENTIAL)
                  //UI labels.
                  @Pkg(label = "[[MakeCall.SID.label]]",   default_value_type = STRING, description = "[[MakeCall.SID.description]]")
                  //Ensure that a validation error is thrown when the value is null.
                  @NotEmpty SecureString authSID,
      
                  @Idx(index = "2", type = CREDENTIAL)
                  @Pkg(label = "[[MakeCall.AuthToken.label]]",   default_value_type = STRING, description = "[[MakeCall.AuthToken.description]]")
                  @NotEmpty SecureString authToken,
      
                  @Idx(index = "3", type = TEXT)
                  @Pkg(label = "[[MakeCall.SenderNumber.label]]", description = "[[MakeCall.SenderNumber.description]]")
                  @NotEmpty String senderNumber,
      
                  @Idx(index = "4", type = TEXT)
                  @Pkg(label = "[[MakeCall.RecipientNumber.label]]", default_value_type = STRING, description = "[[MakeCall.RecipientNumber.description]]")
                  @NotEmpty String recipientNumber,
      
                  @Idx(index = "5", type = TEXT)
                  @Pkg(label = "[[MakeCall.CallMessage.label]]", default_value_type = STRING, description = "[[MakeCall.CallMessage.description]]")
                  @NotEmpty String  messageBody
          ) {
              String result = "";
              try{
                  //Business logic to place voice call
                  Twilio.init(authSID.getInsecureString(),authToken.getInsecureString());
                  Call call = Call.creator(new PhoneNumber(recipientNumber), new PhoneNumber(senderNumber),
                          new com.twilio.type.Twiml(messageBody)).create();
                  result = call.getSid();
              }catch(Exception e){
                  throw new BotCommandException(e.getMessage(), e);
              }
              //Return StringValue.
              return new StringValue(result);
          }
      }
    8. As the commenting suggests, these annotations make the class eligible for being considered an action, and allow for setting a label, description, and icon for the package. Using these annotations also automatically imports several Automation Anywhere sdk namespaces.

      i. In the lines we just pasted in – take a look at the Command Package Annotation (most of which makes references to the locales json we’ll be updating in a bit).

      1. name is the name of the action.

      2. label is the display label for the command as will show in the actions pane.

      3. node_label is the label for the command instance inside of the bot (shows up right under the command itself).

      4. description is the short description of the action which is displayed on mouse-over.

      5. icon is the icon that is used for the command when displayed in the flow and list view.

      6. return_label is the field label for the return value mapping.

      7. return_type is the type of data that the action will return.

  11. The code just pasted in does the following:

    1. Automatically imports several namespaces based on the annotations and datatypes used.

      i. Should this automatic import not work properly in IntelliJ, you may need to manually import the namespaces by pressing alt + enter on an error highlighted line.

      1. @Idx annotation sets up the field index order as well as the field type. Additional attribute types like file, image, regex, radio, etc. are referenced in the projects Java Docs.

      2. @Pkg annotation establishes the label used for the field. Additional parameters that can be set here include an additional description which can be added below the field, making a field read only, etc. are referenced in the projects Java Docs.

      3. NotEmpty annotation ensures that the value is filled. Additional annotation rules like greater than, less than, credential only, etc. are referenced in the projects Java Docs.

      4. Sets an exception/error message if the field is not empty

      5. SMS: Sends a SMS to the recipient number and returns a SID as the output if the SMS is successful, otherwise it will throw an exception which can be captured in a variable for further processing

      6. MakeCall: Places a voice call to the recipient number and returns a SID as the output if the Call is successful, otherwise it will throw an exception which can be captured in a variable for further processing

  12. Navigate to src > main > resources > locales > en_US.json

    1. Add the following value references after the label and description values we updated previously:

      "SMS.name": "Send SMS from Twilio",
          "SMS.label": "Send SMS",
          "SMS.description": "Sends SMS using Twilio API",
          "SMS.node_label": "Sends SMS using Twilio API",
          "SMS.return_label": "Assign the output to variable as type String",
      
          "SMS.SID.label": "SID",
          "SMS.SID.description": "Auth SID",
      
          "SMS.AuthToken.label": "Auth Token",
          "SMS.AuthToken.description": "Auth Token",
      
          "SMS.SenderNumber.label": "Sender Number",
          "SMS.SenderNumber.description": "Format this number with a '+' and a country code, e.g., +16175551212, Reference: https://www.twilio.com/docs/sms/send-messages#from",
      
          "SMS.RecipientNumber.label": "Recipient Number",
          "SMS.RecipientNumber.description": "Format this number with a '+' and a country code, e.g., +16175551212, Reference: https://www.twilio.com/docs/sms/send-messages#to",
      
          "SMS.MessageBody.label": "Message Body",
          "SMS.MessageBody.description": "Reference: https://www.twilio.com/docs/sms/send-messages#body",
      
          "MakeCall.name": "Place a call from Twilio",
          "MakeCall.label": "Make a Call",
          "MakeCall.description": "Outgoing calls using Twilio Account",
          "MakeCall.node_label": "Outgoing calls using Twilio",
          "MakeCall.return_label": "Assign the output to variable as type String",
      
          "MakeCall.SID.label": "SID",
          "MakeCall.SID.description": "Auth SID",
      
          "MakeCall.AuthToken.label": "Auth Token",
          "MakeCall.AuthToken.description": "Auth Token",
      
          "MakeCall.SenderNumber.label": "Sender Number",
          "MakeCall.SenderNumber.description": "Format this number with a '+' and a country code, e.g., +16175551212, Reference: https://www.twilio.com/docs/voice/make-calls#specify-the-caller-id",
      
          "MakeCall.RecipientNumber.label": "Recipient Number",
          "MakeCall.RecipientNumber.description": "Format this number with a '+' and a country code, e.g., +16175551212, Reference: https://www.twilio.com/docs/voice/make-calls#specify-the-calls-recipient",
      
          "MakeCall.CallMessage.label": "Message Body",
          "MakeCall.CallMessage.description": "Sample URL to be used: https://demo.twilio.com/docs/voice.xml, Read more about the format here: https://www.twilio.com/docs/voice/make-calls#tell-twilio-what-to-do-on-the-call"

      Note: each value in the en_US.json should have a comma after it except for the final value just before the curly braces at the end of the file

       

       

  13. Navigate to src > main > java > com.automationanyhwere.botcommand and delete the samples.commands package.
    1. Additionally, delete the samples package that shows up after deleting samples.commands.
  14. The CommandPkg annotation, we referenced a custom icon which doesn’t yet exist in our project.
    1. Download the twilio.svg from this location saving the file by right clicking on the image and selecting Save Image As.. and naming the file as twilio.svg

    2. Download the iconwhite.svg from this location saving the file by right clicking on the image and selecting Save Image As.. and naming the file as iconwhite.svg

    3. Copy both files into the src > main > resources > icons folder.

      i. When in flow view or when the specific command is highlighted in list view, the iconwhite.svg is used.

      ii. In the Action pane view and in list view when the specific command is not highlighted, the twilio.svg we referenced in the CommandPkg will be used.

  15. Save the project by going to File > Save All or pressing ctrl +S
  16. The package now needs to be built. This can be done through the IntelliJ UI or through the command line. In this example, we’ll do it using the command line.
    1. Open a command prompt and navigate to your Twilio directory by entering:
      cd “%USERPROFILE%\IdeaProjects\Twilio”

       

    2. To clean and build the project, run the following command:
      gradlew.bat clean build shadowJar

       

    3. You should get a BUILD SUCCESSFUL message. Should you get an error – check back in IntelliJ to make sure none of the code is highlighted with a red underline (indicating there is an issue)
      1. Alternatively, sometimes builds will fail because existing files couldn’t be deleted automatically from the command line with a message indicating the execution failed for task ‘:clean’.
        1. In those cases, try closing previously opened windows explorer windows and running the build again to successfully compile the project.
  17. From windows explorer, navigate to C:\Users\<Username>\IdeaProjects\Twilio\build\libs and you should find Twilio-2.0.0.jar. Version number 2.0.0 is coming from the build.gradle file in the section configure(all projects) as seen in the last line below before the paranthesis.
    configure(allprojects){
        
        apply plugin: 'com.github.johnrengelman.shadow'
        apply plugin: "com.automationanywhere.command-codegen"
        
        ext {
            groupName = 'com.automationanywhere'
            testNgVersion = '6.14.3'
            loggerVersion = '2.10.0'
            jnaVersion = '5.3.1'	
            version '2.0.0'
        }

     

  18. Log in to your Automation Anywhere Enterprise A2019 Control Room as a user with permissions to add a new package.
  19. Navigate to Bots > Packages

    1. On the right side of the screen above the existing packages table should be an icon with PKG+. Click this button to add a new package.

    2. Click the Browse… button to navigate to the jar file we’d just compiled.

    3. This should be located in C:\Users\<Username>\IdeaProjects\Twilio\build\libs

    4. Select the Twilio-2.0.0.jar and press Open to select the file.

    5. Press the Upload Package button after the file has been selected to upload it to the Control Room.

    6. On the Confirm Package page that appears, select Accept, enable and set as default.

  20. Create a bot to test out the newly created action.
    1. In Control Room, navigate to Bots > My Bots

    2. Click the Create a bot… icon in the top right corner to start creating a new bot.

    3. In the Create Task Bot interface that appears, enter the name TwilioBot and press theCreated & edit button

  21. In the Actions pane on the left, navigate to the Twilio package, and drag the Send SMS action into your bot flow
    1. In the SID field that appears, enter the SID from your Twilio account

    2. In the Auth Token field, enter the Auth Token from your Twilio account

    3. Enter the Sender Number (Format with a ‘+’ and a country code, e.g., +16175551212)

    4. Enter the Recipient Number (Format with a ‘+’ and a country code, e.g., +16175551212)

    5. Enter the Message body “Hello Twilio”

    6. Select ‘prompt-assignment’ in ‘Assign the output to variable as type String’.

    7. Press the Apply button to save the changes to the action

    8. Add a ‘Message box’ and select ‘prompt-assignment’ This will display the SID number for the SMS delivery

    9. Press the Save button to save the bot changes, and press the Run button to execute the bot.
  22. The bot will execute and display a number (similar to this) ‘SM13b907e66d42435ba8686fe487039762’ in the message box

  23. You can check your mobile SMS to see the message sent from your Bot

  24. Now lets test the Call feature.

    1. Disable the Twilio: Send SMS action used earlier

    2. In the Actions pane on the left, navigate to the Twilio package, and drag the Make Call action into your bot flow.

    3. In the SID field that appears, enter the SID from your Twilio account

    4. In the Auth Token field, enter the Auth Token from your Twilio account

    5. Enter the Sender Number (Format with a ‘+’ and a country code, e.g., +16175551212)

    6. Enter the Recipient Number (Format with a ‘+’ and a country code, e.g., +16175551212)

    7. Enter the Call Message field in the following two ways:

      1. First option is to type this entire text
        <Response><Say>This is a call from your Automation Anywhere bot. You successfully created a package that can place phone calls. Well done. Go be Great!</Say></Response>

         

      2. Second option is to just enter the URL like this, which contains the text details to be passed
        http://demo.twilio.com/docs/voice.xml

         

    8. Select ‘prompt-assignment’ in ‘Assign the output to variable as type String’.

    9. Press the Apply button to save the changes to the action

    10. Press the Save button to save the bot changes, and press the Run button to execute the bot.
  25. The bot will execute and display a number (similar to this) ‘SM13b907e6653453l45j3456fe487039762’ in the message box

  26. You should receive a call on your mobile from the Twilio Sender Number configured above.

  27. That’s the end of this tutorial, hope you enjoyed creating a new package.

Final Note

The package source code is uploaded here for your reference, feel free to download and try it out.