The Amazon Lex chatbot framework offers to use custom slot types. However, the mechanism is to provide an array of values that will be validated. But I want a custom validator that e.g. checks if the input is in a database.
Ideally, I want to develop an AWS lambda hook that receives the input parameter and then executes some program that returns the either well-formated slot type or gives an error if the input was not valid. Anyone an idea?
AWS exposes an API to dynamically create slot types, and updating the LEX bot. (see: http://docs.aws.amazon.com/lex/latest/dg/API_PutSlotType.html, and http://docs.aws.amazon.com/lex/latest/dg/API_CreateSlotTypeVersion.html)
In theory you could dynamically change this list when your data base has an update (may run into rate limiting issues though.)
However it does not appear that custom slot types limit valid responses like you think they do: http://docs.aws.amazon.com/lex/latest/dg/gl-guidelines.html
Specifically this bit:
Note the following about how Amazon Lex captures slot values from user utterances:
Amazon Lex uses the enumeration values you provide in a slot type definition to train its machine learning models. Suppose you define an intent called GetPredictionIntent with the following sample utterance:
"Tell me the prediction for {Sign}"
Where {Sign} is a slot of custom type ZodiacSign. ZodiacSign has 12 enumeration values (Aries through Pisces). From the user utterance "Tell me the prediction for ..." Amazon Lex understands that what follows is a zodiac sign.
If the user says "Tell me the prediction for earth", Amazon Lex infers that "earth" is possibly another ZodiacSign and passes it to your fulfillment activity. Therefore, your fulfillment activity must validate the slot values.
In other words, it appears to not be a enumeration list that is enforced.
Another example of the docs saying this: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/migrating-to-the-improved-built-in-and-custom-slot-types#literal
A custom slot type is not the equivalent of an enumeration. Values outside the list may still be returned if recognized by the spoken language understanding system. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. Your code still needs to include validation and error checking when using slot values.
So even if you did dynamically create this custom slot type, it would only make the input somewhat lean in the direction of your predetermined options. Not restrict it to them.