Echo Dot (3rd Gen) - Smart speaker with Alexa - Charcoal

Use your voice to play a song, artist, or genre through Amazon Music, Apple Music, Spotify, Pandora, and others. With compatible Echo devices in different rooms, you can fill your whole home with music.

Buy Now

Wireless Rechargeable Battery Powered WiFi Camera.

Wireless Rechargeable Battery Powered WiFi Camera is home security camera system lets you listen in and talk back through the built in speaker and microphone that work directly through your iPhone or Android Mic.

Buy Now

Capturing and validating alphanumeric identifiers in Amazon Lex

0
131


Enterprises often rely on unique identifiers to look up information on accounts or events. For example, airlines use confirmation codes to locate itineraries, and insurance companies use policy IDs to retrieve policy details. In customer support, these identifiers are the first level of information necessary to address customer requests. Identifiers are typically a combination of letters and numbers and have a specific pattern. It is likely a fixed length with specific positions of letters and numbers. Previously, you had to create a custom slot type with a broad range of applicable values. As of this writing, you can use AMAZON.AlphaNumeric slot type in Amazon Lex to capture such inputs in your bot. This slot type can capture combinations of letters and numbers. You can extend this slot type by applying a validation check to create a custom slot type. You can apply these validation checks by specifying a regular expression (regex) on the AMAZON.AlphaNumeric slot type. This post demonstrates how to use the AMAZON.AlphaNumeric slot type to capture alphanumeric information and restrict such input to a specific pattern.

Building a bot

This post uses the following conversation to model a bot:

User: I want to reschedule my flight.
Agent: Sure. Can you provide the confirmation code?
User: ABC12D
Agent: Thank you. I see you are on the 6 AM flight to Seattle tomorrow. What would you like to change to?
User: I want to change to next Monday.
Agent: What time would you prefer to travel?
User: 8 AM.
Agent: Sure. Let me make that change. For authentication purposes, can I get the last four digits of the credit card number?
User: Yes, it’s 1234.
Agent: Excellent. I have rescheduled you for the flight departing on February 10 at 8 AM. Anything else I can help you with?
User: No.
Agent: Thank you. Have a great day!

First, build an Amazon Lex bot (FlightReservationBot) with the following intents:

  • MakeReservation – Elicits the travel date, source, and destination cities to process a reservation and return a booking confirmation code.
  • ModifyReservation – Elicits the confirmation code and last four digits of the user’s credit card number to modify the reservation.
  • CancelReservation – Elicits the confirmation code to cancel the reservation.

You can create the built-in slot type AMAZON.AlphaNumeric. Such a design helps capture alphanumeric information but doesn’t validate it. To validate, use a regular expression. Create a new slot type ConfirmationCode by extending AMAZON.AlphaNumeric. The confirmation code has a fixed format of six characters: [letter] [letter][letter][number][number][letter]. For example, ABC12D is a confirmation code.

To capture the confirmation code and enforce the necessary validation checks, complete the following steps:

  1. On the Amazon Lex console, choose FlightReservationBot.
  2. Next to Slot types, choose the plus sign.
  3. Choose Extend slot type.
    Capturing and validating alphanumeric identifiers in Amazon Lex 1
  4. For Slot type name, enter ConfirmationCode.
  5. For Description, enter a description of your slot type.
  6. For Regular expression, restrict the slot type to the six-character fixed format as specified previously by entering the expression [A-D]{1}[A-Z]{2}[0-9]{2}[A-Z]{1}.
  7. Choose Save slot type.
    Capturing and validating alphanumeric identifiers in Amazon Lex 2

You can now use the ConfirmationCode slot type to design the ModifyReservation and CancelReservation intents for your bot and make sure that the user input contains a valid confirmation code.

To add the ConfirmationCode slot type to the ModifyReservation intent, complete the following steps:

  1. On the Amazon Lex console, choose FlightReservationBot.
  2. Under Intents, choose
  3. Under Slots, add a new slot BookingConfirmationCode with Slot type ConfirmationCode with an appropriate prompt.
  4. Design the rest of the bot as per your use-case.
  5. Choose Save Intent, Build, and Publish.

Your bot is now ready to use. You can test it by providing a confirmation code such as ABCDE that does not match the pattern specified by the regular expression.

Conclusion

This post demonstrated how to capture alphanumeric values using the AMAZON.AlphaNumeric slot type. You can further restrict the slot values captured to a fixed format by providing a regular expression. For more information please refer to the Amazon Lex documentation. Try out the AlphaNumeric slot type in your bot today!


About the author

Capturing and validating alphanumeric identifiers in Amazon Lex 3Anubhav Mishra is a Product Manager with AWS. He spends his time understanding customers and designing product experiences to address their business challenges.

 

 

 



Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here