Skip to main content

Creating entity extraction model using Ruta script

6 Tasks

20 mins

Visible to: All users
Beginner Pega Customer Decision Hub '24.1 English
Verify the version tags to ensure you are consuming the intended content or, complete the latest version.

Scenario

U+ Air uses a chatbot to serve its customers. Currently, the chatbot recognizes when a customer wants to cancel a ticket, and the system automatically creates a new case and routes it to the correct work queue.

U+ Air wants to improve its chatbot further to detect airline ticket numbers in customer messages automatically. The airline ticket numbers follow a strict pattern of two letters that are followed by three digits.

U+ Air determines that using an Apache UMIA RUTA script is the best choice to detect the strict ticket number pattern. As a data scientist, create an entity extraction model that contains a RUTA based entity to implement this business requirement.

Use the following credentials to log in to the exercise system:

Role User name Password
Data Scientist NLPDataScientist rules
Application Developer NLPApplicationDeveloper rules

Your assignment consists of the following tasks:

Task 1: Test the chatbot

As an application developer, test the chatbot for the following message: I want to cancel my ticket number AA562, and note that the chatbot does not detect the ticket number.

Task 2: Create a new entity extraction model

As a data scientist, create a new entity model.

Task 3: Create a RUTA-based entity

Create a new RUTA based entity extraction model in the text prediction to meet the business requirement. The structure of the ticket number is strict: two letters that are followed by three digits.

Task 4: Test the entity extraction in the Airline prediction

Test the entity extraction in the Airline prediction and observe the results.

Task 5: Map entities in a case command

As an application developer, map the entities to a case command so that the chatbot includes the ticket number in the ticket cancellation case.

Task 6: Test the trained chatbot

Confirm that a ticket cancellation request is correctly recognized and that the ticket number is correctly extracted from the message.

 

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Challenge Walkthrough

Detailed Tasks

1 Test the chatbot

  1. On the exercise system landing page, click Launch Pega Infinity™ to log in to App Studio.
  2. Log in to App Studio as an application developer:
    1. In the User name field, enter NLPApplicationDeveloper.
    2. In the Password field, enter rules.
  3. In the navigation pane of App Studio, click Channels to view the list of current channels.
  4. In the Current channel interfaces section, click the icon that represents your existing Airline Digital Messaging channel.
    channel interfaces
  5. In the Preview console on the right, in the Type your message here text box, enter I want to cancel my ticket number AA562 to test the chatbot.
  6. Turn on the Show analysis switch to see the details.
    chatbot 1
  7. Click Yes.
  8. Confirm that the chatbot detects the cancel ticket topic with 95% confidence and runs a preconfigured Cancel a ticket case type but does not detect the ticket number as an entity even though it is provided in the first message.
    please type
  9. In the lower-left corner, click the user icon, and then select Log off to log out of App Studio.

2 Create a new entity extraction model

  1. Log in to Prediction Studio as a data scientist:
    1. In the User name field, enter NLPDataScientist.
    2. In the Password field, enter rules.
  2. On the Predictions landing page, click Airline to open the prediction workspace.
    prediction
  3. Click the Models tab.
    models tab
  4. In the Entity section, click System Entities to inspect it.
    entities
    Note: System Entities is an out-of-the-box entity extraction model that contains basic entities; you cannot modify it. New entity extraction model is required to add a new entity type.
  1. In the upper-left corner of the entity model details, click Back to return to the Models tab.
  2. In the Entity section, click Add model to begin creating the entity extraction model.
    entities list
    1. In the Add model dialog box, select Create a new model.
    2. In the Model name field, enter Airline_entities.
      add model dialog
    3. Click Create.
  3. In the upper-right corner of the Airline prediction workspace, click Save to save the entity extraction model.

3 Create a RUTA-based entity

  1. Click the Outcomes tab.
  2. In the Outcomes section, click the Entities tab.
    entities tab
  3. In the upper-right corner of the list of entities, click Create entity to begin creating the RUTA-based entity.
    1. In the New entity dialog box, in the Entity name field, enter ticket_number.
      new entity dialog
      Note: Notice that the created Airline_entities entity model is selected by default without possibility to change, because it is the only editable entity model configured in the prediction.
    2. Click Create.
    3. Click the RUTA tab.
    4. Select the Enable RUTA checkbox.
      custom tab
    5. In the Rulescript editor, enter

      CAP{REGEXP("..")}NUM{REGEXP("...") -> MARK(EntityType,1,3)};
       
      ruta rulescript
      Note: CAP{REGEXP("..")} detects capital letters with two characters. NUM{REGEXP("...") detects three-digit numbers that are followed by the previously detected letters. MARK(EntityType,1,3) means that annotations 1 through 3 are marked as the entity type. To learn more about RUTA script, go to Pega documentation page.
    6. Click Save to close the New entity window.
  1. In the upper-right corner of the Airline prediction workspace, click Save to save your changes.

4 Test the entity extraction in the Airline prediction

  1. In the upper-right corner of the Airline prediction workspace, click Test.
    1. In the Test prediction dialog box, in the text box, enter: I want to cancel my ticket number AA562, and then click Test to view the run result.
    2. Click the Entity tab.
      go to entity tab
    3. Confirm that in the Value column, the test detects AA562 as a ticket_number entity.
    4. Close the Test prediction dialog box.
  2. In the lower-left corner, click the user icon, and then select Log off to log out of Prediction Studio.

5 Map entities in a case command

  1. Log in to App Studio as an application developer:
    1. In the User name field, enter NLPApplicationDeveloper.
    2. In the Password field, enter rules.
  2. In the navigation pane of App Studio, click Channels to view the list of current channels.
  3. In the Current channel interfaces section, click the icon that represents your existing Airline Digital Messaging channel.
    channel interfaces
  4. In the Content section, in the cancel ticket row, click the Gear icon.
    gear
    1. In the Response configuration dialog box, click the Entities extraction tab.
    2. Click Add mapping to enable the chatbot to export the extracted entity in the created case.
      create command
    3. In the Select entity list, select ticket_number.
      Note: This entity is the ticket_number entity that the Data Scientist creates.
    4. In the Select property list, select ticket_number.
      Note: A System Architect already created the ticket_number case property.
    5. Click Submit.
  1. In the upper-right corner of App Studio, click Save to save the configuration.

6 Test the trained chatbot

  1. In the Preview console on the right, in the Type your message here text box, enter I want to cancel my ticket number AA562 to test the chatbot.
  2. Turn on the Show analysis switch to see the details.
    chatbot 11
    Note: The chatbot extracts the ticket_number entity and detects cancel ticket topic. The chatbot runs a pre-configured cancel a ticket case. The conversation flow is designed to ask the customer for confirmation.
  1. Click Yes.
    skipped question 1
    Note: If the customer does not provide the ticket number in the first message of the conversation flow, the chatbot requests the ticket number before proceeding. If the entity extraction model already detects the ticket number, this question is skipped.
  1. Verify that the chatbot confirms the case routing.
    bot 5
  2. In the upper-right corner of App Studio, click Save to save the results of the interaction.
  3. In the lower-left corner, click the user icon, and then select Log off to log out of App Studio.

This Challenge is to practice what you learned in the following Module:


Available in the following mission:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice