Hello Hi. Welcome to the 32nd session of create custom and accessing using AWS lambda function tutorials for beginners. In this session we will learn how to manage state and use built in intense like yes and no. Let us open Visual Studio code. Here I will create a new skin for that with name for STEM. In this case, the user may say my name is nice or I want to visit this country after this visit confirm the values.
For this we will use building intents for yes and no instead of slot confirmation directly. When the user says yes, with an attorney you say yes in person name or country as per intent. So we need to open the model file. Create a new index with the name person name, intent. It has one slot with name person name and type will be amazon.com. Here the user may say my name is personally or I am personally so create a new intent for a country with named country meaning it can serve as one slot if the country name and type will be amazon dot country end user may say I want to visit country we also need to add intense for yes and no so light is at Amazon dot yes And Amazon does not know that for baking integrity do not need to provide a sample Amazon already added those samples that is modify lambda function update speech text of lunch requests collapse all functions for a factor of three personally intent handler obtain value from causing names not in ALEKS our core SDK, we need to add over state details.
Session manually for these that is often session attributes. I personally in the state will use the attribute later to identify the state of our skill. Set those attributes can be simple response we do not need to copy this and update intent name for country Often country names loss statement the country that is correct this typo and update this page text to now we need to create new vendors for yes and no intend for both states. Let us start with yes in 10 for personally we need to check for the state. So we need to return session attributes jacket, it is yes intent and state is personally. session attributes.
After receiving a request to this handler we need to change state and changing the value of undefined. The reason for this is that if we are not doing these, then when user says yes in all subsequent requests, it will call this handler and generate a simple message with speech you say yes in personally save those attributes in fashion. Generate simple message with the text you say yes in personally. And we don't want to add a session copy this handler you need to know this way handle for knowing. Update message change properties. Let us copy both of those handlers.
Big internal condition and message health, condition and message text. Here we have managed state. Now we need to register all those six handlers that we have created defining the price key You're I need to change the working directory to fourth demo. Let us test it in simulator. refresh this page to get our ski open for them. Got our first demo?
Welcome to the fourth demo skill. So my name is Emma Sorry, I can't understand the command. Please say again. Here we got an error. That is open cloud watch to find the issue. Select lambda function that you have created.
Here, our lambda is not listed. So we need to refresh this list cloudwatch takes some time to update logs. Your editing session attributes is not function. It seems perfect. Okay, you have spent taking action Find all occurrences and replace it with correct scenes a file and update lambda function. refresh this page that our fourth demo Welcome to the fourth demo skill.
Same message. Your name is Emma. Right here you can see that session contains person named state. letter saying yes. You said yes in person name used to be called personal message. Let me send this message again.
Your name is Emma, right and this time right No. You said no in person name. This time I will use country name. You want to visit Japan? Right? And that is saying yes.
You said yes in country name. We caught a proper response. Now let's see what we are learning this session. To manage state. We need to use session attributes and the state where the user is in our scheme. Here we have used wilting yes in gate can handle methods we can retrieve session attributes and check for state one In handle method we have set it to undefined for knowing that we have performed the same operation.
Thanks for watching this video. If you have any doubts, please feel free to contact me. Have a nice day.