Hello guys, welcome to the 13th session of create custom Alexa skill using AWS lambda function tutorials for beginners. In previous session we have created new skill project as CLA. In this session we will understand the coding structure of lambda and modify it. It is lambda function that created via ask CNI. NET understood core is written here. Your Alexa SDK core module was imported, then created several handlers that collapse all for better readability.
Yet created custom Skill Builder. Using add request handlers macker register each handler the error handler is a special kind of handler so it was registered using an error handler smarter and call lamda method to create lambda function that is expand launch Request Handler it contains two methods can handle and handle both of them will receive handler input from parameter. It contains JSON data sent by Alexa as well as some helper classes and methods can handle method we need to return a boolean value. If it was true then code written in handle method will execute. In the previous session, we have used event dot request dot type to check whether the request is launched request or not. Here it is saying we got event data in request and below.
So, if it is launched request, then execute this code. Responsible there is helper class that allows us to build a response. It supports method chaining, so call each method like this First of all, called speech method to set output speech in response to the prompt method is used to add reproach in response. Using rich sample card method, we can create a simple card and get response method is used to obtain Jason for this response and return it. Here we do not need to care about JSON response builder will automatically know I will update this lambda function to response same as our old function. For this first of all, I am going to update launch Request Handler.
Update message text we do not want to generate card and launch request let us create a new handler name. Hello intent halyard create can handle method Whether request type is intent request and intent name is Hello intent. Create handle method that takes to be set in output speech and reproved. Use response builder to set output speech and replace text and call get response matter. No, we must need to call this method at the end and also return it. Otherwise Alexa will not get response for make file for proper intent.
Now create a handle for display greetings intent. Let us copy this Get in 10 minutes. Here we need to obtain the value of person name from this slot and then we need to add it in session attributes. Here I will use attributes manager it provides getter and setter methods for manipulating attributes in session or Dynamo dB. We will use Dynamo DB in upcoming sessions. First of all an existing session attributes using gap session attributes mapping of attributes manager, net asset value and person name even within this area.
Now we need to update session attributes for this use set session attributes method and pass array Update text for output speech. Note that here I have not entered speak that before and after message response builder will automatically added and outputs page type will be set to SSL for all text. Here we do not need to ask for return. However, we also do not want to end the session for this use, which should add session method. It will update the value of short and fashion intervals. Let's copy this highlight and create a highlight for fabric language a bit intending I'm copying those lines from our existing lambda function to opt in language name and ID.
That is create a variable for personally. That guest user as default value. session attributes contains person name that obtain its value and update output speech. I'm using string interpolation. I prefer to use this over called Getting each string for better readability. Let us add missing bracket and format this again.
Now we need to register those all handlers in our Skill Builder. That's it, our lambda function was created. Now we need to create interaction model. You can manually build Jason data for interaction model. But now I'm copying Jason from our existing key and change invocation name to secondary. This will include three default intent.
Hello intent, and its sample utterances display greetings with slots and utterances. Private language also contains slots and it renting. Here is custom slot type. We have created you can also modify these letters and one more value in this slot type for to be let us say all five. Let us see what we have learned in this session. In this session we have learned how to use can handle and handle method for creating our own handler.
Here is launch Request Handler in which we have just simply use speak and repro matters. Here is a Hello intent handler, in which we have checked for request type and enter name in the can handler method. In handler method, again, we have used speak and the prompt. In display greeting handler, we have obtained slot value obtain existing session attributes using attribute manager. We start a new attribute in it and we use that session attribute method to update it. We can also set ssms in output speech.
Richard and session updates you session in the fabric language handler we have obtained slot value person name from the session and generate a simple response depot method factory from speech, which should end session method that should end session value to null or false or true this simple card method renders a simple card with the following title and content with standard card method renders a standard card with the following title content an image with link account card method renders a link account card with ask for permissions consent cards matter Brenda's asked her permission consent card at delegate effective method as a dialogue delegate direct you to response and elicit non directive methods as a dialog elicit slot direct you to response and confirm slots. Let's do let's have a dialogue on from slot directive to response and confirm intent directive methods exit dialogue confirm intent directive to response.
As audio player play digital method as an audio player play detective and audio plays complementary method as an audio player stop directly. Add audio PSTN to track your method as an audio player to cue directly add video app launch direct method as a video I'd like you to play a video. I'd like to record as a hint. Thanks for watching this video. If you have any doubts, please feel free to contact me. Have a nice day.