Custom slot types in amazon lex without enumeration values

天大地大妈咪最大 提交于 2019-12-11 00:08:41

问题


I'm trying to build a bot to change userinfo stored in a database.

My first thought was to create two slot types like {toChange} and {newValue} where the user could say "Change my name to Peter Griffin" or "My new email is user@mail.com".

Turns out Lex can't handle these custom string inputs. I had to create a slot type for each value the user can have: {name} with AMAZON.Person, {address} with AMAZON.PostalAddress and so on and let Lambda handle the correct slots to elicit.

The problem is that Lex does not offer slot types for email or an bankingaccount number in IBAN format (nor any other format).

If I use a custom slot type with an empty enumeration list I can only enter text, not numbers. Furthermore blanks and special characterls like . and @ are not recognized and Lex asks for input again.

Is there any way to accomplish this? I thought of something like asking for the first part of the mail before the @, then to ask for the provider and lastly filling in the country code. But that is far far away from being userfriendly.

[EDIT]

During testing I found out there is no validation on Amazons side for AMAZON.PostalAddress as for now. I can literally type anything I want and it will be accepted, like lets say an email address or an account number :twinkle:

For the moment this approach works fine, but there is absolutely no guarantee it will stay this way in the future, so my question still is open.

PS: Like this I was able to follow my first approach with {toChange} and {newValue}, where the first is a custom slot type with enumation values und the latter is a AMAZON.PostalAddress slot.


回答1:


The way I did it was,
create a custom slot type like

{   "name": "emailAddressSlotType",
    "description": "see name",
    "enumerationValues": [
        { "value": "bobbySmith@yahoo.com" },
        { "value": "FreakyDonkeyLover@gmail.com" },
        { "value": "smithyBob@hotmail.com" }
    ]
}      

The enumeration values are just sample email addresses. You then need to validate it with something like a Lambda validationCodeHook.
see: this probably... i'm still working on mine



来源:https://stackoverflow.com/questions/44413621/custom-slot-types-in-amazon-lex-without-enumeration-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!