I am trying to create a custom slot type to hold the user response for yes / no values but it looks like Lex does not recognize Yes, No or Sure as input on my custom slot type. Are there limits with slot types on what values should we use?
I was hoping to use Lex as a way to solve basic helpdesk problems before forwarding a user on to a human. My questions are things like "Have you turned it off an on?", which I'm expecting a "yes/no" response.
It seems like Lex is unable to understand these answers.
I found a hacky solution.
Within your Lambda function, continuously respond with ConfirmIntent and check intentRequest.currentIntent.confirmationStatus for Confirmed and Denied. State can be managed through a slot parameter or outputSessionAttribute (e.g. incrementing an integer).
This feels like it's breaking the intended flow process of Lex, but it gets the job done.
Please post an answer if you think there is a better way
You should be able to use the built-in AMAZON.YesIntent and AMAZON.NoIntent for these.
Related
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.
You can create your own Yes/No custom slot type in the Lex Console.
I've built one as an example 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.
In AWS Lex, I am using the default AMAZON.Country as a slot type.
However, when I interact with the test bot, I can enter any value (for instance "I don't know") and the JSON when I inspect the response says that the value for 'country' is "I don't know".
The purpose of a slot type, is that it limits the answers to existing country names. Not some random sentences. Any idea why I don't get the expected behaviour?
"The purpose of a slot type, is that it limits the answers...."
That is not actually true and is a common misconception when starting to develop with Lex.
Experience has taught us that the main purpose of slot types is simply to improve input recognition and fill the slot with what is most expected or desired but it does not limit the values that can fill the slot.
This is why we Lex developers also write parsing and validation code in Lambda to double check the slot values or the inputTranscript ourselves.
It might seem like Lex should do a better job of this for you, (I think we all start out assuming that) but once you start doing your own parsing/validating, you realize how much more control you actually have to make your bot smarter and more natural.
Documentation
Amazon Lex Built-In Slot Types refers Lex developers to Alexa docs.
Amazon Lex supports built-in slot types from the Alexa Skills Kit.
...see Slot Type Reference in the Alexa Skills Kit documentation
There is a warning message in Slot Type Reference in Alexa Skills Kit:
Important: A built-in slot type is not the equivalent of an enumeration. Values outside the list are still returned if recognized by the spoken language understanding system. Although input to the 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.
I have an important question, at the moment i am writing my last essay before starting with my bachelor thesis. It is about voice apps, which includes the alexa skills for sure.
But i need some informations about the word tolerance of the utterances. And I was not able to find some information on the internet yet. Does Alexa only recognize the utterances typed in by the developer or does Alexa uses machine learning like Google Assistant to learn about new utterances ? It is really important for my essay. So I would be very happy if you can help me with this question.
Thank you!
Alexa also recognize slightly different sentences than what you defined as utterances. But if your intent is matched also depends on how many intents you have and how similar they are.
So what happens on Amazon side is behind the scenes and I don't think they use machine learning to get your utterances to intent connection right. Because you would need to train the algorithm somehow what is right and what was a wrong connection from phrase to intent.
In their documentation they suggest to use as many utterances as possible:
It is better to provide too many samples than to provide too few
https://developer.amazon.com/de/docs/custom-skills/best-practices-for-sample-utterances-and-custom-slot-type-values.html
It will be too difficult to develop an alexa app if you need to configure all the possible variations of intent. Alexa learns from the phrases that you provide for an intent and uses machine learning to not just recognize the intents that you have configured but also the subtle variations too.
You can easily verify this by setting up a basic alexa app and testing it on online simulator.
Based on what I saw using the echo device to test the skill and not only the online simulator (they are way too different, so be sure to test the skill with the real device because the behaviour is completely different between simulator and echo) I think that yes, Alexa use ML to understand what you have say to "enforce" the understanding into something that you have put into the slot.
This is a strange behaviour, because yes, you can say something different to fill the slot but there is no guarantee that Alexa will understand correctly what you have say and will trigger the correct slot.
You can try this behaviour simply putting some random or non-real word into the slots. If you say to Alexa something similar to that word, even if it doesn't exists, you will get a match, but if you say something that is completely different, there is no guarantee that the intent will be triggered.
(eg. if you put in the slot the word "blues", even if you say "blue" Alexa try to enforce her understanding into "blues". Or even better, try putting a completely random string like "asdajhfjkak" and say to Alexa something that is similar to that and you will get a match)
I'm required to create a Amazon Skill Kit to open a ticket in our ticketing tool.
By looking at the examples for Amazon Skill Kit, I couldn't find a way of accepting the free form text as input. Other option is by creating a custom slot with all probable set of inputs as custom slot inputs.
But in my case, all i have to do is capture the full content of user input to log it somewhere in the ticket which is very unlikely to expect the probable utterances before hand.
Correction to my comment... I, and others, may be misunderstanding the deprecation of the AMAZON.LITERAL. I found that custom slots still pass through literal content that did not match the predefined entries. If you have a custom slot with the entries "Bob" and "John" and I say "Samuel" my skill is still sent "Samuel". Which seems identical to previous AMAZON.LITERAL behavior. (AMAZON.LITERAL required you to provide example utterances, just as custom slots require to provide example utterances, so it seems only a difference in definition, not function.)
As you think about what users are likely to ask, consider using a built-in or custom slot type to capture user input that is more predictable, and the AMAZON.SearchQuery slot type to capture less-predictable input that makes up the search query.
You can read more here
To get the value in your application you will have to this
event.request.intent.slots.IntentName.value
Update: This is no longer possible as of October 2018.
AMAZON.LITERAL is deprecated as of October 22, 2018. Older skills
built with AMAZON.LITERAL do continue to work, but you must migrate
away from AMAZON.LITERAL when you update those older skills, and for
all new skills.
You can use the AMAZON.LITERAL slot type to capture freeform text. Amazon recommends providing sample phrases, but according to this thread, you may be able to get away with not providing them.
Is there any method to identify from which source an API is called? source refer to IOS application, web application like a page or button click( Ajax calls etc).
Although, saving a flag like (?source=ios or ?source=webapp) while calling api can be done but i just wanted to know is there any other better option to accomplish this?
I also feel this requirement is weird, because in general an App or a web application is used by n number of users so it is difficult to monitor those many API calls.
please give your valuable suggestions.
There is no perfect way to solve this. Designating a special flag won't solve your problem, because the consumer can put in whatever she wants and you cannot be sure if it is legit or not. The same holds true if you issue different API keys for different consumers - you never know if they decide to switch them up.
The only option that comes to my mind is to analyze the HTTP header and see what you can deduce from it. As you probably know a typical HTTP header looks something like this:
You can try and see how the requests from all sources differ in your case and decide if you can reliably differentiate between them. If you have the luxury of developing the client (i.e. this is not a public API), you can set your custom User-Agent strings for different sources.
But keep in mind that Referrer is not mandatory and thus it is not very reliable, and the user agent can also be spoofed. So it is a solution that is better than nothing, but it's not 100% reliable.
Hope this helps, also here is a similar question. Good luck!