1
votes

I know that Amazon Lex does not natively support a currency slot type. However, in my situation, I need to ask a user for a dollar amount, and they need to be able to respond with a dollar amount. The dollar amount may be only cents, may have no cents, or may have dollars and cents. I am looking for ideas to accomplish this. I did see one idea to ask for dollars and cents separately, however that would not be very user intuitive. Ultimately, I want my users to be able to say the following phrases, and Lex translate it to the appropriate decimal value:

  1. Eight Hundred Seventy Two Dollars and Seventeen Cents (872.17)
  2. Seventy Four Dollars (74.00)
  3. Sixty Five Cents (0.65)

Any help will be greatly appreciated.

1
The easiest way is definitely using AMAZON.NUMBER slotType and asking for dollars and cents separately. Otherwise you will have to build your own currency language parser and deal with all the possible variations yourself which will introduce many more possibilities for error. A slight inconvenience for the user far outweighs the alternative in my opinion. But it can be done, and it would be very cool. So it may be worth it if your bot deals with money input constantly.Jay A. Little

1 Answers

1
votes

The way that I ended up implementing this was by adding an intent "DollarAmount" with a slot typed AMAZON.NUMBER for Dollars and another slot AMAZON.NUMBER Cents. Then in Lambda, I combine the values into a decimal. Utterances for the Intent are as follows:

DollarAmount {Dollars} dollars
DollarAmount {Dollars} dollars and {Cents} cents
DollarAmount {Dollars} dollars and {Cents} cents
DollarAmount {Cents} cents