3

I want to make custom slots that accepts any and all entries as long as those entries follow a certain regex pattern, eg:any number of alphabets or numbers but without a space in between. Can anyone tell me if there is a way in amazon lex to achieve it? Also, if I want to take a certain type of data, say, email ids, but want to give the user option to give any number of email ids (more than one), what is the way to do that.

I am new to Amazon Lex and any suggestions would be appreciated.

Kanika Agarwal
  • 191
  • 1
  • 4
  • 9
  • 1
    You'll have to handle both of these things in your Lambda function. Have Lex get the data you want as best you can, but then your regex will further handle the slots or even the whole user input from your Lambda function. Asking for suggestions is usually closed as too broad of a question. So search around, try it out, then come back and ask more specific questions if you have problems. – Jay A. Little Feb 11 '18 at 02:51

1 Answers1

0

Make a slot in Lex console in your intent but do not tick as required, and give any type as slot type.
Now in lambda code, first set the slot to null and then parse the inputText using regex and assign the correct value to the slot.

This way both of your problems will be addressed.
Hope it helps. Let us know if you run in any problems.

sid8491
  • 6,622
  • 6
  • 38
  • 64
  • The problem i am facing with setting any slot type is that the information is not identified well. eg: for intent: change slot1:a slot2:b, if i say change a to b, Lex identifies slot1: a to b, and asks for slot2. – Kanika Agarwal Feb 15 '18 at 08:33
  • @KanikaAgarwal i do not understand, could you please give a proper example and use-case. – sid8491 Feb 15 '18 at 10:02
  • If my Usecase is to make changes in a database. I am using the lex chatbot for that purpose. This is a sample command: || user: update foo to bar in dataset.|| bot : what do you want to update to?|| user : bar|| bot : intent: update ; slot1: foo to bar ; slot 2 : bar ; ready for fulfillment|| .............................do you see my problem? – Kanika Agarwal Feb 15 '18 at 11:14
  • @KanikaAgarwal `slot1` should only contain `foo` instead of `foo to bar`, this can be done both via Lex console an regex way. even if it is catching `foo to bar` in `slot1` you can extract `foo` from it and you are already getting `bar` from `slot2`. – sid8491 Feb 15 '18 at 18:52
  • How can I do it the Lex console way?I have about 10 types of intents and I am getting this error with most of them where multiple words are captured in a slot (when I only want one word).Thanks for all your suggestions btw – Kanika Agarwal Feb 16 '18 at 05:22
  • @KanikaAgarwal yes, Lex is not so intelligent to capture what we desire, still you can try to train the slot using lots of examples. better way is to do it in Lambda function. I also do not depend on Lex and try to do almost everything in Lambda only. sorry if i mis-guided you earlier. – sid8491 Feb 16 '18 at 07:56