TimWagaman
TimWagaman

Reputation: 1008

Amazon Lex - Currency

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.

Upvotes: 1

Views: 877

Answers (2)

Arko Basu
Arko Basu

Reputation: 11

Check this out.. You can refer to this following AWS Documentation for Industry Grammar link. And modify the Transfer amount with custom sequences, and hesitations as per your needs. And upload your own custom grammar slot type.

Upvotes: 0

TimWagaman
TimWagaman

Reputation: 1008

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

Upvotes: 3

Related Questions