Video Transcript

Hey, this is Steve with Dabble Lab.  In this video, I’m going to walk through creating a simple Alexa Skill that calls an external API.  I’m going to do that using a template from skilltemplates.com.

This is another project that I’ve been working on.  This is a site that is going to share free Alexa Skill templates that you can use either to learn how to build templates or as a starting point for a skill that you’re building.  It is going to launch shortly.  If you’re interested in being notified when it launches and/or being notified when new skills are available, you can go to skilltemplates.com and enter your e-mail address and you will be notified when new templates are available.

So for today, we’re going to be working with a template called the API starter template.  And this is a simple template that calls in external API.  There is a working version of the skill if you want to try it out called Ground Control.  And it calls the open notify API, which returns a list of astronauts that are currently in space.  So if you enable the ground control skill, you can test it out.  You will just say “Alexa enable Ground Control.” and then “Alexa, open Ground Control.”  And then you’d hear Alexa respond with a total number of astronauts that are currently in space and their names.  And that’s what we’re going to be creating here today.

I’ll leave links to all the stuff as well.  There is a command that we’re going to use with the Alexa Skills Kit-CLI which you do need to have installed.  There is a link here to get it and install it.  You need to have that installed.  You also need to have an AWS Account and an Amazon Developer Account to make this work.

If you have those, you can go to the folder where you want to run it — I’ll zoom this in so you can see.  And then you would type in the ask new command and use the template parameter, but just leave that blank and then also the URL parameter.  But for the value where you’re going to use — you’re going to have http:/skilltemplates.com/templates.json, just like this.  And when you’ll run that you’ll get a list of available templates.

Right now there is just a few, there will be a lot more in the weeks to come but for today we’ve got the API starter, a basic starter, and then the VideoApp starter.  We’re going to be using the API starter, so select that one and that will create a skilled project and it will create it in the folder that you run the command and I’m just going to temp folder here.

The template includes all of the code that you need to make this skill work.  So at this point, you can literally just use the CLI to deploy the skill and it’s ready to go.  So if you just move into the folder that was created, so API starter and you can go ask deploy.  And this is going to deploy it so we’ll have a working skill.  And I’ll show you that it’s pushing out — it’s pushing the skill out to the developer portal and then also it’s going to deploy the Lambda Function to the AWS console.  And this is going to take a few minutes, so I’ll pause and then come back and we can take a look at the code.

Okay.  So it’s all deployed now and we can go take a look at what it set up.  So if we go out, we’ll start with the Alexa Developer Console.  So if you log in to developer.amazon.com and then go to AlexaSkills, you’ll see a list of your skills if you’ve already created some.  If not, you will at least see the API Starter Skill and this is the skill that the ASK-CLI deployed from the template here.  So this is the one that we’re going to be working with and all we need to do now is just test it.  So you can go to the test here.

Everything else has been completed from the template and enable testing.  Then we can try it out.  There is this new test simulator, that’s pretty cool, that we’ll use to do this test.  And this just lets you test now using either a command that you can type in that you’re sending to the skilled service, the Lambda backend or you can just use your voice, so just like talking to an Echo device and it will do that.

So the invocation name is API starters, so we’ll say,

Steve:  Alexa, open API Starter.

Alexa:  There are currently 6 astronauts in space.  Their names are Alexander Misurkin, Mark Vande Hei, Joe Acaba, Anton Shkaplerov, Scott Tingle, and Norishige Kanai.

So again, real simple.  It’s calling the API and the API that it’s calling is returning a JSON response that provides the count of the astronauts in space and then their names.  And so that’s what we got here.  So let’s take a look at the code.  So in the skilled project, if you go into not assets but to Lambda and then the custom, the code that was deployed out to AWS, the backend, the Lambda code is in here.  And you can see it’s pretty straightforward.  There is a method that is calling, making the HTTP request and this is the endpoint, so if you want to see what it’s returning just copy that, take a look at what’s returning here.

So you can see, it’s just returning a JSON response with the number of astronauts that are in space and then an array of their names.  So that’s what our skill service is getting back here.  So this is making the call, returning it back.  And then in the Get Astros function here.  We’re just looping through or grabbing the output from that API and then creating our speech output, which is what we’re responding back here.

So pretty simple if you want to use this as a starting point, this method can be easily modified to call another endpoint.  And if you want to just deploy the skill as is, you can do that easily enough by going into the skill manifest here and changing the name and you can change the description, you can change the icons if you want to do that.  And then the other thing that you would want to change is in the model.  You would want to also change the invocation name.  This is the name that is used to open the skill or start the skill, so you can change this to whatever you want.

And then you just simply, once you made those changes go back and do ask deploy again and your updates would be pushed out, so it is that simple.

If you have any questions you can post those and I’ll respond to those just as quickly as I can.  If you found the video valuable, please like it and subscribe to the Dabble Lab channel.  Thanks so much.