Tutorial: Creating a bot skill to extract passport data

This tutorial teaches you how to create IBM Robotic Process Automation (RPA) bots and then add them as skills into IBM watsonx Orchestrate™. Create a bot that can complete I-9 forms by using scanned passport data. Bots are a great tool to automate repetitive and rules-based tasks, perfect for this use case.

IBM RPA is a platform that automates recurring processes by using bots to replace highly repetitive tasks. You can automate these types of tasks by developing scripts to create the actions that a bot must run. For more information, see the IBM Robotic Process Automation 🡥 documentation.

This tutorial covers the following steps:

  1. Developing the bot's script
  2. Preparing a bot
  3. Publishing the bot as a skill to the skill catalog
  4. Connecting and running the bot skill

Before you begin

Before you start creating a bot skill, you must comply with the following requirements for IBM Robotic Process Automation and IBM watsonx Orchestrate:

IBM Robotic Process Automation

Important: You can explore IBM Robotic Process Automation with a free trial. The trial gives you access to an environment with tenant provision and IBM RPA Studio pre-configured at no-cost for 30 days to build bots.

For deployments of IBM Robotic Process Automation as Software as a Service (SaaS), you get provisioned with a tenant by IBM.
And, for deployments of IBM Robotic Process Automation On-Premises, you provision the first tenant during the installation of the platform. For more information about how to install IBM RPA, see Installing IBM RPA 🡥.

Contact an IBM sales representative to discuss deployment options at IBM Robotic Process Automation.

After you get your tenant provisioned and install IBM RPA, check with your tenant administrator to add the following resources to it:

  1. Add a user with the following permissions:

    • Manage projects
    • Manage bots
    • Start bots
    • Manage scripts
    • Use a studio application
    • Manage connections

    For instructions, see Creating users 🡥.

    Note: Use this user to go through this tutorial.
  2. Add a computer to run the bot. The computer must comply with the following settings:

    • The computer must have a credential that is bound to it. For instructions, see Creating a credential 🡥.
    • The Queues runtime percentage value must be higher than zero, for example: 100%.

    For instructions, see Creating a computer 🡥

  3. Add a computer group named Bot skill computer group. For instructions, see Creating a computer group 🡥.

  4. Add the following domain to the bot callbacks allowlist in IBM RPA:

    *.watson-orchestrate.ibm.com
    

    For instructions, see Creating an OpenAPI callback allowlist 🡥.

  5. Provide a Google Drive account.

IBM watsonx Orchestrate

You must have access to a Orchestrate tenant and a user with builder permissions to develop skills.

Developing the bot's script

View the following video to get an overview of the scenario of the script developed for this tutorial and understand how it works. You can use both the video and the written steps to walk through the next steps:

This tutorial provides a previously developed script and its assets so you have the resources that you need to create a bot in IBM RPA and complete the tutorial. Go to the Download the assets step to get it.

The script has instructions to get a passport image from Google Drive based on the passport file name. That information comes from one input form when the user uses the skill on Orchestrate.

Then, the script instructs the bot to extract the passport data and fill the I-9 form based on these extracted data. After that the bot returns the results of the automations over one output form on Orchestrate.

The input and output forms are automatically generated based on the input and output variables on the script. Which means that for each input and output variable in the bot's script, a new field is added to the input and output form.

This first topic walks you through the steps to download the tutorial's assets, and update and publish the bot's script.

  1. Download the assets
  2. Configure the automation environment
  3. Update the bot's script
  4. Publish the bot's script

Download the assets

Download the "BOT-SKILL-ASSETS" folder to get the bot's script and its resources.

This folder must contain the following files:

BOT-SKILL-ASSETS\
  ├── extractPassportDetails.wal
  ├── i-9 form template.pdf
  ├── Kamilla Vitia Campo.jpg
  ├── Oriana Telama Byrd.jpg
  ├── Venkat Bonaventura Telman.jpg
  └── Waheed Haris Rinaldi.jpg

Configure the automation environment

To property use the I-9 automation, you need to configure the Google Drive folders and connect that drive account to RPA.

To create the folders and save the files to your Google Drive account:

  1. Log in to your Google Drive account 🡥.
  2. Create the Passports, I9Documents, and referenceDocuments folders.
  3. Paste the passport files into the Passports folder.
  4. Paste the i-9 form template.pdf file into the referenceDocuments folder.

To connect IBM RPA to your Google Drive account:

  1. Log in to IBM RPA Control Center.
  2. On the Define menu, click Connections > Create connection.
  3. Click Google Drive and then click Next.
  4. In the Display name field, enter RPA I9 Google Drive.
  5. Set the Share connection to On, and click Next.
  6. Review the connection summary and click Authorize. Follow the Google Drive authorization steps to authorize IBM RPA to connect to it.

Update the bot's script

Check whether the script references the right connection to Google Drive:

  1. Log in to IBM RPA Studio.

    • Note: IBM RPA Studio is a low-code graphical interface that you can use to develop your scripts. For more information about how it works, see IBM RPA Studio 🡥.
  2. Open the extractPassportDetails.wal file and go to the connectToGoogleDrive subroutine.

  3. Double-click the Connect to Google Drive command and select RPA I9 Google Drive from the Name list.

    Focus on the connectToGoogleDrive subroutine's code block. It shows the Connect to Google Drive command opened and filled with the indicated connection.

If you want to add more information in the skill output, follow the following procedure:

  1. In to IBM RPA Studio, open the extractPassportDetails.wal file. For more information, see Opening existing scripts.

  2. Go to Home > Actions and click Variables visible.

  3. Double-click a variable, for example, the passportNumber variable.

  4. Set Script Output Parameter to On.

  5. Click Save and save the script.

    Note: The logic of this script sets the passportFileName variable as an input variable, so if you change it without changing the script logic, the bot skill might not work properly.

Publish the bot's script

Now, is time to publish the script to your tenant. Complete the following steps to publish the script:

  1. In IBM RPA Studio, go to Home and click Publish.
  2. In the Name field, enter extractPassportDetails.
  3. In the Description field, enter Download passport files from Google Drive, and get their data to fill the I-9 form..
  4. Set the Set as production to On.
  5. Click the Show advanced options link.
  6. In the Green time field, enter 00:01.
  7. In the Yellow time field, enter 00:02.
  8. In the Red time field, enter 00:04.
  9. Click Ok.

A green check appears on the script tab to indicate that the script is published.

Preparing a bot

This second topic walks you through the steps to create a project and a bot, and download the OpenAPI file.

  1. Create the project
  2. Create the bot
  3. Download the OpenAPI file

Create the project

  1. Log in to IBM RPA Control Center.
  2. On the Manage menu, click Projects > Create project.
  3. In the Name field, enter Bot skill.
  4. In the Description field, enter Bot skill project.
  5. Click Create.

As a result, you can view the Bot skill project in the project's list.

Create the bot

  1. From the Manage projects page, click the Bot skill project.
  2. In the Bots tab, click Create bot +.
  3. In the Name field, enter Create an I9 form.
  4. In the Description field, enter Bot intended to collect passport data and fills the I-9 form..
  5. Click Next.
  6. From the Script list, select extractPassportDetails.
  7. From the Version list, select 1.
  8. From the Computer group list, select Bot skill computer group.
  9. Click Next.
  10. Review the bot summary and click Create.

As a result, you can view the Create an I9 form bot in the bot's list.

Download the OpenAPI file

From the Bot skill project, click Download OpenAPI. It downloads a YAML file that follows the OpenAPI specification and contains your bot data. For this tutorial, the downloaded file is named bot_skill-openapi.yml.

Page of the Bot Skill project. The cursor clicks the Download OpenAPI button to download the OpenAPI specification file for the Bot Skill project.

Important:If the importing process with the YAML failed, convert the YAML into JSON and try import it again.

Publishing the bot as a skill to the skill catalog

The following video shows how to import and enhance the bot as skill to Orchestrate. It is an overview of the written steps. You can use both the video and the written steps to walk through the next steps:

This third topic walks you through the steps to add an icon to the skill, add the bot as a skill, and enhance and publish it to the skill catalog:

  1. Optional: Add an icon to the skill
  2. Import the bot as a skill
  3. Enhance the bot skill
  4. Publish the bot skill

Optional: Add an icon to the skill

Optionally, you can add an icon to better identify the bot skill in the skill catalog. By default, imported skills don’t have icons that are attached to it, so you need to add it manually in the bot OpenAPI file.

To add an icon to the bot_skill-openapi.json file, open it and add the following code for x-ibm-application-icon into the info section. Your info section must look like the following code sample:

info:
  title: bot_skill
  description: Bot skill
  version: 1.0.0
  x-ibm-application-icon: <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 48 48"
    style="enable-background:new 0 0 48 48;" xml:space="preserve" with="48" height="48"><style
    type="text/css">.st0{fill:#010101;stroke:#010101;stroke-miterlimit:10;}</style><polygon
    class="st0" points="40.69,28.59 37.09,32.27 27.25,42.34 27.44,46.93 32.46,46.57
    42.29,36.5 45.89,32.82 "/><g><path class="st0" d="M37.59,12.57c0-1.16,0-2.3,0-3.43c0-1.8-1.63-3.32-3.57-3.32c-1.13,0-2.25,0-3.37,0c-0.09,0-0.19,0-0.31,0V0.74h-3.61v5.05h-5.45V0.75h-3.63v5.07h-0.98c-0.88,0-1.75,0-2.63,0c-2.04,0-3.64,1.5-3.64,3.41c0,1.04,0,2.08,0,3.12c0,0.08-0.07,0.16-0.1,0.24H6.8v3.38h3.6c0,0.11,0,0.2,0,0.29c0,2.17,0,4.34,0,6.5c0,0.96,0.4,1.76,1.13,2.41c0.7,0.62,1.54,0.93,2.51,0.92c0.59,0,1.18,0,1.8,0v3.38c-0.31,0-0.58,0-0.84,0c-2.28,0-4.57,0-6.85,0c-0.47,0-0.95-0.01-1.42,0c-1.14,0.01-2.06,0.45-2.78,1.26c-0.69,0.78-0.87,1.71-0.79,2.68c0,0.82,0,1.64,0,2.46c0,0.38,0,0.76,0,1.12c0,0.38,0,0.76,0,1.12c0,0.36,0,0.72,0,1.08c0,0.36,0,0.72,0,1.08c0,0.43,0,0.85,0,1.28c0,0.11,0,0.2,0,0.31l0,0v4.06l0,0v0.14c0,0.32,0,0.65,0,0.97c0,0.15,0.04,0.21,0.22,0.21c1.07,0,2.13,0,3.2,0c0.17,0,0.22-0.07,0.22-0.21c0-0.31,0-0.61,0-0.92c0-0.34,0-0.69,0-1.03l0,0l0,0l0,0c0-0.31,0-0.61,0-0.92c0-0.1,0-0.19,0-0.28v-2.02l0,0c0-0.07,0-0.14,0-0.21c0-0.43,0-0.85,0-1.28l0,0c0-0.34,0-0.68,0-1.03c0-0.36,0-0.72,0-1.08c0-0.36,0-0.72,0-1.08c0-0.4,0-0.78,0-1.18c0-0.27,0-0.54,0-0.82v-2.35c0.16,0,0.27,0,0.37,0c1.47,0,2.94,0,4.41,0c1.91,0,3.83,0,5.75,0c0.92,0,1.85,0,2.76,0c1.83,0,3.64,0,5.47,0c0.99,0,1.99,0,2.98,0h3.62v-6.75c0.59,0,1.14,0.01,1.68,0c0.35-0.01,0.72-0.02,1.05-0.11c1.29-0.34,2.16-1.09,2.55-2.3c0.06-0.32,0.15-0.63,0.16-0.95c0.01-2.17,0-4.33,0-6.5c0-0.09,0-0.18,0-0.3h3.61v-3.38L37.59,12.57L37.59,12.57z
    M28.51,29.49h-3.38c-1.75,0-3.51,0-5.26,0c-0.11,0-0.24,0-0.37,0V26.1h1.79c2.29,0,4.59,0,6.88,0c0.11,0,0.22,0,0.35,0L28.51,29.49L28.51,29.49z
    M33.97,11.92c0,0.63,0,1.26,0,1.89c0,2.28,0,4.54,0,6.82v2.1c-0.13,0-0.24,0-0.34,0c-2.58,0-5.16,0-7.73,0c-0.11,0-0.22,0-0.33,0c-1.22,0-2.44,0-3.66,0c-1.34,0-2.68,0-4.02,0h-3.84c0-0.13,0-0.22,0-0.32c0-2.02,0-4.03,0-6.04c0-0.11,0-0.2-0.01-0.31c0-2.18,0-4.35,0-6.53c0-0.1,0-0.2,0-0.35h6.1c0.79,0,1.57,0,2.36,0c2.69,0,5.39,0,8.08,0c0.11,0,0.22,0,0.33,0h3.09V11.92c0-0.01,0.09,0.04,0.12,0.07C34.06,11.96,34.01,11.94,33.97,11.92L33.97,11.92z"/><path
    class="st0" d="M17.67,15.94h3.59v-3.35h-3.59C17.67,12.59,17.67,15.94,17.67,15.94z"/><path
    class="st0" d="M26.73,15.95h3.59v-3.35h-3.59V15.95z"/></g></svg>
  x-ibm-annotations: true
  x-ibm-application-id: bot_skill
  x-ibm-application-name: Bot skill

For more information about how to use your own custom icon, see Adding icon to app.

Import the bot as a skill

  1. Log in to Orchestrate and from the menu Menu, select Skills and apps.
  2. In the Add skills page, select From files.
  3. Click Drag and drop files here or click to upload, and select the bot_skill-openapi.yml file.
  4. Click Next.
  5. Select the Create an I9 form skill, and click Add.

You can now see your newly added skill on the Skills page.

Enhance the bot skill

To enhance the bot skill, do the following steps:

  1. In the Skills page, locate the Create an I9 form skill.
  2. From the menu overflow menu next to the bot skill, select Enhance this skill.
  3. From the Name tab, in the Description field, enter Collect passport data and fills the I-9 form..

Before you test and publish the bot skill to the skill catalog, you can also change fields' labels, add fields' descriptions, and add phrases as part of your enhancement.

Optional: Change fields' labels

Change fields' labels to provide texts that inform what kind of information that input and output fields expect.

From the Enhance the “Create an I9 form” skill page, click the Input tab to change the input field's label. For the passportFileName input, in Provide the Label for input parameter passportFileName, enter "Passport file name" as a label.

Next, click the Output tab to change the output fields' labels. For the outputs, click Edit response, and click Table. Enter the following values as labels in the Add header field:

  1. For output.lastName, enter "Last name".
  2. For output.firstName, enter "Fist name".
  3. For output.operationStatus, enter "Operation status".
  4. For output.operationStatusMessage, enter "Operation message".
  5. For output.filledI9FormPath, enter "I-9 form file path".

Optional: Add fields' descriptions

Add fields' descriptions to provide texts that help understanding what values that input fields receive and output fields return.

  1. From the Enhance the “Create an I9 form” skill page, click the Input tab to change the input field's description.
  2. For the passportFileName input, expand Edit response, and click Single-line text.
  3. In Text, enter "Enter the passport file name without its extension." as a description.

Add phrases

Add phrases to the skill to help users to find and start skills in the Orchestrate chat.

From the Enhance the “Create an I9 form” skill page, click the Phrases tab, and add the following phrases to the bot skill:

Create an I9 form.
Fill I9 form with my passport data.
Can you fill the I-9 form with passport data?

Publish the bot skill

After you enhance the bot skill, it's time to publish it. Click Publish to publish the bot skill to the skill catalog.

Connecting and running the bot skill

The following video shows how to connect the bot skill to the skill set and run it. It is an overview of the written steps. You can use both the video and the written steps to walk through the next steps:

This fourth topic walks you through the steps to connect the bot skill, add it to the skill set, and run the bot skill.

  1. Connect to the bot skill
  2. Add the bot skill to skill set
  3. Run the bot skill

Connect to the bot skill

  1. Log in to Orchestrate.
  2. From the Chat page, click Add skills from catalog.
  3. In All Apps, click Bot skill.
  4. Click Connect app.
    1. In Username, enter your IBM RPA access user.
    2. In Password, enter your IBM RPA access password.
  5. Click Connect app.

Add the bot skill to skill set

From the Bot skill skill page, click the Create an I9 form skill, and click Add skill to add the bot skill to skill set.

Run the bot skill

  1. From the Chat page, you can click the Create an I9 form skill or ask for Create an I9 form in the chat.
  2. In the input parameter, enter the passport file name, for example: Kamilla Vitia Campo.
  3. Click Apply.

Wait for the skill set response. It returns a form with the output values that the bot generates from the task.

Tip: You can check the logs of the bot's jobs on the IBM RPA Control Center. For more information, see Viewing jobs of a bot 🡥.

Sample OpenAPI specification for the bot

Copy the following OpenAPI specification for the bot:

openapi: 3.0.1
info:
  title: bot_skill
  description: Bot skill
  version: 1.0.0
  x-ibm-annotations: true
  x-ibm-application-id: bot_skill
  x-ibm-application-name: Bot skill
servers:
- url: https://regionapi.wdgautomation.com/v2.0/workspace/00000000-0000-00000-0000-00000000000/projects/bot_skill/bots/
paths:
  "/create_an_i9_form":
    post:
      summary: Create an I9 form
      operationId: create_an_i9_form
      parameters:
      - name: callbackUrl
        in: header
        description: The URL to send the result of the operation to
        schema:
          type: string
          format: uri
      requestBody:
        description: Bot intended to collect passport data and fills the I-9 form.
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/create_an_i9_form_input"
      responses:
        '202':
          description: Request accepted
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/acknowledge_asynchronous_request"
        '400':
          description: The request contains invalid parameters, or they are missing.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/create_an_i9_formException"
        '404':
          description: The requested resource does not exist.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/create_an_i9_formException"
        '409':
          description: The request cannot be processed because of one ore more conflicts.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/create_an_i9_formException"
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/create_an_i9_formException"
      callbacks:
        postResponse:
          "{$request.header.callbackUrl}":
            post:
              requestBody:
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        output:
                          "$ref": "#/components/schemas/create_an_i9_form_callback_output"
                        runtimeException:
                          "$ref": "#/components/schemas/create_an_i9_form_callback_runtime_exception"
              responses:
                '202':
                  description: Output received successfully.
                '500':
                  description: Internal server error.
                  content:
                    application/json:
                      schema:
                        "$ref": "#/components/schemas/create_an_i9_formException"
components:
  schemas:
    create_an_i9_form_input:
      type: object
      properties:
        passportFileName:
          type: string
      x-ibm-parameter-wrapper: true
    create_an_i9_form_output:
      type: object
      properties:
        operationStatusMessage:
          type: string
        lastName:
          type: string
        filledI9FormPath:
          type: string
        operationStatus:
          type: string
        firstName:
          type: string
      x-ibm-response-wrapper: true
    create_an_i9_form_callback_output:
      "$ref": "#/components/schemas/create_an_i9_form_output"
    create_an_i9_formException:
      type: object
      properties:
        code:
          type: string
          description: Exception code or Message ID of the exception.
        message:
          type: string
          description: Message text of the exception.
        message_parameters:
          type: array
          items:
            type: string
          description: Message text parameters of the exception.
      x-ibm-response-wrapper: true
    create_an_i9_form_callback_runtime_exception:
      "$ref": "#/components/schemas/create_an_i9_formException"
    acknowledge_asynchronous_request:
      type: object
      properties:
        jobId:
          type: string
          description: Job id assigned to request.
        project:
          type: string
          description: RPA project containing bot.
        botName:
          type: string
          description: Bot name.
        status:
          type: string
          description: Status of bot invocation.
      description: Request accepted
      x-ibm-response-wrapper: true
  securitySchemes:
    passwordGrant:
      type: oauth2
      description: Password grant authorization.
      flows:
        password:
          tokenUrl: https://regionapi.wdgautomation.com/v1.0/token?tenantId=00000000-0000-00000-0000-00000000000
          scopes: {}
security:
- passwordGrant: []

Parent topic:

Tutorials