Alexa Skills Kit: Practical Chatbot Development | Nathan Glover | Skillshare

Alexa Skills Kit: Practical Chatbot Development

Nathan Glover, I love technology, I'm a maker at heart!

Alexa Skills Kit: Practical Chatbot Development

Nathan Glover, I love technology, I'm a maker at heart!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
24 Lessons (2h 27m)
    • 1. Introduction

    • 2. Windows, Mac & Linux Setup

    • 3. Where To Find Sample Code

    • 4. Alexa Skill - Interaction Model

    • 5. Alexa Skill - Lambda Handler

    • 6. Alexa Skill - Lambda Deploy

    • 7. Alexa Skill - Lambda Connection

    • 8. Alexa Skills Kit - Create Project

    • 9. Cat-a-Log - Project Architecture

    • 10. DynamoDB Management Tool - Create

    • 11. DynamoDB Management Tool - Insert

    • 12. DynamoDB Management Tool - Test

    • 13. Improving Project Structure

    • 14. Deploy and Test

    • 15. Custom Intent Slots

    • 16. DynamoDB Lookup

    • 17. Response Localisation

    • 18. Session Attributes - Name (Model)

    • 19. Session Attributes - Name (Code)

    • 20. Request & Response Interceptors

    • 21. DynamoDB Attribute Persistence

    • 22. Dynamic Responses - Timezone Awareness

    • 23. Localisation - Cleanup

    • 24. SSML Audio Clips

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

AWS Alexa, Google Home and other voice assistant devices are becoming more and more common in our interconnected world. The tech landscape rewards developers who are on the leading edge of new trends, and Alexa Skills Kit (ASK) is one of the most supported and recognised methods of developing consumer and commercial chatbots.

This course is written with the very latest and best development standards in mind. You'll learn a number of key things that will help you succeed in this fast moving field of technology.

  • Alexa Skill Creation (UI) - We'll develop an understanding of how Alexa Skills can be created and managed via the web interface

  • Ask Skills Kit (CLI) - Once we have a firm understanding, we'll write our Skills entirely as code and deploy them using ONE command!

  • DynamoDB - Data will be stored and retrieved from an instance of DynamoDB that we'll create and manage from code as well.

  • DynamoDB Persistence - Using the DynamoDB persistence adaptor in Alexa Skill Kit we'll save and retrieve user attributes to manage state between the Alexa skill life-cycle

All this plus most importantly you will develop best practices and have a number of perfect example applications by the end of the course that you can use as a reference for future projects.

Meet Your Teacher

Teacher Profile Image

Nathan Glover

I love technology, I'm a maker at heart!


Creator of ALL things AWESOME!

Bachelor of Technology with a Major in Computer Systems and Networking, I've always had a strong desire to make amazing things with the technical skill I learn.

I've recently taken up developing Ethereum Smart contracts using the Solidity programming language and have deployed a number of small successful distributed applications (DApps).

When I'm not writing distributed and immutable code, I'm usually soldering electronics and writing code for some of my IoT home automation projects, and also working on Unity3D game development.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Introduction: Welcome to the Alexa Skill Kit Practical Chat Bob Development Course monitor. They think lover. I'm a passionate computer systems engineer who loves to spread knowledge and education through different technology fields that I learned about. My background isn't back in and front end software development, and I'm really drawn to cloud technology. And with that, I started to learn Alexa through the Alexa skills give, which is the course you about the tape. Throughout this course, I take you through the architecture journey. We design our models before we implement them. You have a really good understanding of what we're trying to build. We'll be turning and modeling code on the left into an interactive chat. As you can see on the rise, you won't need much, and you don't need access from Alexa devised to take pot. You're able to test everything from the command line well through a Web browser, all you're gonna need is an AWS free tier account to get started along with high quality videos. You also get access to PS that outline every single step along the way. So if you get stuck and you need to read some documentation, I have you covered. It's what are you waiting for? Pick up the course, have fun and build chatbots 2. Windows, Mac & Linux Setup: Welcome back, everybody in this video, we're gonna get you set up with everything you're gonna need in order to complete this cults set up with a variety of different tools. Again, if some of these tools don't meet your sense, the things like ideas feel free to use whatever you're comfortable with. But these are just sort of the general recommendations of people who are beginners who just want to get started and little need a little bit next, a helping hand. And so for windows, specifically, you're probably gonna want get installed. Get that form the euro. Here, get for windows dot dog alternately if you go Teoh just Google gifts and so top result you're likely to get on very similar results Basic using to install gets I guess you probably don't need it for this course entirely, but it will help a lot because all while code is gonna be hosted on Get hub on. If you want to able to clone that and pull it down easily, you'll need to get tools. Second recommendation I make is for visual studio code, So code of visual studio dot com. I'll mention this later on in the course we use it, but it's a really great free idea. Has a bunch of extensions that make things a lot easier. Things like text highlighting your code really, really helpful gives you order plates. I know there are People have their own preferences and ideas, so I'm not going to say you have to use this. Obviously use whatever you're comfortable with. However, if you're not already using an idea, visual studio code is a great assault. A starter. The third thing you're gonna need is a Amazon account. So you need eight of us again. You can use it free to your account. Basically free T A couple is pretty much most of the common services. Up to 12 months, you'll get a bunch of free credit. That free credit is very, very, very unlikely to inspire. You get a lot of it. You know you're free to your account for this course because we do deploy Orlando. It's not gonna cost much, if anything, if you don't have a free tier account, just going to the Amazon AWS website and orders Craig one of those specific Semak. If you you're on a Mac, you already have get installed. It comes with Mac Os. Same with clinics. In most cases, if not just Google. How don't so get on clinics again? Great idea for Mac is just code, and you're gonna need a free tier 80 risk council. Now, this is just a sort of over you off what the account limits are like for the free tier stuff again. A 1,000,003 requests per month with Lando. We're not gonna even get close to touching that. So I think you recovered. You'll be fine for you, Needful. Now you're seeing any eight of this seal I sort of set up and installed. You can get it gets more details about how to install it properly at this Lincoln eight Overstock Amazon com for its life steel I Alternatively, you should be able to download the 64 32 bit version off the tool for Windows. Uh, from one of these two links. Uh, well off. Sorry, Onda from Mac os O Lennox, you can install a fire pit. You know, it was a solid Bytyqi. Pip. You're gonna have to have possum installed, So a lot of times party will come on your system when you when you get it. However, if it doesn't just down, apart from from this leak in it. And then run Pip install a but Seelye for any other information about still in Seattle. Heiler, I've been checking out this tutorial appear all this, That sort of tools that I was on a document. Really, really well on their website. So what we're gonna do is actually going to go through the process of setting up your credentials. Once you have this seal, Eitel sort of installed Grab a link. Now I'm on a Windows machine here. Somebody grab the 64 bit like here. Once it's down, let it is going up. We're gonna go through interest in Seoul. These tools now, it's all finished. What we're gonna do is gonna open up command from yeah, multiples. Just run eight of us. And what we probably do is plan will fail again. It's just letting us know that we need Teoh run a difficult man. So jump Echeverria Trial tutorial here. And basically what we're gonna need is a set of credentials, you know, just fills out. So we're gonna jump onto the Consul Emma's aws to amazon dot com I am. And bring up a list of al, uh, uses that are available. Let's look in. You probably won't have access to a bunch of these use of these uses. I've created myself. But just click your administrator account or your account might just be your name or whatever your use name is here whatever account you have access to with permissions that came with your account. Once you click this, go to security credentials tab, scroll down to access keys and click. Create access. Kate, you know you could you get a access I d and attacks a secret key. Don't share this with everybody. I'm the one I'm going to share with you now is one I'm going to disable after this. Anybody who gets access, thes thes acts, occasional secret keys. We'll have access to your address count and have permission to spin up and spin down resources out. Will. It can cost you a lot of money. So totally these to anybody else. Now, to input these access keys. What were you going to do is take a copy. I'm gonna jump back over to my sister here. I'm gonna aws configure now. It's asking for all access key I d And in here I'm just going to put in that access key. Just coffee. Hey, dancer. Now we need our secret key again. Just gonna jump back over here. I'm gonna call you my secret, Kate. I'm just gonna pace to my secret kid region name. Just put us East One for now. Again. You can change this later on, but just for this course, we will be using us, Ace and for default format. Just leave it at No. None. And hit. Enter. What that should have done is set up all the things we credentials you need in one interactive. The eight of us account from the anywhere Seelye, you know, just tested. Everything's working. I'm just gonna run aws s three ls And what that will do. It was a print out. A list of my diverse as three buckets in my account also is likely to print actually, nothing if you haven't had native was a cat before, but it probably list absolutely nothing. But as long as you're getting era, you'll know that that is all set up and working so close that off Jump over twice lines and again. These lies just go through What I just talked about running it was configure helping in your I d and secret key. Your region name and idiota. That's everything you need. In order to get started with this course, there might be a few of its dependencies that will still later on down the track. But to get started right now, you should be all set up. I'll see you next year. 3. Where To Find Sample Code: Welcome back, everybody. In this view, I'm gonna quickly go over what you need in terms of sample code for this course Now, throughout the sections of this course, we're gonna be going for a lot of code and you might get lost. And if you do, you don't worry. I basically covered on each of the steps and each each section we go through. I've broke them up into little chunks that you can access by Give Repo and they're also attached to each video. So I'll give you an example. Now the Alexa random quotes one with the Alexa random points repository seen here and get helped a comb forward slash tearful gloving for it slash alike surrender ports. It's just one single project because it's only used in one video and it's during now set up for Alfa selects a school where we return random quotes. Now, if you have access the code which we will in that section, you're gonna be going to this link here. The one that's a little bit more important is the catalogue code section because because we're adding and removing a bunch of different lines of code per video, it's really easy to potentially get lost, or maybe just want to see what the code eventually looks up. Looks like off the end of the video, you have a better understanding of what you're trying to achieve. And for this, what I've done is a breaking broken each section up into drew individual folders with a label defining what each of those sort of sections does down the bottom. Here, if you do get lost at any stage, where you can do is find a section that you currently working on. Open up this folder here and you'll get a sort of a save state at that point in time off where we're up to in the lectures. So again, if you could stop working for any reason, jump onto here, pull down the folder, you having problems with and just start fresh from there. And as I said before, I have attached a zip file with each of these sections to the videos as well. So if you do happen to get lost, you don't have access to get. Can I get for whatever reason, you just down the zips from the videos from the resources match these videos, so let's get started 4. Alexa Skill - Interaction Model: welcome everybody in this first lecture, what we're gonna do is actually go through building Al first, Alexa skill using the Alexa Development console. We're gonna do this So you have a good understanding of how to develop Alexis skills and what's actually required to develop one and push one out before we jumping into the code. It's always good to understand how to do it to do you. Why? So that we know we're building. So start with we're gonna build this random, quite generator. Now, basically, to get started. What we need to do is never get to the Alexa developed council at developer dot amazon dot com forward slash Alexa. It's bring that up here and you just have to sign, and we have you'll Amazon account. Now, if you already have an AWS account, you're gonna be able to use that. We just added Amazon developer account. So I'm going to do that now. Fantastic. Now, once you looked in, we're gonna do is actually jump up to the top here and we're gonna click your Alexa Consoles and click skills. You're gonna see a few skills that already developed here. Ignore those. You're not gonna have any. So what you're gonna do to start with you just click, create skill? No. We're creating a new skill. You have to give it a not unique name but a unique name within your account. So it for Apple's we're gonna call it random court generator and selecting your default language as English US. Now scroll down and select custom. When we're building our skill, There are a variety of different templates. You can go and explore yourself you'd like. It basically sets you up with a bunch of different intent so you can get a good understanding of how I was long sort of recommend you build skills. Both of this course we're gonna select custom so you know how to do everything from scratch once he's elected that go up the top and click create skill again. Another template, um, was gonna select from scratch. However, bear in mind, we're building a random, quite generator which is actually quite similar to the fact skill. So this particular example is actually based on the fact skill, but I'm going through it from scratch with you so that you have a good understanding of what what all the pieces actually did. Fantastic. So once you don't, you should get a sort of you just like this. Uh, Let's just get started, shall we? So let's explain what each of these parts do up the top. Here. You've got sort of your navigator left to right now of how you're going to develop a Amazon skill. So you start with building testing, distribution, certification we actually submitted Teoh Amazon Force application and analytics is not something you can tap on at the end. You can see it on the right hand side. Here. As we build things out, you'll get more, more green ticks. Once you've built up the skill to the point where it could be accepted for submission, you're able to do so. But what is going to stay looking at the left here, These sort of our custom interaction model panel We're gonna be working out of this primarily on what you can see he had to start with is a bunch of basic intense fullback. Cancel, help, stop and navigate home intense. So you think of intense is things that you trigger when you ask Alexis certain questions. So, for example, when you ask the question. Alexis, stop. She'll run the stop intent here. Now stop intent. You can actually give it some sample utterances, so you could be like a stop as one utterance. That's basically saying that when the user utters the words stop within this skill, it's going to trigger this intent. We'll leave that for now, however, And what we're gonna do is basically just go down to here and select Jason. Editor, This is basically just a Jason format off everything that you have up here in the intense field on the left. Here. Now, what we're actually gonna do is kind of copy in some boiled a code to get started so you can get access to this code by going to Betley to if, by p N p. T. However, I've got a link that I will just like on the screen right now as well. Basically, just click that and it will bring up a just so to bring up ageist. When we get to this, Just what we're gonna do is just basically copy all the coded here and we're going to copy it straight into our Jason fields here. Really, the only thing we've added is this random quite intent here, which is a custom intent, and we've given it a series of different trigger words in order to trigger this intent. So if we go up here and actually go save model, what you'll see is that on the left here we get the random court intent, and if we click on that, it's got a Siri's off difference. Throws does intense, basically listed. So, like I was saying before, if you utter Alexa A quite she will trigger this intent and out code that's attached to this will execute. Now we're happy with that. So what we're gonna do is actually click build model, and you can see down the bottom right here that it's just notified us that are built has in fact started, started and we'll get a notification when it is complete. Awesome elbowed is complete. Click, go to build and we can see that the basing intent has been set up. Now, in the next video, what we're gonna do is actually download some sample code that we're going to attach to this skill and basically say that when we trigger this, we're gonna run piece of code. We're gonna cover that in the next video 5. Alexa Skill - Lambda Handler: everybody has a going in this section. We're going to start to go through some of the code that gonna upload and attached to Alexis skill. We're gonna go over intense handlers, a little bit of localization, but not much. And just in general, how the structure of an Alexis Gold looks like in code. We're not going to dive too much into it right now because we just want to get a good idea of how we deploy a skill in later sections. In this course, we're gonna go through how you rattles, cut from scratch and really understand it. So don't worry too much if you don't understand everything to start with. What you're gonna want to do is pull down the code that's associated with section. You can get better, get hub dot com for it slash t 04 glover end for it slash Alexa dash Around of death courts should also be attached this video. When you download it, you're gonna want an I D in order to edit code in. So I recommend you probably used there just to your code. It's the idea I used throughout this course. It's pretty lightweight. It's available for all platforms. But you're on Windows, Mac or Lennox. So just download that. Get that will set up. It's pretty straightforward. Um, And then once you've got that set up, just open up the Alexa random quotes repository that we downloaded from my frequent and because you don't know you can download it by clicking this green cologne. Oh, download button. If you know, how do you get you can even climb it. You think it climb. So once you've got that code, we're gonna open it up in a visual studio code. We're just gonna go over some sort of basics and the repository give you a little bit of an idea of how it all works. So have packaged up, Jason. This is where we basically to define things like what this repositories cold about it too much on. We define our dependencies, these air packages that we use within our code and for our cases were using the ask STK because that's what this course is all about. Building Alexa skills. We're gonna use the Arctic. It's decayed to do so. So skipping over that we go to the next, such as this is really where a lot code sits when Alexis skilled triggers the lander on land is just basically Bisa code that's running in the club. It's going to call this file and try to get the logic it needs. Teoh complete the intent so you'll see some sort of recognizable things here. We got to get random quote handler, which is again referenced down here and within this handler we basically got the code that handles getting a random event, getting around in court. I should say again, Don't worry too much about the code right now. Just know that when our Alexis skill go back to the consul to give you a better idea when our Alexis skill gets cold here basically saying Alexa around him, quote or give me a quote this get random, quite intent is cold. And then within the code that get random court intense, I right there, here's what runs this piece of code here. So basically what we call it, this is what gets run. Don't worry about that too much. What we're gonna do is which is going to skip down and explain how the localization stuff works, even though we're not gonna go over too much right now. But say you wanted to support a variety of different languages. You can do so by using sort of blocks where you define different locales. So if you're part of the United States, you could have a US data. So in this case here, I just actually combined about one again. Don't worry about it too much right now. We're gonna go over it a little bit later. Just know that it does its job as intended. We're gonna define a bunch of quotes in here. As you can see, there are preloaded When we called skill, it's gonna return one of these quotes to us, right? And that's more or less everything that's of needed in order to run skill in the next sort of section. What we're gonna do is we're gonna package up this code on. We're just gonna upload it to AWS and then link it up to the Alexa skill. We'll see. Then 6. Alexa Skill - Lambda Deploy: everybody. Welcome back in this video, what we're gonna do is deploy the Lambda function that we have just had a look at eso all that code. We're gonna bundle little up. We're going up to it uploaded to eight of its lander, which basically runs code for us. We're gonna tie that Lando function. Teoh lost skill eventually. So to get started, what you want to do is go to the Amazon Web services Management console. Now, you can sign up for a free tier account. I highly recommend doing that. You might have to attach a credit card. That's the one thing you're probably gonna have to do. That's a prerequisite to this course. Is that you haven't even worse. Account with free tier now to get started. Like I said, go to the AWS management console, which should be Unconsoled. Abra, stop calm. Don't you on one today he's gonna click on Lando. When we arrived, The constant you can see. I've got a bunch of monkeys here. Just ignore those. You won't have those. You're probably gonna have an empty function. Uh, just a heads up in the top right here, where you got the You might not be able to see because my head's in the way. Uh, but basically, when you've got your regions up top right here, make sure you select North Virginia even if you live in a different region. Your Lambda Lambda functions actually deployed to different regions. So if they deployed to, for example, Sydney and you try to use it, uh, you might have luck. But let's just keep everything within the same region for this course. In this case, it's gonna be us East, North Virginia. I can click great function. And now let's work out what we need. We're gonna actually also a function from scratch because that's what we've done. And let's give it the names we're gonna call it Alexa Random quartz. It's gonna be a node.js. Version 8.10. Uh, was keeping on that. That's what we've built it for. And we're going to create a custom role for this. It'll open up basically a new portal where we're gonna be asked to find a new role. Now what? We're creating a new role. We're gonna even the name something a little bit more representative, what we're doing, we're gonna call it Alexa land a basic excellent execution. This is basically going to give Alexa enough permission to execute Elam function. Scroll down. Just have a look. But there's nothing weird there. But that's basically the defaults is what we need s We're gonna go ahead and hit, allow it will bring it back. And it was You can see it's gonna have pre populated this role for us. We're gonna go through and we're gonna click. Create function. Fantastic. So functions being created. However, it's not currently attached to any code. Right now. You can see this, um, blank default code in here, but we don't want that. We want our own version of the code attached. So to do that, what we're gonna do is change this from edit code in line to upload the file. Now, we're gonna go across on We're gonna grab the Celexa, rent a quote sip from within a repository. So if you download the prostitute, you should already have a copy of the sit file. Basically, all it is is zip version of all this code in one location. That Lander is able to understand. It's like I said, I already got a copy here So I'm going, Teoh, Go ahead. And But I'm gonna bring up my land, my land, A council. I'm gonna click upload now from here. I'm just going to navigate directory where? I downloaded this code and I'm going to select a land. Alexa. Random quotes. Now, make sure you select. Does it fall within the folder and not the originals? That fire you downloaded off the code from the git repository. So first unzip the git repository and you should get access this fall in here Once that's done, just make sure that again. The runtime set to married a 0.10. I don't handle a set to index. So handler hit safe. Cool. So the coach should upload, and you should be presented with your code in line down the bottom here. Now, the next thing we're gonna have to do is we're gonna have to grab this Aaron at the top here. So this is basically the resource name for this particular lander function. So we're gonna take a copy of that on. We're gonna actually dump that somewhere. Just dump it somewhere. You're gonna remember, because we're gonna need it in a second. Uh, next What we're gonna do is we're gonna jump back over to the top here again, and we're gonna drag in this trigger here. Uh, Alexis skill kit. So you think you can just click it and then it's click the note he exit says in his configuration, Basically, we need to do is needed with skill idea of our Lexus skill into this box. Here, you can get X that by going back to your Alexa skill in the console him. And then if we scroll down Teoh interfaces, Sorry. And points, I should say, Then click eight of us Lambda Erin, and you should get access to your skill idea here. So when a copy that skill Eddie in and we gonna pay sell scale, I d into their we're gonna hit that. And then finally, we're gonna grab this hair and at the top here, copy. That. Gonna go back to the Alexa developed console. And in this default region here, we're just gonna pace that, Aaron. Okay, cool. We're going to say if the in points you might find that we get a error message. Uh, let's go back. You might find me getting their message. And that message is because we have actually saved this eso new trigger. We added the skill, Eddie, we have to make sure we get saving top you when you hit. Save. Then if we go back here and we click save in points, we should see that skills manifest has successfully saved. Fantastic. It's now in the next video we're gonna do is basically just gonna go through and test this skilled. Make sure it works the way we intended for and wrap up this section. 7. Alexa Skill - Lambda Connection: everybody. Welcome back in this video, what we're gonna do is go ever kind of testing l skill. Now we've got a much complete because we've linked up all the code toe Alexis Gil, Let's test to make sure it's working, and I'm gonna show you how to do that. Let's jump back over to the Alexa developed council on again. If you haven't already, you need to make sure that you've set up the endpoint information where you put skill. I d. You've placed your skill, Eddie into the lander expression and you taking your default region. Uh, and you start, you've put your Aaron, you're Iran is attached to your live with functions that help you. And you've put that into this default region, Bossier. Now, if you did have ah, multiple region if you did have the skill set up for multiple regions by that I mean just, like load balancing across different regions, you could actually paste in the same functions, Aaron, into these various boxes that different regions get a better experience for your school healthy. Just browse. That was fine. We had saved in point and we are ready to test this skill. Let's have a look at how intent just to make sure that we get a good understanding what we're gonna need to start asking, Alexis would in order to get information back. So if you recall the get round of intent, quote intent was basically requesting that we say, give me a short quote or basically any of these. Look, tell me something and we should get a quote back. Let's test make sure this works. You just reduce within the council by just clicking this test tab. The topia already now you have to do is just enable development testing for this skill. You should just get access his boxing apartment in sort the tab. Here, you can select which language you want to use. In our case, we only have access to English us because that's what we're building us go for. If you did support multiple, like tells, you have access to multiple drop down tear. But for now, what we can do to interact with this is Alexis Killers basically say something along the lines of opened random quote Jenner Aito and give me a court. Listen, Alexis actually popped up and given a cell Quite. She said he is your enemy. Okay, well, church, these yielding my tears just then. But basically, she should actually talk out your court and say, What if the court was in our case? It was a huge around in problem. If you get up one more time and then you fall, you will make it through good advice. Uh, and yet you basically you can ask election in a variety of different ways. How you, um how you'd like to interact with thirsty? You could go back and have a look actually back under build. What was some of the other ones we had? So we also had Ah, tell me something. Read, um, question Rachel and tell me something superb. And she's basically again. She's told us what She's giving us a quite five into 10 go. And that basically explains how you can sort of deploy a really, really simple Alexis Gill on. This is basically using a lot of oil fight card probably didn't learn too much about the code, and that's where we're going to start to fill in those gaps. In the next coming videos. We're gonna start to cover how you could build all of this from scratch, but we're gonna actually using the ask STK in order to do that, they asked. Sdk is designed to help sort of fill level of this boilerplate on just allow you to stop making intense without having to worry too much about what's going on under the hood. So without further doing, I will see you in the next two years. 8. Alexa Skills Kit - Create Project: Welcome back, everybody. In this series of videos, we're actually going to start to build a very own skill from scratch. Using nothing but the ask sdk and code. We're gonna be doing all the deployments from the command line. And this is what stuff gets really interesting because it means, you know, having to fiddle around with all these user user interfaces. And you could divine everything in code. The real benefits to this come from working in teams, you know, we'll be editing different parts, the code within things like get on, have it all come together and deployed with one simple command. Let's get stopped getting me really good understanding about what the skills kid actually is. We're gonna be using the version for No, Jess, that's just outright. Of course, if you're writing stuff in Pathan, um, I'm pretty sure there also libraries for C shop on. Don't let s. So you can be riding and using the ask kids. Ask sdk across a variety of different languages. However, for this particular course, we're gonna be focusing solely on JavaScript. Let's get started now. What you need is no jazz. No jazz just is how we're gonna run Java script Outlook system. I'm gonna be writing job script, deploying job script. So you gonna need a JavaScript compiler or interpreter free system we're going to use, you know, just for that, don't let this from the no jest Ogg Della's Page. Mine is defaulting to Mecca West's. However you can download it for pretty much any operating system on the sun being Windows, Mac or Lennox. Once you have that old installed, what we're gonna do is actually creating a you new project using the OSK it I Now, however, in order to do that, we're gonna have to first install the ask CLI. Now, the Aussie ally allows us to interact with the with the Alexa consul from Al Seelye. So to do that, we're gonna go in PM It's still global usage Global's like I'm going ask Seelye. Fantastic. Now we have that all installed. We're gonna go ask in needs. Now when we get asking it, what we're gonna have to do is sort of select the profile without eight. It was propel attached, and when we went through the set up for this course, you were going have to set up a bunch off secret keys within the dot AWS folder off your home directory. If you can remember that, basically, that's what's being being picked up here when we have gone asking it and we're gonna just be using the default profile here. So it's like default again. I mean to say it's like people and it's gonna bring up a web. You I where we have to both indicate against. So I'm just going to you off screen. So give you sick now, once you being probably for two factor, I'm just gonna go ahead and I'm gonna click. Allow a successful So close it off and we're going to see that it has indeed authenticated me. Cool. Now, to get started, we're going to create a new ask project. You don't do that. We're gonna go ask you, and it's gonna ask us, uh, run time we'd like to use. We're gonna be using No, just gonna like No, just. And we can kind of choose a bunch of different example, uh, sort of, I guess, templates. So we're going to want to use, which is gonna be using Hello, world. We're gonna rename the skill. However we're gonna call it cats. Look, then what we're gonna do is we're gonna open up in visual studio code. Now, you know what to do That we're gonna change directory into, uh, a look. Cool. Yes, we have. How great here. And we can actually do code dot on what it will do is it'll open up in visual studio code Al folder. However, if it wasn't set up properly for you, you might have just never getting at this folder yourself manually in what i d you decided to use. Now we've got this whole set up. Let's go through something folders and what each of them actually do. Now, first folder is this mosque folder, and basically it has the configuration. This is old kind of you don't really manage. This is configuration State. This is all managed by the asks Eli for us. So you should never have to change anything in this folder. It's basically gonna be changed for us when If we push out changes Teoh the Oscar to the Alexa Council next folder. That's kind of important is lander. And this is our, uh, facing out code that could support alongside how skill? So you can see here. We've been in next address and is being populated with a bunch of different intense, uh, these air, basically hello, World intense. The's a role, very stock standard. And all they do is handle just Hallowell. It's pretty much a lady. Um, it's good, because it's all wrapped up in this one photo called Lander. Next is the models folder. Close this one off and busy again. We can see in here. We have a interaction model. If you remember back to the one that we pasted in from the just for a previous skill. All we're gonna be doing is when we make changes to al l model with we typically used to do . We didn't. He likes a council itself. We're gonna be doing it through this file instead. And finally we have our skills. Don't, Jason. This is what we define. I guess a bunch of variety of configuration options that help help without skill helped define what else School actually is things like our summary. Some of the example phrases. This is all information that to use by the Alexa. Why? In order to find, like, what else? Kelly is what we do go to deploy things like category. Uh, again. Don't worry about this too much right now. We're going to current really soon. It also points to things like Al Lander that we run along with. That skill will be making change to this in the next section. But now that you've got old sort of the basic code the whole folder set up, I think we're good to move on to the next section. 9. Cat-a-Log - Project Architecture: Okay. Now, before we get too deep into our solution, we should probably talk architecture. Let's talk about what we're actually trying to build with this skill. Basically, in this section, we're just gonna cover Like what? We are trying to build plan out some of the commands that we'd like Alexa to respond to, and we're gonna talk about, like, eventually what kind of external set this is gonna be leveraging full of application. So architecture right now is actually gonna be pretty simple. Simple. We're gonna ask Alexa to open the catalog database skill I'm gonna ask her to tell me about , and we're gonna give her a name of an animal that we'd like to get information from now, I have created some sort of some pre defined data, and this date is in Jason format. Uh, that's gonna be like the description location, the i. D name. And, like, these gets the breed of animal, uh, for each individual animals. So we've got a name here called Bill. As you can see, Bill is a reptile. Bill gets along well with Children. Bill is located in South Perth, Western Australia, and his description is I'm small and still trying to understand the world. So right now, again, architectures really simple. We're gonna get a rate on this architecture diagram as we move through this course. For now, all you need to know is that we're gonna have it will be just a single intent here. World's gonna help me intent. Work on. We have to separate. Intense. Start with what? We're building this up and we're gonna have to have a slot. Now, Slope is, you know, case animal name. Now you can think the slot as, like, a custom parameter that Alexa needs to think about or needs to try. Teoh. Phil, when we ask the question someone that when I do ask, tell me about it. And then I say a name Alexa is going to win for the fact that that name is, in fact, an animal name, and it's gonna link a taco. We're gonna go over that in the future for now, just knowing that that is gonna be filled with our own slot. This is our data schema. We're gonna be storing it in Amazon's dynamodb for this case just because already talking in Amazon model who use all Amazon services this and it is still stored in a free T. A database search cost you any money. Again. The database schema is almost identical to what you see before, you know, facing structure. So now that's what you really need to know before moving forward. Uh, just gives you good understanding what we're doing before we start doing it, so I'll see you next year. 10. DynamoDB Management Tool - Create: everyone Welcome back in this video, we're going to cover dynamodb gonna create al database, gonna upload some data to we're gonna get that all sorted out to start with now, if you like. May I don't like to click through your eyes to build things because it means that if you make think changes later on and you guys have to redeploy things, you kind of have toe. Remember all those little changes you make, it's better if you deploy everything in code. If you define things in code, you know, without with without a fact that if you deploy something by that code you've written, it's gonna be the same every time infrastructure is code for people typically will call it . So what we're gonna do is we're gonna create a small daughter based management tool. It's gonna help us pre load some data into dynamodb. And it's not gonna help us create al dynamodb table. So to get started, what we're gonna do is gonna create a new folder, and we're gonna call this TV for now. Hopes now, within this TV folder, what we're going to do is we're gonna probably create a few different files we're gonna create a folder we're gonna call this folder source and within the source directory we're gonna do is gonna create a folder called Conflict Js. We're gonna create a you're gonna create a few files, and we're just gonna create that packaged Jason just outside of this source folder. Now, to start with, Richard's gonna paste in some code from this packaged up Jason into this package. Jason, uh, this might be again. It's up to you How you want to do this, But this is the code that I've put in. I was calling a package database. Manage? It doesn't really matter what you put in here. Just make sure that you've got this scripts field as noticed source create in certain test signed the keywords create test. Answer just basically means we can run these commands with no Jess by growing like NPM test and it will run out test fall for us. Also, make sure in the dependencies field you have defined your AWS sdk versions and the blueberry version. Take a second to write all that down and let's move on to the next file. The next fall we're gonna need is actually on animals that Jason, while it's gonna be our Jason data that we want to use for this particular tutorial, you can get that at the bit. Li dot orbit dot li afford slash to a Noor X. I also put a link to this on the screen now. And as you can see, this is just some sample data that we're gonna be using. We're just gonna click that roll button. I'm going to copy all that information and then just again. Yeah, just outside the source. Folta. We're gonna create the file called Animals don't Jason. And we're just gonna pay Still that did it in cool. Close that often. Now close that one off now and let's get started on Al. So the first file when I open up helped convict up just again. If you want to skip all of this, feel free to sort of skip ahead on and just type of this code it up. If you don't like this code in, jump into the get hub on. Just pull this code down. Drop a zip file attempts this video as well with all the completely code. Because I know this particular section to be quite tedious talking rolls out, but we're going to try to explain it as we go. So basically, this CONFIG file is just place process to still some common values that going to be using throughout a bunch of these different files in our case, we're actually gonna create. But it's gonna create a instance off conflict or dynamo. And we're gonna populate the values table name, region, partition key and sake It's a table name should be pretty obvious. That's the name of our data. My devi table that we'd like to create, manage and test against a region is out of this region that we'd like to deploy to again. We're gonna use the North Virginia, which is just a US East one. We're gonna be using this throughout the rest, of course. So get used to talking us East one. The partition key is the animal name our petition key you can think of as sort of a pseudo unique identifier for the item that we'd like to get information out of. So in our case, it's gonna be animal name says you can see under animals. So Jason, we have a name here. We're actually gonna map that animal name to this name eventually. So think of it is a little bit like a um I guess a primary key in the data base needs to be fairly. It needs to be pretty much unique, Doesn't to be unique and have sort of type is of a value or variable. It's part of like an object. Or, in our case, like an item in the animals array that can be used to a group similar like minded items. So in our case, we're gonna be using this type field because I'll talk to you Cat, dog, reptile or bird on. That gives us a way of sort of clustering out cats and dogs and reptiles and birds into sort of groups. There's a lot of sort of there's a lot involved in picking good sort, sort and partition keys. I've kind of done the hard work for you. You don't really need it right now because this isn't really course of dynamodb. You just want to know what you need to get started. If you have any queries about this, feel free to ask me that. Let's move on to a great function. Now we're gonna create a school function that allows us to Let's move on next to our create function, this is gonna be stored and out create dot Js folder. And what we're gonna do is we're gonna start to populate some code that allows us to create a new dynamodb table using code. Let's get started. We start by bringing in our two references to both of CONFIG file and Teoh a diverse STK and we're gonna stole that variable. Now we're gonna update the configure region by using a variable in all config file. So gonna convict or dynamo don't region, which is gonna be referencing this dynamo region field and all config file again. Table name. We're referencing the variable for all table name keys. Gamers very defined the petition assault case. He s here, Stands will string. Basically, it's a vision here. Parisian three put is just some variables where we can set. How did the capabilities of all database in terms of scaling up and scaling down Don't worry about it too much. It's just required field This five and five actually covered under free tier social cost you any money to run these Now we've written now parameters for out query. Let's actually bring in the Dynamo DB instance. Now we have a instance. Let's bring this all together basically here we don't have. We've called our dynamodb don't create table. We've passed out parameters which we defined here, and we're gonna pipe in either the error or the data into the output here. That basically confirms if we created the table or not before moving on. Let's actually confirmed this create function actually works. In order to do that, what we're gonna do is bring up a terminal you need to use your term or if your windows just your get bashed. Tamerlan, we set up. What we're gonna do is within this DB folder here. We're gonna go npm install. Once you're done, NPM install. What we're gonna do is run NPM run. Create. What this will do is run out. Create a J s father. We just freaking here. Fantastic. And we should get an output that basically says we didn't get an error, so we know that has worked. Now what we're gonna do is we're gonna move on to writing our next function, which is the inset 11. DynamoDB Management Tool - Insert: Olson. Now, let's get started running on set function. Basically, we're gonna be doing is just taking the data that see, now the animals don't. Jason, file. We already pulled down. We're gonna be inserting them line by line into out dynamo db instance that we just created in all previous video Let's get started. This is probably gonna be looking fairly similar, which is gonna be calling in and bring in aws sdk out configure variables. We're gonna be setting up a duck client. Instance off the 80 bus dynamodb document client without region here. We're just bringing the file system import, and we will be using the file system. Important. And Jason are passed on orders bringing the animals that Jason toe are variable animal dot Jason here. We're gonna get a function called ad animal to table. That takes an animal. So we're gonna take this line by line crossing animal. We're gonna have to create out prams again for our document clients. This takes the table, man and an item. Now, item is just gonna be a, uh, basically each of l items here in animal. Jason, we're just gonna fill in here. So here we basically paused in all the data. So we gotta animal, basically, each animal that we passing is gonna have a field name, adopted type, location, attribute and description. We're gonna set these values here equal to those types of people in basically cold. Don't client. Don't put me passing Brems and do adult promise. That just means it's gonna be a synchronously completed me that many walker, So don't run. Basically be triggered old once and the whole run to completion. Now we need to call this function. So we're gonna go animal that Jason dot for each, which is a nice little expression we can use. Basically, we're saying for each item in that Jason Final, we're gonna call each item animal. Rania's an arrow function. Now we're gonna say that I had Teoh animal table. I'm gonna posit the instance of the animal. That should be all we need's. What we're gonna do is we're gonna open up again. We're gonna open up a terminal that's linked to this. Insert that chaos. We're gonna run NPM run insert before we run this, just make sure that under your package, Jason, you have in fact, got a script field called insert where it snowed Source index or insert R J s. We're gonna run that so again, back with sexual, it's works. It looks like we had good Inara. That is a problem. So I've gone new data. We should have gone new date. Don't get time here. So we're gonna clear the consul gonna run this again. Superb. Looks like everything's worked as expected. We'll find out in the next video. However, because we're gonna be writing a quick test function. Helps this check to make sure all the data with populated probably 12. DynamoDB Management Tool - Test: already, guys. Homestretch. Sorry the section took so long, but we're up to the final piece, which is just writing that test function. That's gonna help test to make sure that basically date is an AL but dynamodb instance and also gives you a good I experience of how you can actually pull data from a dynamo DB. It's a swell CMB drivers group SdK Let's get started. Most getting pretty good at riding this out now basically bringing out imports and an instance of the document client again. Guess what we're writing in other friends. The final table name. Okay, lets go over this in pieces because I know it's a lot to take in. We've got our table name. Then what we've got is our key condition expression. This is basically what's doing. Check to return the data that matches the expression. In our case, we're matching animal name where name is equal to the animal name an animal type where type Siegel, CNN time. So it's probably make a huge amount of sense here, But let me explain this variable here name and type are actually referring to this expression type values here, so named Frankie type dog is. We're actually defining. What data? We want to be pulling form using our client. So we're gonna be looking for a dog named Frankie. That's where to find him. Here. Now, this animal name an animal type here, These actual flags with the hash in front. That's where we map this name. So what? This is inside the database. So animal name is the feel that we have inside our database. And a type field is called type in our database. What is mapping them to difference names here. So it's a little bit less complicated if we have them. Both is the same name. This whole Parames field becomes a It just becomes messy. Very 100 split. Let's go ahead and actually perform the query. Now we're ready to problem the query. We're gonna use the dark client, but apostle parameters and the query is gonna execute. If it errors out, we're going to get an error. However, if it succeeds, got the air query succeeded. And then we're gonna print the results of our queries, gonna go data toe items for each and then for each item which is gonna console over the items out. Let's Go ahead and I've got the council now and again. Make sure packaged up. Jason, we've got that test. One for the soul. Still test. We're gonna go in PM Run, Test. My mistake. I obeyed Air American expressions. It should be Expression has expressed you. Let's try that one time. Fantastic. So we've returned out query results, which is returned, Frankie, which is out dog. And there the details for Frankie. So that's basically everything you need to know. In order to manage the database by a code, we're gonna have all that within our DB folder within a repository. For now, you probably won't need to use this too much, but it's always good to come back. Here is a reference because you could get example how we do make queries the database and add information to the database. If you do want to expand this skill further in the future, so in the next video we're gonna do is actually start in Flint. Um, I guess away off improving the project structurally already got, uh as we move forward. So it's a little bit less messy. 13. Improving Project Structure: Welcome back. Everybody in this video we're going to go through, I guess improving the project structure off this existing boilerplate code that's been given to us. We're gonna move things off into different directories to make things a little bit easier to work with later on down the track. This isn't really required, but it's gonna make things a lot easier when you do start to build up a lot of new intense . Let's start off by having looking. Index suggests we got a bunch of different handlers in here. We've got a launch. Hello, World Help cancels stop session and requests. All these things are needed. However, they don't all need to be an index that dress and help with this. What do is that? Just start to split these off into new sort of full destruction we're gonna create. So what is his custom folder here? We're going to create a new folder Cold, intense, and we do this intense folder we'll create a new photo call base. And within this baseball that we're gonna create full files. Great. Helped a Jess once for Jess. Session ends. It stopped. Jess, this is we're gonna We're gonna start to move all those fairies. Well, that various logic into now to do that, what we're gonna do is we're going to start off with what do we do first? Start off with Launch, for example? So what we'll do is we're going to index. And here, this is this launch handle here. We're gonna just basically cut. We're gonna move back into the India into here, and we're gonna paste it here just for now. Now the top, We're just gonna add used strict, which is just for mine by highlighting so it knows what to do. Don't worry too much. We're gonna export a model, start export. And we're basically going to paste all this code here into this model export. Then what we can do is actually get rid of this launch handle here. Cool is going to reform. It could. And that's pretty much the Lord Chancellor here moved across instead, What we're gonna do is pretty much do the same thing for the other three functions. So you can speed ahead for this Perfect. And that we moved those four out. We're just going left the hello world Handler. Now what we're going to do is actually bring in a reference to these four files and replace these with them there. So basically at the top here, we're gonna ads instead of comments and base intent handlers, and we'll bring them in. And once we bring those four in, we basically replace down here. Well, we grow tea exports will handle a skill builder. We have a builder function here called ad Request. Handlers were just gonna replace thes request handlers here with launch help. Stop and with session. And that should be everything we need to do that now. Lastly, what we have to do that you created custom Hadler for that lost function within Allen. Next o J s. It's this. Hello, Wilder 10. Basically, you want to convert it to our own custom intent. So what we're gonna be doing is under this intense folder here, create a new far code animals. No animal details Js and within animal detail through the same sort of thing. Basically do is copy in something similar with this Helliwell. So I'm gonna take this can handle here. What the hell I will. We're gonna pace it in here and under here where we got Helaba intent. We're going places with animal details intent. And then here we go to speech text. We're gonna replace this with animal details, and here under the simple card will have any details as well. Awesome. And then back in the index again, we're gonna have another coming here called Custom Intense bringing the animal details and will replace the hello world intent handling. Yeah, he's gonna get rid of it entirely. I'm gonna put that on top there. Fantastic. And then finally, we're gonna actually have to do is add in to our models side of your on the models. We're going to replace the Hello world intent here with, uh, and a movie details intense. And then, indeed, samples would have give me details and just details. These just some example. Utterances weaken. Send this to Alexa, and we'll get this intent triggered. And we'll also change the invocation names. This is the what? The name of the thing that you ask Alexa. Paul, when you say open, so we'll go open Catalog database will do Cat logue database. Now we use the cop. The periods here seem to indicate probably wanting to say catalogue. Uh, Alexa one interpret that properly. So we do periods with your cat. Well, Log data base. So we sort of spill it out. Exactly how she would interpret it and then finally will do. Under these skilled on Jason is we'll do something similar, will just be up updating the summary here, Teoh interacts with cats. Well, database And then some of the example phrases here. We're just gonna have Let's copy some of these in. So, Alexa have been catalog database like sauce catalog database. The details on then on description Also copy in just a simple description here to fix up interacts with cat data for the training course. And that is pretty much everything. So that cleaned up, I think more seriously cleaned up. You will leave it there. A handler in here. But as you can see, we've now got the project in a slightly more maintainable state. It's a lot easier for us. Toe manage In this way, in the next video we're going to start to cover is I guess deploying this base project is confirmed. Everything's working before me forward 14. Deploy and Test: also working this far. Guys. Now, in this video, we're actually going to start to get real meat. We're gonna start deploying this and then you show that it all works. Hopefully, you know, the code that we've written is wrong, so we'll work that out in this section. So what we're gonna do is we're actually gonna open up a new terminal in the root of this project, so just make sure that again. Oops. You're in that, uh, catalogue re directories. That's the top view of all these files on. What we're gonna do is we're gonna run our employees of this and this is actually really easy, so we can t do, ask deploy and that's it. Just let it run. Fantastic. Now that's actually deployed pretty much everything. So it's gone through deployed Orlando. It's deployed al, uh, Alexa skill. And it's clear that all together it's credit old security for us. Everything only one command. And that's why I ask SdK is just so amazing. It's now let's go ahead and actually navigate to the web. You want OK? Just give us a bit of refresh. So we get access to our new skill and you can access this underdevelopment. Don't amazon dot com forward slash Alexa and we're gonna complete calumny Skill. Couto that catalogue to now if we actually open up that animal, you have to see all that stuff we write in code is already being deployed for us. Just really awesome. And again I'm doing, uh, endpoints. You can see it's actually already already configured all this stuff for us as well. So let's go to test and again. Snake Show That said Teoh was us and let's go like So we've been cats. Logue Database. No, she should return with this default. What? Alexis Skill kit. You can say hello. That's normal, because that's actually what we have to find. Yokoya, sir. Uh, Landau on the launch, you can see Welcome to you like Cisco Kit. You can say hello because this is the launch tense. This is the thing that's run when we actually launch skill without any further information . Let's actually talk details now. Cool. So she's actually returning animal details, which is exactly what we supply within that. Um, let's bring that back up. That's what we supplied within our actual animal details dot Js file. So we've caught the intent. Animal details intent here. We've gone, uh, this guy here, a tent name, animal details, intent. And we've just pretend speech, text, animal details. And that is pretty much all we really need to test. However, there is even an easier way to test. We can use the command line, which is something we're gonna get a shot. It might not work with Windows. I have tested this, Mac. We're gonna trial best with Windows. However, what we're gonna do is we're going Teoh, basically ask simulate. You should be able to do this on any operating system. We're gonna go ask to see me late. T t is the text that we'd like to see. The light sweet ago. Open cat A Logue database. And we're gonna supply the l flag, which is just our region. We're gonna e n us the vehicle, and that's returned. I guess that's just returned the chase on response for actual school request. How? You can see down a bit further under invocation response. You can see she has returned. Welcome to the school, kid. Okay, so next we could do you ask Sim, you simulate t uh, just describe? I guess l ian us again. Let's just make sure that under our way, have not just possible describe. So let's actually go and do details. Oops, my mistake. Have special text here. Cool. And she has returned animal details. That's pretty much everything you need to know In order, Teoh, create this sort of defensively test all skill. However, we can make this a little bit easier this again my no vote for all operating systems. But we'll do it anyway. So what we'll do is we'll create a new fast we're gonna touch seemed R S H and then we gonna open up that Sim and within it were actually going to create. This changes the details. Basically, what this does with this force recession is it forces Alexa to start the session. So it's forcing the skill to relaunch effectively. And then it's for any details. This been bashes just telling you what show you want to use again. This won't work for Windows for other work. For Mac, however, from actors how you do it on Windows, you would probably write a bash script, see dio create a file called sendup be 80 on, then you just put this in and hopefully that should work. If everything works well with Windows, Um and that's pretty much everything we need to do in terms of testing. So it's really easy for us to test. Now we're able to simulate from the command line, and we're also able to see me, like from, ah, Web browser. Well, I'm so in the next section. What we're gonna do is just expand our animal details to include a slot where we're gonna ask the user for an animal name, so I'll see you never get 15. Custom Intent Slots: everybody. Welcome back in this video, we're gonna have a look at creating Al Fist Customs slot. Now, a smoke be thought of as a kind of parameter or wild card within any given utterance. So we use this example that I've got up here, give me details about animal night. That's what we're trying to achieve here. We want to fill this animal name. We want to have somebody say a name off an animal and have Alexa pick up the fact that we have said in animals named there and then passed through whatever we say here to our code. For example, if we would say give me details about Felix Amazon would recommend recognize that animal name is Felix and will posses through that animal name to all code. Have you been an example of how this all works? Gonna be making use of an Amazon list? You can get to it from this reference here. I've got it up behind him now. I was on lists. They have a fried your different sort of pre defined lists that they can look out for when you defined it as part of our utterance. So in our case, we want to be using us. First name U. S first name Liska is populated with thousands of popular first names commonly spoken within the United States. So we're gonna assume that we're gonna be naming animals after first names that are common within the U. S. There are other versions off this first name list. This first name such. There's also a great Britain and a German touch. This is a few different varieties you confuse other languages. Might be supported, can use custom lis, which we might have a look at later. For now, all you need to know is we're gonna be using the U. S first thing list for this section. So I'll just bring that held down. We're really gonna be adding this code here to al skills dot Jason, I'm not sales direction models, e n us toe Jason. So basically, we're gonna be filling this animal details intent with the code you soul up there. So what I'm gonna do is we're gonna type this up, and you can follow. So right there we define that. We're going to be using a slot type of U. S. First name and redefining that sort type named animal name. Now it's filled some examples. There we go. There are a number of examples that we're gonna be using. So, basically, whenever we say the phrase give me animals about and then say a name, Alexa will interpret that we want to access the animal details intent and will also passes in the variable that we have supplied it for. Animal name. Have a look at how we're now going to implement this within the code itself. So we're gonna be doing is gonna jump back over into a Lambda folder. We're gonna happen. The intense and open up animal details we're going to do is just to make sure this is all working when I had a little bit of information that will basically allow us to pull the animal name that's passed him from a slot into our code. So it said that now, so just explain this line here basically need to confirm it every stage that we don't have a null value here. So we're looking for animals. Slot names. Look, we're gonna be going event to the event comes in. We're gonna check the request intent. We're gonna check to make sure that's not know we're gonna check to actually slots available. And then if that's available, we're gonna get thieve alley of animal name. We have to do this because if we don't check from no value here and we try to reference no , we're gonna get an error code. He we're gonna pull out the value of animal name slope into a variable animal name again. We have to check for a null value. An animal names local value. And if we returned a or if we get value, gonna return, animal man. So now we have a function. It will allow us to extract the animal name from the slot. What we need to do now is basically reference that within al exports up the top here, that's right. Now a lot of comment. You know, this handling input, that request invalid is just a sort of common uh, very well, but this is actually what's past two l in 10. Handler, uh, don't need to know about too much, but if you printed this, you get a huge Jason basically object full of all the data that's coming in from the Lexus sdk today. So we're gonna be accessing the handler employed that request influence. This is where all the request information comes in. And we're gonna say that to variable within this is very possible event to the get animal name event function that we work down here and we're going to return the name of the animal that we get here. Everyone is gonna replace all speech, text something else you just want testing. What we're gonna make sure is that we actually do get the variable of the animal through on in this section. We're just gonna be testing to make sure we have set up slots correctly. I should also mention that the building here with simple card is basically the word or the phrase or the text that displayed on the Alexis screen. If you're Alexa, Device supports a screen, and that's everything we need to do. For now, What we're gonna do is we're just gonna say this code. We're gonna open up another terminal in the root directory off our project, and then what we're gonna do is run, Ask deploy how schools should not be deployed. So what we're gonna do is run another simulate command in order to test to make sure everything's working to do. This will run out, ask simulate open catalog database with the language ian us and will force a new session once we confirm that that's all worked. Okay, we're going to run next command, which will be ask simulate with the text. Describe Felix. Monetary changed this to let's just have a look to make sure that much is our model. Describe. So here's what we're gonna be triggering described with the animal name. So we do describe feelings, making sure that the name that we've got here is actually an animal with another device. Fantastic. And as you can see, we have returned to the speech animal details for Felix. So it has. You might not seem like much, but we've what we've successfully done is we've passed in a a name as part of our utterance on Amazon, has picked that up and has sent that in as our slot, and we've upended that slot value to the end of all Frasier Animal details. Full name. In the next video, we're basically gonna have a look at how we can start to do a dynamodb look up using the name that we get from the utterance from the person. So see in the video 16. DynamoDB Lookup: Welcome back, everybody in this video we're gonna have a look at how we can start to use our slot That we've returned a value for in order to do was to do a dynamodb look up and returned a description off a particular animal from our dynamodb database over the Lexus Skill. Let's get started. So what we're gonna do is what you're gonna create A few files that you might recognize from our previous database sort of sections will create a convict for spilling out into our custom folding. We're gonna go new, great config dot dress, and this is gonna be quite similar to our previous conflict. Dress will go to the court now that because it's pretty straightforward, we're gonna be defining our table name, a region and a p I version baby evolution just allows us Teoh, until the AWS sdk how we want to be querying the version of Dynamo. It's quite important because if dynamodb changes the way that our handles a queries, we want to be able to define which version we want to be making up. Where is under for our next time we're going to do with into custom director you've been a great new Folco, Hugh tills dot Js And we're gonna place in just a little bit of boilerplate code here as well. It's basically a What we've done is we've sort of set up this utility class for our being up to make queries to the dynamodb. Instance as we're gonna start to populate a small function that will basically allow us to query our, um, I'll database for his example. So let's have a local. We're gonna don't want to be. We're gonna going to be taking the animal name from the database. We run out. Queary. Let's sort of stop by actually writing a new function. I'm gonna make a function cold, gets animal by name. We're gonna pass in the name and a call back. We need to pass it to call back here because their request we make is going to need to be a synchronous. We're gonna have to have a promise back in our original code that went fulfilled. Will wealthy Alexis skills code to continue again? How attribute values here instead of us defining it in the code as we did in the previous database example. We're actually gonna use thieve value of name that we pass into this function Get Annable by name. So basically gonna be checking to see if this name here is available within the database. And here's where we do the check to make sure that the animal name that we get past in is equal to the animal name within Dead vice. And we use an error function. Basically Paulist the output of eight of the air or the data to a small section here where we're gonna eat that, do a bit of logging and then passed back the data fire. Colback. So basically, here we've we've checked to make sure that so if we have an error or out data is undefined , which is gonna throw an error. And we love that up. The consul's weaken debug. Basically, if it succeeds, we're also going to print out the console, have Why not? Just aren't sure if we've actually got a felon value back yet. So now we need to check to see if we actually did get a value back from Oh, sorry. Here was saying that if we do have a value, you know, Adam Count, we're just gonna return the first value in the array. Unfortunately, this does mean that if we do have to animals under the same day, it will only return the first animal help for this Exercise it. This is how we're going to be continuing board as a unique identify is the name of the cat or the dog or the other animal. And that should be all the code we do need. I'm just gonna close up a few of these brackets. However, it's not necessary. And I'm just going to reform it. This sure, its old nice and pretty. And now next. What we're gonna do is a pains to our animal details. Don't Js in order to implement this function here. So we're gonna go in tow. Intense general details. We're gonna right a little bit of code to start with. What we have to do is actually bring in Al, uh, constant. So we're gonna bring it out, you tills and the next under all handle, we're going to make a few big changes. It's gonna start to copy in civil code. Gonna copy this in. It's relevant, and we're going to just add a few variables here. Find speech, text and I'll re prompt. Explain what re prompters in a second. It's basically if the query does fail, it'll prompt the user for and it lost the user. Another question noted to entice them to ask what you re try, they quit their question query. So now we're gonna do is we're gonna implement this, you tills functions, Gonna get you tells gettable, Brennan, we're gonna pass in the name that he actually got from our slot here. We're gonna check to see if the animal that we get back, uh, is not undefined. We're gonna set off speech tickets, just eagle to the animals description. That animal description is again just to remind you it's gonna be taken from, uh, girl database. It's this description here, and if we don't find an animal, we're just gonna let theism to the fact that we did not find an animal under that name and he is ah, re proper comes into play. Basically, all re prompt is what the usual here if we are stuck in this intent, and Alexa needs to get them to trigger this again, So it's a way of just reminding them that this is how you can actually asked for information from this animal details intent again, Which is gonna rebuild our response builder. It's not talked out here. Basically, just copy in this to get rid of this return intent that and then we need to make sure that we add out reprint passing, you know, really prompt specialises all correct. Name, speech, text response. And then the last thing we need to do is because we defined our response because this is actually a promise. We only want a return it when the promises filled, we're gonna go resolve, response. And what that does is it means that it will treat the response as a promise and it will wait for this utility. I just call back here to be fulfilled correctly. I know what is governed 10. That should be all the code we need. So what we're gonna do is actually redeploy this and make sure it's all working. So again, open up a terminal, make sure Mr Brick directory here and we're gonna go ask deploy. Excited. A ploy was successful. Let's run out. Asks humiliate. You know, just open up the catalog database again. Asked simulate T open catalog database. without language and divorce in your session. Looks like it's open it. So let's now asked to describe Felix, as we can see here. In our response, we can see Net pod or play play hard in that part of my body. I get along better with other human playmates than my kitchen ones. And we can also see that all re prompt is set to one to check status than animal. What is the back story clicks so you can see this has actually pulled the data from our database, which is excellent. So what we're gonna do? You basically wrap up this lecture and we're gonna move into the next sort of series of actress which arm or intermediate, we're going to start to look at the more more advanced sort of features off the l've Alexa and ask STK soc Insidious 17. Response Localisation: Welcome to the next section, guys. In this sort of sort of syriza videos, we're gonna wrap up the based development off Al catalog database. Alexa Skill. Now, to start with, we're gonna actually have a look at locale. Look, how is really important because it allows us to develop Alexis skills in a way that works across a variety of different languages and regions all over the world. I mean, it gets to you started how you can separate your projects into multiple accounts were gonna be focusing on two different languages for this section. Gonna look at us, English and a you in English that you should say, mostly because I speak English and it might be a little bit, well, confusing if I stopped do a few different languages. Let's have a look at what you do. So if we have a look at the models for here, we have our ian us. Basically, we need a a way of it separating at these out to be four different languages, and this is actually quite easy. What can I do is copy it across. Change the name. I'm gonna change it to E N you. Now what we've done here. Is we basically separated a second model for the Vienna You. So the Australian version off this skill, what we're actually gonna do is we are gonna keep majority of this the same for now. Bear with me what's going to do with the jump down into the school. Stop, Jason. And we need to make sure that we referenced this new locale under this locale section. Here. Notice the that direction do is quite simple. It's gonna copy the bn us fields down here, as you probably expect. What is going to change the U S. To be a you? We won't make a small change. This, uh, you know what? It's probably fine if we keep this the same. Just make sure that you need to have thesis the same sort of setting set up for both. Look, house, in order for this to work properly. Next, What we're gonna do is we're gonna create a new file for handling the variety over responses that we want Alexa to throw it back at us based on the regions. So, as an example paper. Really? Maybe we're in Australia, and we wanna have likeable laid back in chill, Alexa. So you want to say CIA when we sort of exit this skill on may be in the US, We just want to have good bye. This is something we can actually do quite easily by adding a resource file in order to manage different sponsors within our code. So it's going to actually do this now, but the custom folder wouldn't give file called resources Duck chess. It was in this file. We're going a little bit of code boilerplate code to start with. Let's go over this code. No, what we've got here is closest. We're back up. We've got to resources set up on you can think of resources. There's a group of translations for a particular language, so you can see we've got sort of a list inside these court translation and the way this sort of, uh, sort of resources utility colossal work is we're gonna pass it in a locale when we possible locale. We're going to return a list of translations to the Alexa Asian from our intense code to make a little bit more sense in a second start with what we're gonna do is what you're gonna be replacing some off the code within our base intent four stop. Okay, so here we've got the word goodbye. Which is gonna be replacing this with some code within our localization sort of set up here . So we'll do. Is wipe of this bracket will add a comment here just to find that we're going to create a new translation, one of our intense and we have to give the key that we want to reference it with. So we're just gonna go exit skill and then we give it the translation that we want to supply to the stop intent. In this case, it's just gonna be goodbye for the U. S. It's actually quite similar for the Australian one. Just paste it in. How would have to prove that it's actually working? We're just gonna replace it with CIA. That's pretty much everything we need within our resources file. So close that one off. Now, within our stopped at Js, we're gonna make a few small changes this in order to replace this speech text and get it to pull in. Based on that, you look out festive first, what we need to do is actually pull in the low cattle off the users agents. We can get this from the event variable within the headless input he is we're gonna see is we're actually gonna bring in that new classy right resources. And then this variable here is gonna be set to the translations. So we're actually gonna pause in the locale which we could get from event request Don't locale. And this pulls the locale of the user who's using the Alexa skill. So if I am using Alexa would in Germany, it will return the German locale to this request here, and it'll pass it in Teoh Al Field here. So it'll be passed in here. And this is the locality uses a key to pull the resources from this section. So if you want to add further, sort of, If you want to add more like house to this, what you can do is just add in another field here and you could go in Di VI or something like that. Whatever. Look how you want on, and you can begin to stop writing different translations and you can manage all within one place since that, having to go through each file individually. Finally, you put text. It's much easier this way. Just sit within that resources field now is what we're gonna do is that she replaced this speech text. So instead of writing good bye here, we're just gonna go rez dot strings dot exit skill. I'll just explain what that is. So that raise again. It's just a reference to the old trick that's returned from here. Strings is the key here. Translation within a translation field, we're gonna grab this index item exit skill, which really be goodbye. It will see a based on we fled cowering again. We'll make sure we passed speech. That's their. And then, instead of having a simple card here, we'll get rid of it and will do Ah, and replace it with this should end session. It was true. This is basically saying that the house session for our skill will just end. An obedience school should close off. It's now let's test to make sure this is all working again and open up a terminal again. You guys be any pretty good This you do and ask deploy. We should have deployed working. So we're gonna do is we're going to now simulate opening the catalog database with the language he and us, and we're gonna force any session. And now we're gonna exit skill. And to do that, we're just gonna prompt end. And again you have to pass in the language in us and we should see goodbye as expected, because that's the translation for the U. S. Equivalent. Now, what we're gonna do is gonna rerun this, except we're going to do he and a you for driven it as an Australian. Look out and we're gonna run the end again. Except again, just does this. Really. And we should say that Britain text is CIA for Australians. Excellent. You know, it's all working now we're gonna start to do is look at attributes in the next section. So I'll see you then. 18. Session Attributes - Name (Model): Hi, everybody. Welcome back in this video we're going to start to look at attributes and how we can use them in order to save crucial information about the person that interacting real skill. Have a look of the architecture of what we're about to do. We want to add a way to save the name of somebody who is interacting with our school. So, for example, they'll open up the catalog database. Alex's go, and we're gonna ask the person, or the person will say, my name is And then they'll said your name. We're gonna store that name value that they give us within attributes within our Alexis skills. Attribute tree. We can use data within the light attribute tree in order to make decisions as repressive skill. It also allows Alexa to be a little bit more personal. She's able to reference us by our name and say things like, Hey, Nathan, how's it going? He's the answer to your question, things like that. No trophy this. We're gonna create a new intent called the change Name a tent, which is going to take a name slot. However, we're gonna add a little spin on this and we're actually going to be working with dialogue flows. And we're gonna give Alexa Theobald iti to ask us questions in order to fulfill and Phil and populate data that she wants in order to progress. In no case, how name sitting and started to is gonna pop over to El Models files and we're gonna open up e n dot us. We're actually gonna be adding a new intent. And this intent is going to be the change name intent. Let's do that. He's gonna put it down. The bullet here is gonna be quite similar to the one here. So being a copy across these scared samples and her name is going to be just name, we're going to again use Amazon US first name and we actually provide some samples here. This might seem a little bit a little bit off a repeat. However, it's important as it is. These samples are ways. That's so when we trigger the dialogue tree, which I'll show you how to work within a second. You use these samples in order to confirm that we have fulfilled the data value that were passing into this intent skin samples at dawn. So go down with samples here, and we need to add a couple here, this copy and across. So again, you might see something with the strange. We have name just fine. We got my name is change name to in the name, but we want for this field here. Change name. Now, When I actually causing data into this, this intent will fail, right? Not exactly. What we can actually do is create a dialogue and a prompt in order to tell Alexa that what we want to do is actually ask the user for their name for the crescent, progressing further from its intent. Okay, now I want to do that. We need to do is create a, um we need to create a dialogue that we're gonna licit from this intent. So we're going to just after. Make sure in the right block just after this, huh? Off this intense walk? You, uh, no, the intense book here. So just after this language model, it's too from the bottom. We're gonna add a new block. It could. Now, I'm gonna call me a lot of this in because we don't want to spend a lot of time talking it out. Basically, we're going to head out. So I love to start with Donna. Look, just references and 10. That's the change name intent. We're not gonna have a confirmation because we don't want to ask the user. Are they Sure that that's correct. Don't worry about prompts. For now, we're actually gonna define the prompts in their slots. We're gonna have a slope that slowed his name again. This is a lot of duplicate se elicit ation required. And that's basically saying that, uh, but Lexa will elicit this dialogue tree, and this solicitation idea can actually be. Could be pretty much anything you want. It just needs to unique, uh, neutral school. So we actually just can't provide that, because it makes little sense to us. Finally, we need a prompt. Now, I promise you a reference by an i. D. This idea just needs to match the elicit station here. We're gonna have Alexis and Variation. So when should she asks us questions to fulfill the data that she needs? She soon Oscar sent a variety of ways. So when I've always gonna get the same static responsible, she might ask us what is your night or and your name? She was getting a variety different ways. Keeps it, keeps it unique, Keeps it fresh. Next week. When I felt seminal we're gonna test to make sure this whole works. We're gonna coffee everything in this in us, into Vienna. You and tremendous course were basicly have to make sure that these same Aziz, we need to make sure that the intense between both regions are identical. Then we'll do is run a hostile boy that the deployment things that successful now in order to test this for moving on, what we're gonna do is jump back over and t the developer portal for Alexa. That's about developing at amazon dot com forward slash Alexa within the console. Just make sure you select your skill hang out cases catalogue. And then I was refreshed. This page, from what we want to see is that out change name intent is in fact, you We'll get that click. We should see the utterances. We should also see the intense love is being populated without Amazon first name and then we will under a slow type. Sorry to change name intent under edits I Look, if we click that we should see our dialogue. Promise things is what Alexa will ask us if she wants to fulfill this slut. And there's some sample utterances which are very similar to the ones we have in the actual intent itself. I just want to make sure that this box here is slot required to fill intent is checked is basically means that Alexa won't move on from the changing intent until the information is being asked. So these there has to supply name before we'll move on and allow us to ask other things. That's pretty much everything we're gonna cover in this video in the next video. What we're gonna do is actually going to implement this within our code. So we're gonna add the intent code within Outlander function and start toe handle the incoming slot value within the 19. Session Attributes - Name (Code): Welcome back. Everybody in this video, we're going to cover adding the code toe link up, out change name intent without Landau how to get started. What we're gonna do is we're gonna add some new resources to out How could we have enough resources? So, Jess, I'm gonna add some translations we're gonna work entirely out of the in us to start with. And then that the end, we're just gonna copy it into thean at you. If you'd like to make some changes to make him a lousy by all means feel free. So let's get started. Then. We know we're gonna have a file called change name address, so we'll add a comment. You just indicate that we're working with We're gonna some confirmation, You hear? Basically, what we're gonna ask is welcome. And they were gonna substitute in the name of someone we're gonna use this variable this curly brackets with number in between to substitute a value in. We'll get to that in a sec. Okay, Now, this line is a bit to take in this prompters. Basically, we're gonna pin this after we say welcome. Basically reminding the user that I can change the name at any time we're gonna add. This varies here. Break time 200. This is basically gonna force Alexa to take a breather for 200 milliseconds and hear what we're using is our speech synthesis markup language or S S M l for short looks a bit like a this XML or HTML is actually a good documents on the Alexis documentation for speeches into this markup language reference guy that basically covers all the different sort of references you have the option to offer you actually get her to, like, do things like whisper, you can play audio break emphasizes. Interesting. You can get her to, like, speak up with certain things pronunciation. There's a lot of options here. However, just for this video, we're gonna be covering just taking a break. So it's jump back into the code. We're gonna add a line for a change we prompt. And this is basically just to re prop the user and remind the user of what to say. You know, if you change the name, Mr Reminder, we're actually going to take the court from here and pretty much just copy it down into a you as well again. If we want to make it more lazy, you can, uh Now we're just gonna leave with wages. Now that that's done, we're just gonna close that results to follow because we don't know that we're gonna add a new file to our intense hold him code change name dot Js. There's actually a lot of code to this, so let's just start talking it and I'll explain how it all works once we put it in. Okay, Now let's go through each line because there is a lot to take in. So again, we've added all you strict. Don't worry about that too much right now. And we just exporting a module here we're gonna be using or checking and running. Request intern name change name intents. We're gonna be looking for the intent that we just defined, you know, model change, name intent. If we get it, we're gonna handle it. Nothing. None of this is gonna look two different. We've found this in the previous video. We've basically possum locale to get a list of our translations. We're going to find a speech variable here that we're gonna populate slowly as we progress through this code No. Here we go. Attributes don't name this attributes variable here where we've gone constant attributes We're actually growing a reference to the input handlers attributes manager and getting a reference to the attributes. So the session attributes which I'll show you in just a second. It's sort of like a local local temporary data store where we can pass in data that we want to store while we're interacting with our school. So in this case, we did a reference to the actual attributes store on were actually going to append down name here by going, I treat some name having a new key name and sitting into equal to the value of events request intense lots name value. So we're gonna get the value of the name slot that we pass into this intent. There are actual speech to the thing we're going to say is just equal to how translation change, confirm. And when we go to don't replace zero, we're gonna replace that field zero without actual name here. So if we go back to translation, see how we went Welcome here We're basically replace that with the name and that's why we how we used the dot replacement a deal. We're also going to say if the temp variable name prompt is not sent, we're also going to upend the words speech. So we're gonna add to the actual speech. I'm gonna add the change name prompt. So we're also going to add this line here. So we're gonna basically say, Welcome, Nathan, You can change at any time by saying change name and they were going to set that temporary variable for name property. Go to true. This is just letting it likes Unknown alto asked for a name again because we've already being asked it. And we don't wanna have to be told this over and over and over and over and over again. Because if we use a skill a lot, we know how to use this girl. We know that we can change your name at any time, so we only want to prompt for it the first time. These up. It's a skill what is gonna add out reprints. It's gonna load in every pump from all string translation and for this example, which is go to a pendulum re prompt 12 speech as well. So this to begin, say, Felix, please go to opinion that it's the first time is asking what this intent runs. It's pretty much gonna say all three of these lines and then continue as you could see speech pumped and get response. That's everything we should need for this intent. However, we haven't accounted for everything we need to delegate Alexa. The ability to ask us for our name if we don't give it or if we don't supply it. You know what to do that we're gonna have a little bit of code in between here syncopated. We'll explain how it all works, does it? So you might have asked. See, here we never actually asked. Well, checked whether or not the slot was equal time under find. And that's because we're gonna add this block. Now we're gonna check to make sure what we're gonna see If the's slots name is not provided and if this last name isn't provided, we can use the ad delegate directive in order to force Alexa to rerun this intent. So we're basically telling Alexa you have to rerun this of intent now. Event request intent said she's gonna rerun this intent. How it because it is a, um because it's being elicited by the delegate. It's going to ask us. Please give me your name. So, Alexis going to respond with us Also respond to us with one of the responses in the prompts down the bottom. Here I this What is your name? His name. Are you and your name? Basically. And that's what I could did us. That should be pretty much everything we need now for this, uh, noticed. Make sure it all works and jump back into our index. Still, Jess, I would have to gonna have to bring in this new custom intent animal at it as a request handler, once we had does your request. Handler. You know the drill. We're gonna open up terminal and we gonna brown Ask the boy now that we deployed, let's launch how simulator. Yeah, we'll go ask simulate. It's gonna open up. That skill then we're gonna do is we're going, Teoh, ask simulate, and we're just gonna took the words. My name is Nathan. I'm probably going to see this fails on. That's basically because we haven't initialized the attributes properly, but that's fine, because we can actually see that all session. Actually, it is being set to Nathan. So that code within our change name is indeed being executed. And it is actually sitting attributes Nathan equal to the right value. However, we need to revolt next year where we're gonna look a interceptors where we're gonna initialize all the attributes arrays end. So the lists before this intent runs, we'll look at that in the next video. 20. Request & Response Interceptors: as a going everybody in this video, we're gonna start to look at request in response Interceptors. Now we hear news interceptors in order to get Alexa to make changes before or after an intent is cold from user. So it's a good way about allowing us to sort of set up everything before fulfilling an intent. Let's up the code in sort of a much nicer way before we get into writing too much. What we're gonna do is similar to how intense folder, which only create in your folder cold interceptors. We're doing all this because we need to work out a way to initialize if we have another look back inside the intense folder here where we go attributes stock temp propped on. We're checking where we do this. Check here. We're actually gonna get a fail because what we want to do is we want to initialize this value equal to false using an interceptor before we get to this block. So again, under this interceptors folded here, we're gonna create two new falls. We're gonna create my request Deceptive cold request of Jess, and we're creating a response. Interceptor called response to address now within our requesting Deceptive. We're just gonna add a little bit of coated trying to copying from another place. And within our response interceptor, I'm gonna copy in a similar bucket code. I don't give you a few seconds just to copy. Holds out. Yeah, request president. Now let's jump back into the neck stretches. Let's connect everything up before moving forward. So any kind of comment at the top here does it. And now we need to attach these two interceptors to our skill builder, and we can do that. But adding another line down you cold ad request interceptors, and we'll simply add out Request interceptor and similarly response, Septus. Well, I don't response Interceptor. And that should be everything we need to do, you know, set up the basic boilerplate. Next, What we're gonna do is we're gonna open up. I'll requesting deceptive. We're gonna write some code. That sort of initialize is all the variables that we need within Al Alexis Gill. So let's add that now. We need to find out what streets manager session attributes of these local attributes of the whole session. I you what we say the name, attributes and our first relevant read it to a check to see if we have initialized the session attributes already. And if we haven't? In other words, if such an attributes or equal to zero, we're gonna initialize them again. This is all temp Attribute where? Actualizing We're gonna add a flag to indicate that this is indeed a new session for any other intense that want to add a little bit extra dialogue if it's in your user here, basically, we're gonna add a counter called such attributes. Start sessions. It's a bit of a store. Any number of how many times the person is interacted with the Alexis Gil. How about this is not gonna be very helpful until we persist the data but within the vessel set up for later. And we're also gonna store reference to the uses. Look out. You said it comment. Just elects. Know that we are sitting over temp attributes and we use the set session attributes, pausing in the session attributes and then we results. And then if this, I guess isn't the first time that we evolve onto this senses of 30 sort of 3rd 4th are you feel like there's gonna be greater than zero. We're just gonna results straight away. So we're gonna move on and fulfill the intent. Not so. Request intercepted. Um, no. Its adult response into septum responsive receptor is going to be eventually responsible in order to go sort of responsible for saving our session attributes and persistent toe a database in the next few years Gonna cover them. But now we're gonna get everything set up in order to pull all the attributes together, save a little bit more information to it at the end of an intense and then move on. We're basically going to first check to see if this'll was indeed in your session and if it was a new session, we're gonna set that session variable are defined. So the next time we use a launches skilled and I'm gonna get all the new props, here's an interesting one. We could basically set a flag to indecision. And if we do said, if, like to end the session, begin four selects adequate. Just a way to allow us to force Alexa to quit within any valentines. If we like again. Another interesting thing we can do is we can actually save the last thing that Alexa has said to the user in an attributes, We're gonna say that in the attributes start temp at last response again. I'm not another nice to have that we might make you so of later on down the track. And here we're also going to save the last re prompt as well, just for convenience. We're just going to resolve this response, Angela. That should be everything we need. So what we'll do again? Open up, new counsel. Run, lost boy. And once it's deployed, we're just simulate opening again. We see some of the session attributes have been set sessions, ego, one locales being said and the temp has been also being set. Lost response. No, it's actually coal miners, Nathan. Excellent. And we should see that the response to welcome anything you can change your name at any time by saying change name to begin, Say, described Felix. We could see that we sessions you gotta won. The name has been set and pretty much all the responses. It means that so that is working as expected instead is good. In the next video, however, we're going to start persisting all these session attributes to dynamodb because right now , every time a relaunch this we're gonna end up with the same section attributes because we're not persisting or loading them. So CNN video. 21. DynamoDB Attribute Persistence: Welcome back, everybody In this video, we're gonna look at dynamodb persistence, which I think is probably the coolest part about the ask kit because it allows us to save session attributes for each user to dynamodb instance and load them in and say Come back as we move through Intense. It's really powerful because it allows us to remember things about uses in between sessions . Let's get stopped. What do you start with this? Actually install a few dependencies. Gonna need not to run this To do that, they open up a new terminal, we're gonna make sure that we're in al landed directory. We're gonna open up and see the into custom. It's again. You should have be in this directory here and then you're gonna do npm install. Ask sdk Tanamor db Persistence Step two that should have worked all day Was will open a Palander close this one off. Just make sure that you have indeed got the Oscars DK persistent stabbed A listed here. If you do have issues in this section, I highly recommend that you list and use this version that I've got to find here along with the versions I've got to find tearfully asked us. You can call and ask us. You might take a model If you want a locker version, you can just remove the up our from here and just defined it as 2.3 points here. What is close That myself. What we'll do is now under custom. We're gonna hook up Al Conceit flow. We're gonna add a few more lines talking football, basically here. What we're doing is we're creating a new array of items. A list of items in Devi adapter. We're gonna create a table name can a look skill. This is gonna be the dynamodb table name. It gets created to store our session attributes for a petition key. We're going to supply the use ready because we know that's gonna be unique. Thanks for the attributes key. We're going to supply the map attributes. That's just the name of the field with Al Dynamodb where we're actually gonna stole the attributes and then the index will. The primary or partition key will just be the user's unique idea, which is a really long identify for each user. Use Alexa, she'll we need that now. What we're gonna do is when I open up Index O. J s and we're gonna initialize the persistence adapter. Now, to do that in a scroll, the very top we're gonna add new reference to configure because we need to collect configured variables and then just down the bottom here, underneath out skill builder here Actually, we'll put it just above it. So you bring in the persistence and kept his reference initialize idiots himself the persistence adapter and he risi defying a table name lead for Barca Fig the partition key name again from the config again for, like, a big practice his name and we'll pass in this, like create table is equal to true That I should be just tells the Alexa skill to create the table if it doesn't already exist. Finally, we need to do is actually link up this persistence adapter to ask your builder. So we'll have another, uh, field to the builder here called with persistent Stata no passing the TV detector and that everything we need to do to initialize this This is his reference duty Dynamo DB Instance. Now what we're gonna do is we're gonna retrofit that persistence into our how session request. So under the interceptor just under our requests, we're gonna add a little bit of code in order, Teoh, get Thesafeside persistent attributes and load them in. If we can, we're going to change these just slightly. Here's the interesting part. We're gonna go dot get persistent attributes, and then we're gonna get the persistent attributes and we're gonna run this afterwards. It's them within out. Then we are pretty much gonna copy in most of this. The only difference is now that we've got access to this attributes field here, you can replace the session attributes. Yeah, And here and here. So this is basically loading in the attributes and then initializing them if they aren't already available, That's what Good. Now I was gonna add a catch. Where we passing the error We're gonna reject now. The brakes were fitted that in What we do is when it closer request off. We're actually gonna slightly change obsession end. So under intense, uh, base session end, which is going to add some logic that allows us to save Al, uh, attributes back out to the persistence later. In order to do that, we're going to slightly change this function. Gonna change this council log Busy, say session end with the reason, Lovell and it's also saving attributes. It's reform on this. Gonna let the session attributes into this variable. We're gonna set the temporary attributes start to find, and then we're going to set up a snatch, buttes and then save the persistent attributes. And that should be all the code that we need within our session end in order for that to work. So what we will now do is well, you guessed it looking about command line and we're going to run osk deploy. That deployment is successful. We're gonna do it, actually, open up. This seem no less age. You might not have it, but I'm just gonna update it with the new commands. We're gonna run again. Don't stress too much if you don't have it. I'm just using it as reference. Akopian else s command. Now the first command monetarily fail. Uh, this is just a glitch. With the initialization of the database, you might find that if you re run the command in bulwark, it's what will. Those were clear And this should only ever happen. Once when you're deploying your skill coupe like I said now it's looking just fine. So what we've done is forced into employment going to say that my name is Nathan. What they should do is populate the Nathan. Actually, these attributes are still not persisted until we end the skill. So what we'll do is we do ask simulate end. It looks like we did have an error. Just a quick update. Guys actually found what the issue waas um end and exit. There was a lecture was able to distinguish end as stop. So what we've done is you can use exit, you get the correct response. So again, try this again. I'm gonna open instance until our name and Lola name Endemol exit. And what we should say is that the session and request wasif user initiated and everything should save off to the date of ice sole request response. Open it up as we could see, uh, Nathan successions cause I've run a few times and use ready. So that is all work, you know? I'll see you next week 22. Dynamic Responses - Timezone Awareness: everybody. Welcome back in this video, we're actually gonna have a look at time zones and dynamic responses. So we're gonna implement a couple utilities that help Alexa respond in ways that are a little bit more dynamic and flexible based on, for example, the time zone you're in and the time of day. Let's get started on this one. I really need a few dependencies. Boy, begin. So all those weapons terminal in the custom photo again, we're gonna end install to dependencies by going npm install https and moment times I and again just to let us know I'm using versions off moment time zone 0.5 point 23 hitch DPS Our vision one. If you have issues with your code, just double check that you actually using these versions to find here. And remember, you can remove the error up to define a specific version. Ever recommend you copying the dependency they've used? If you do, you have problems. It's next. What we're gonna do is we're going to open up our utilities file. We're actually gonna add those imports the top. So just below this visits DK, we're gonna add some imports. Perfecter No, that's, um, stubs for two new functions that we would like to add. Just copy them in. We're going to add a function called get greeting, which is going to return the joint greeting based on the user's time zone and a little bit of a few other pieces of information. And then what we're gonna do is at another local functions that's outside of the modules Export just called function. Don't get user times that now. Let's get started before we do, though, let's actually jump back into our resources file and add a few new translations. I was gonna copies translations in to save some time. Basically, we're gonna add a new look out. Uh, would be translation for the launch for welcome. So it's going Teoh visit. They welcome you to it on. Then we're gonna have a re prompt and will also add some translations for the utility to use for Good morning. Good evening and good afternoon. So, basically, just gonna say good morning. Good evening and good afternoon with a little bit of a break afterwards and again for recording, copy them down into the look out for Australia as well and covers And that should be everything we need in our responses. Let's move back into our utility class in order to work on adding our get user time zone. So this sort of field down here What? We're actually going t o be just double check outs, right? Get his times and get used after really gonna use some code from eh? Just to save time causes a big block of code. You can get it from Bentley B A T T l y forward slash to capital P. You careful r E capital? Why Capital G and it's called fire. Could get user times. And Jess, I actually got this code from a fantastic user GS driver. Get hope. He does a lot of Alexa sort of things. He's fantastic, highly recommend checking out. So the stuff he does, he does look good practices. And he writes really a lot of really helpful utilities, and in this case, we're actually using one of his utilities, which allows us to get the uses time zone from the Alexei p I. So we'll do. Is we'll carby in this entire block code go back to here and basically just paste it over the top. Um, I would go through this too much, but basically, we defined some options for our kids to be request. Uh, were we basically defined up the past? The path is out of ice. I d the person's device. I d and get the system time zone from the person who's actually making request. We can pull a authorization token out from the user's event context. And this part here is basically where we strip the data coming out of this time zone response on. Then Malcolm, form it into a payload. That's easier for us to work with. And then we run the coal back where we actually returned the time zone back up to function Topia. So what we'll do is we will just jump back up to the top here. Now, let's write some code to actually. So they changed the way Alexa talks. Based on that time zone information, we just got so just above here, we're gonna go bringing all translations. We're going to the hour off now. Now, this is gonna be the hour based on the location with the Lambda is which hopefully will be in the same range as the person who runs the the actual, um, skill feats greater than 5 a.m. and less than moon. We're going to say good morning. If it's afternoon, I'm before six. I will say good afternoon. And if it's any other time, we'll say good evening. Then we returned the greeting to the gold back. Also, just return a blank string so she doesn't say anything, and that should be everything we need for this code. However, now we're going to move back into our launch intent. We're gonna open up our intent, open a launch. We're gonna slightly change it. So it is able to utilize this new functionality that would build actually gonna add a new or statement here. We're going to check to see if he session sequel to new this again. It allows us to be able to restart the Lexus skill from within the session attributes if we would like to, and we actually would be replacing pretty much old occurred in here. So I'm just gonna delete this now opportunity promise on the way to call to get greeting and then use air a function to push the results into you. We're going to return D greeting. So basically for your good morning. Good afternoon. Good night. We're going. Teoh, substitute that in just in front off the launch date here. So we're gonna say good morning. Welcome to Kellogg Getaways. So good evening or good night, and we're gonna set up a very prompt and the result. Our response. Well, Khloe's old at off and it's that time again. Perfect also. And run. Ask Deploy worked. So let's run simulation to open to Davis. We should see again the responses. Good afternoon. Welcome to get look Database. Please say your name to speak. And during different times today you should get different sponsors. Just remember to note that this response will be based on the Lambda where it is being executed. If you use the lander in different regions, you'll get a more accurate response in this Good afternoon in the next video. What we're gonna do is actually now, we're gonna clean up a localization, get everything looking and feeling really nice and beautiful. 23. Localisation - Cleanup: Welcome back, everybody in this video, we're gonna start to clean up the localization. So we're just gonna basically go through our code and add some translations where we might have missed some. When we first of the project to start with, we're gonna jump into resources and we're going to add a another basically had some translations for a few of our sections. So we had one for the, uh, animal details intent. And we are going to add 14 hour help intent as well and again, like, is it? We're going to have to have the same code in our So basically, we've got animal details. Animal not found. No animals found under the dame, blood and animal. More employers want to check the status. Say, what's the backstory off and then the animal name. Then, like I said, we also have the help, which is? I wasn't able to understand. Previous command again, we're pretty much is pulling out the help function that we've got, you know, index suggests and moving in translations. So we are managing or translations in one spot. No pre pumped want information about animal, say, describe feelings, Justin. Example. So now that we got out recent since all set up this trump into all help talk, Jess. Um, so if we go under intense help, let's make all the changes we need in order to get this all working. I just thought with were actually going to replace how can't handle it. Sophia, with a slightly altered locker code. Basically, what we're doing here is now, instead of checking just for help and intent requests, we're also gonna check for the full back intent. So we had this line for the fullback intent. It means that if an intent wasn't able to be completed correctly So if all those fails, the help will trigger, which is exactly what we want, because it'll guide the use of back onto the right path. If they do stray away from the path basically next, What? We're gonna two years. We're going to pretty much replace most. This was giving a speech text there, and go make a note saying that we're going to check to see if this was a fullback intent and do something slightly different If it waas especially used to slightly different here. We've gone. Rays don't get string instead of just going to strings. That's just another way we're able to do this. We can go fullback intent or help full back there. So basically, we are, you know, resources Folder. Pulling this helpful back here just in a slightly different ways. You get an idea of house, you could do this. And then we'll also just remove the simple card from here and replace that speech and re prompt. And that should be everything we need to now help doctor s. Now, we're gonna slightly modify our animal details as well. So you have animal details, and we're gonna make a few more few small changes. So just below this event here, we're gonna reference to the translations, the attributes She's gonna clean this up a bit My memory of these comments because we don't need them anymore. Then just here also said a copy of the last searched animal. The uses attributes again just because we can now and then we'll replace the speech text when we don't find an animal will replace the animal found on possum name that queried and this re prompt will also get changed. Pausing an animal mori for info so basically lowing the re prompt Teoh Probably use that. I asked for more info on a particular animal, and I think that is more or less everything we need to do here. Eso it's that time again goes open up that terminal and we are going to run mosque deploy. It won't worry for that's deploy. I'm just gonna copy In the new simulation, fans will be gazing into small here and what's the stun? The point will be running these We're just gonna go through and make sure each man's work still. Good afternoon. That's what Working welcome, Dyson. That's what working were able to describe Felix. And we can also see that the latest such as it is being populated with Felix. We're also will the exit. And then the last thing we're gonna test is if we go back over to the dynamite TV console. Just refresh that. What about the attribute map? We can see that that latest search is also being appended to the dynamodb. Instance For this user, I d That's what it could be pretty much needed in order to clean up localization in the next video we're gonna cover it is audio clips. So We're gonna see if we can add a clip of audio that we could get Alexa to play by using the SSN Mrs. M A L s M l A language. So I'll see you. 24. SSML Audio Clips: Hey, everybody. And welcome to this video on adding all your clips to our likes skill. Now, in this section, we're basically going to implement a few different audio clips that will allow us to make elixir play sound based on what type of animal we request from the database. Now, I've already uploaded for what he couldn't even use 23 bucket. You can access that at this year. All here. Just make note of them because we'll be using them with the code. Alternatively, you can. Dalat the's would eclipse yourself. I should attach into the video else you could tell it this year old and upload them to your own s three bucket if you choose to manage them yourself by your own s three bucket. Um, so let's actually go through and add this code. We're gonna be adding some text speech text to l get animal by name Field. So we're gonna drop back over in trial code and go through it together. Let's puking up. Outland up. It's open up. L utility. Sorry. No, in our utility, open up, out! Intense animal details field And in here, where we do our if animal basically What we're gonna do is we're going to append an extra field to this speech text based on the type of animal that we get. We already know we have access to the animal dot type field because we've done a query on the database. Now I'll talk if you remember back to l. Jason could be a variety from things cat could be dog. It could be reptile and it could be bird. There's four different times and I've got an audio clip for each of those types itself for you. So what, we're gonna dio gonna make use of the fact that that top field is always gonna be the same ? I'm going to add speech again. We're using the animal thesis RTs SML language. You know, let's do this. Uh, so he's the audio and we have to provide a source the source field. We're gonna provide that your ill that we had before. So let's grab that now and which is going to provide up to this part here? That's what we're actually going to do. It's gonna close off that some of your plus the ringer animal dot type plus, then two more the single court's dot MP three. It will close off the double court there, and then we'll add in square brackets and then a space. Oh, I think I've missed something up there. Let's just double check it. We don't need the civil court there. I'm just gonna move this across so you get a full, my dear, with the line lives like speech, text, and that should be everything you need for that. It's what's effectively going to do is it's going to upend the animal type. And because the MP three files are named off the animals directly, we can just pop that in there and we get the euro here. We're actually going. Teoh change. This animal description equals to be a plus, Sickles says. Now it's going to add the description after the audio clip and just going to you format this shoot cool and we're gonna close that one off. And now let's redeploy this skill open up terminal and we're gonna run Alaska. Deploy not support. We'll run simulation, say your name and then we'll describe Felix. And what you should see here is that the the response that we actually get includes this audio source tag with cattle and be three attached. It's not very interesting from command line, so it's actually test this from browser. We open up the Lexa, develop a council and just refresh this, you refreshed speed built because we pushed. Let's go across the test and again, maybe we'll just select English us for this. As you can see, we now have both drop downs with you got both models. We're going to open. Get a look database. She's gonna talkto us. Um, so now let's Oscar. My name is Nathan. It's welcoming me. It's awesome. And finally, let's describe Let's go with Sam will describe Sam. You should see a croaking rivets. Uh, that's the reptile audio on. Then, if you did a similar one for Describe Frankie or describe Special, for example, you'll get a bird in a dog Old Scrabulous, and that's pretty much audio clips. In a nutshell. It's another awesome feature off the SML language. There are a few others that are really interesting. You should totally go on school