2

I'm trying to create a chatbot using Amazon Lex to display results from a database. The designed conversational flow is to show 10 results at first, and then provide an option for the user to "See more results?", which would be a Yes/No question. This would give an additional 10 results from the database. I have searched through the documentation and forums on the internet, to understand a way to add this follow-up Yes/No question, and have been unsuccessful. I'm relatively new to LEX and am unable to model this conversational flow. Can someone explain this/direct me to the right documentation?

Any help/links are highly appreciated.

Sherwin
  • 49
  • 6

1 Answers1

2

You can create your own Yes/No custom slot type in the Lex Console.

I've built one as an example here: enter image description here

I named the slot type affirmation

Then I restricted a list of synonyms to equate to either Yes or No values.

This allows a user to respond naturally in many different ways and the bot will respond appropriately. All you have to do is build your Lambda handling of any slot that uses this slot type to look for either "Yes" or "No".

You can easily monitor this slot too to log any input that was not on your synonym list in order to expand your list and improve your bot's recognition of affirmations and negations.

I even built a parser for this slot in Lambda to be able to recognize emoji's (thumbs up/down, smiley face, sad face, etc.) correctly as positive or negative answers to these type of questions in my bot.

It might be surprising that Lex doesn't have this built-in like Alexa, but it's not hard to build and you can customize it easily which you cannot do with built-in slot types.


Anyway, after making this SlotType, you can create multiple slots that use it in one intent.

Lets say you create a slot called 'moreResults' and another called 'resultsFeedback'. Both would be set to use this 'affirmation' slotType to detect Yes/No responses.

Then when you ElicitSlot either of these slots in the convo, you can form the question specifically for each slot. And you can check whether the slot is filled with values 'Yes' or 'No' in your Lambda on the next response.

Jay A. Little
  • 3,239
  • 2
  • 11
  • 32
  • Thanks Jay. This is helpful for sure. I needed some information about follow-up questions as mentioned. Could you point me in that direction? – Sherwin Nov 25 '20 at 06:02
  • I thought this Yes/No question was your follow-up question you needed. Can you give an example convo that you want, and maybe what Lambda code you have to control that convo? Then I can show you how to use this custom slotType. – Jay A. Little Nov 25 '20 at 11:44
  • Sure. The user gives a search term. I show the first 10 results from search results, and then ask if they want to see more results(1st question). More results are shown on the basis of the reply(Yes/No). After the results have been shown, I need to ask for feedback whether the results were helpful or not(2nd question). This is the conversational flow that I want to model. Two follow up questions here with Yes/No answers. I do understand how you made the custom slot and it will be the way to go for me for getting the reply, but I need a mechanism to put these follow up questions to the user. – Sherwin Nov 26 '20 at 11:46
  • 1
    I see now! Ok after making this SlotType, you can create multiple slots that use it in one intent. Lets say you create a slot called 'moreResults' and another called 'resultsFeedback'. Both would be set to use this 'affirmation' slotType to detect Yes/No responses. Then when you ElicitSlot either of these slots in the convo, you can form the question specifically for each slot. And you can check whether the slot is filled with values 'Yes' or 'No' in your Lambda on the next response. – Jay A. Little Nov 26 '20 at 23:59
  • 1
    Thank you so much. This worked perfectly. Please do add this part to your answer as well. This is exactly what I needed. – Sherwin Nov 27 '20 at 12:13