In the realm of enterprise operations, unique identifiers play a crucial role in retrieving information related to accounts or transactions. For instance, airlines utilize confirmation codes to access itineraries, while insurance companies rely on policy IDs to fetch policy details. In customer service settings, these identifiers form the foundational layer of information needed to address customer inquiries. Typically, identifiers consist of a mix of letters and numbers, adhering to a specific format often characterized by a fixed length with designated positions for letters and digits.
Previously, the process required the development of a custom slot type that encompassed a wide range of potential values. However, as of now, the AMAZON.AlphaNumeric slot type in Amazon Lex allows for the effective capture of such inputs within your bot. This slot type can handle various combinations of letters and numbers, and you can enhance its functionality by implementing validation checks through a custom slot type. By applying a regular expression (regex) to the AMAZON.AlphaNumeric slot type, you can enforce specific input patterns. This article will illustrate how to utilize the AMAZON.AlphaNumeric slot type for capturing alphanumeric data and restricting inputs to a defined format.
Constructing a Bot
This article presents a conversational model for a bot:
User: I wish to reschedule my flight. Agent: Certainly. Can you provide the confirmation code? User: ABC12D Agent: Thank you. I see you're booked on the 6 AM flight to Seattle tomorrow. What would you like to change to? User: I want to switch to next Monday. Agent: What time would you prefer to travel? User: 8 AM. Agent: Absolutely. Let me handle that change. For verification purposes, could you provide the last four digits of the credit card number? User: 1234. Agent: Perfect. I've rescheduled your flight for February 10 at 8 AM. Is there anything else I can assist you with? User: No. Agent: Thank you! Have a wonderful day!
To begin, create an Amazon Lex bot (named FlightReservationBot) with the following intents:
- MakeReservation – Gathers the travel date, source, and destination cities to process a reservation and deliver a booking confirmation code.
- ModifyReservation – Collects the confirmation code and the last four digits of the user’s credit card number to amend the reservation.
- CancelReservation – Requests the confirmation code to cancel the reservation.
You can use the built-in slot type AMAZON.AlphaNumeric to capture alphanumeric information, but it lacks inherent validation. To enforce validation, implement a regular expression. Create a new slot type named ConfirmationCode by extending AMAZON.AlphaNumeric. The confirmation code follows a strict format of six characters: [letter][letter][letter][number][number][letter]. For instance, ABC12D represents a valid confirmation code.
To effectively capture the confirmation code and apply the necessary validation checks, follow these steps:
- Access the Amazon Lex console and select FlightReservationBot.
- Click the plus sign next to Slot types.
- Choose to Extend slot type.
- Name the slot type ConfirmationCode.
- Provide a brief description for your slot type.
- For Regular expression, restrict the slot type to the specified six-character format by entering the expression
[A-D]{1}[A-Z]{2}[0-9]{2}[A-Z]{1}
. - Save the slot type.
Now, the ConfirmationCode slot type is ready for use in designing the ModifyReservation and CancelReservation intents for your bot, ensuring user input adheres to a valid confirmation code format.
To incorporate the ConfirmationCode slot type into the ModifyReservation intent, complete the following actions:
- Return to the Amazon Lex console and select FlightReservationBot.
- Under Intents, select ModifyReservation.
- In Slots, add a new slot named BookingConfirmationCode with Slot type ConfirmationCode and an appropriate prompt.
- Tailor the rest of the bot according to your specific use-case.
- Save Intent, Build, and Publish.
Your bot is now operational. You can test its functionality by inputting a confirmation code like ABCDE, which does not conform to the established regex pattern.
Conclusion
This article demonstrated the process of capturing alphanumeric values using the AMAZON.AlphaNumeric slot type. Further limitations on the captured slot values can be applied by providing a regular expression. For more insights, check out this excellent resource on onboarding processes at Amazon. Additionally, for further reading, this blog post offers additional perspectives on the subject, while Chvanci provides authoritative information on this topic.
Leave a Reply