Creating entity extraction model using Ruta script
6 Tasks
20 mins
Beginner
Pega Customer Decision Hub '24.2
English
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.
Challenge Walkthrough
Detailed Tasks
1 Test the chatbot
- On the exercise system landing page, click Launch Pega Infinity™ to log in to App Studio.
- Log in to App Studio as an application developer:
- In the User name field, enter NLPApplicationDeveloper.
- In the Password field, enter rules.
- In the navigation pane of App Studio, click Channels to view the list of current channels.
- In the Current channel interfaces section, click the icon that represents your existing Airline Digital Messaging channel.
- 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.
- Turn on the Show analysis switch to see the details.
- Click Yes.
- 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.
- 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
- Log in to Prediction Studio as a data scientist:
- In the User name field, enter NLPDataScientist.
- In the Password field, enter rules.
- On the Predictions landing page, click Airline to open the prediction workspace.
- Click the Models tab.
- In the Entity section, click System Entities to inspect it.
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.
- In the upper-left corner of the entity model details, click Back to return to the Models tab.
- In the Entity section, click Add model to begin creating the entity extraction model.
- In the Add model dialog box, select Create a new model.
- In the Model name field, enter Airline_entities.
- Click Create.
- In the upper-right corner of the Airline prediction workspace, click Save to save the entity extraction model.
3 Create a RUTA-based entity
- Click the Outcomes tab.
- In the Outcomes section, click the Entities tab.
- In the upper-right corner of the list of entities, click Create entity to begin creating the RUTA-based entity.
- In the New entity dialog box, in the Entity name field, enter ticket_number.
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.
- Click Create.
- Click the RUTA tab.
- Select the Enable RUTA checkbox.
- In the Rulescript editor, enter
CAP{REGEXP("..")}NUM{REGEXP("...") -> MARK(EntityType,1,3)};
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. - Click Save to close the New entity window.
- In the New entity dialog box, in the Entity name field, enter ticket_number.
- 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
- In the upper-right corner of the Airline prediction workspace, click Test.
- 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.
- Click the Entity tab.
- Confirm that in the Value column, the test detects AA562 as a ticket_number entity.
- Close the Test prediction dialog box.
- 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
- Log in to App Studio as an application developer:
- In the User name field, enter NLPApplicationDeveloper.
- In the Password field, enter rules.
- In the navigation pane of App Studio, click Channels to view the list of current channels.
- In the Current channel interfaces section, click the icon that represents your existing Airline Digital Messaging channel.
- In the Content section, in the cancel ticket row, click the Gear icon.
- In the Response configuration dialog box, click the Entities extraction tab.
- Click Add mapping to enable the chatbot to export the extracted entity in the created case.
- In the Entity list, select ticket_number.
Note: This entity is the ticket_number entity that the Data Scientist creates.
- In the Map to case field list, select ticket_number.
Note: A System Architect already created the ticket_number case property.
- Click Submit.
- In the upper-right corner of App Studio, click Save to save the configuration.
6 Test the trained chatbot
- 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.
- Turn on the Show analysis switch to see the details.
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.
- Click Yes.
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.
- Verify that the chatbot confirms the case routing.
- In the upper-right corner of App Studio, click Save to save the results of the interaction.
- 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.
Want to help us improve this content?