'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:
- Eight Hundred Seventy Two Dollars and Seventeen Cents (872.17)
- Seventy Four Dollars (74.00)
- Sixty Five Cents (0.65)
Any help will be greatly appreciated.
Solution 1:[1]
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
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TimWagaman |
| Solution 2 | Arko Basu |
