paint-brush
Build cool Alexa skills with Echoism.ioby@arkin-dharawat
1,030 reads
1,030 reads

Build cool Alexa skills with Echoism.io

by Arkin DharawatJune 3rd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Amazon released Alexa back in November of 2014. Now it’s everyone’s favorite personal assistant. There are tons of tutorials out there (2–3 from Amazon themselves) on how to start developing on the Alexa. Now, you could follow every step and make the perfect Alexa skill, but alas, you need an Alexa to test it. I am going to show you how you can build almost any Alexa skill you want (and test it of course!) without owning an Alexa.

Company Mentioned

Mention Thumbnail
featured image - Build cool Alexa skills with Echoism.io
Arkin Dharawat HackerNoon profile picture

Amazon released Alexa back in November of 2014. Now it’s everyone’s favorite personal assistant. There are tons of tutorials out there (2–3 from Amazon themselves) on how to start developing on the Alexa. Now, you could follow every step and make the perfect Alexa skill, but alas, you need an Alexa to test it. I am going to show you how you can build almost any Alexa skill you want (and test it of course!) without owning an Alexa.

Getting started

The skill we will be building is pretty simple. We’ll give Alexa the ability to tell us whether a given a number is an Armstrong number or not. We will be writing all our code in Python 2.7. Here are the Python install links, if you don’t have them: OS X and Windows. Next, we will be installing pip, a package management tool for Python, download it here. Install Flask, a python mircoframework, by opening the terminal and typing.

pip install Flask

Flask-Ask

Usually when you build skills with Alexa you need to setup an AWS Lambda function. But say if you’re at, going through the effort of making lambda functions is not the best way to go. Enter: Flask-Ask, a Flask extension tool that makes it easy to build Alexa skills. You can check out more about it here


johnwheeler/flask-ask_flask-ask - Alexa Skills Kit for Python_github.com

Like we did earlier with Flask, use the same line in the terminal to install flask-ask

pip install flask-ask

With flask-ask installed, we create a file called flask_app.py which will hold our code for the flask server. In the same folder create a file, templates.yaml which will hold our speech templates.

Now with our python backend ready to go we can host it locally by typing.

python flask_app.py

This starts our server locally on port 5000. We also need Alexa to access to have access our server, for this there is a handy tool called ngrok. If you have already downloaded it, open a new terminal window and type:

ngrok http 5000

Your terminal screen should look something like this.

Alexa Skills Kit

Head over to https://developer.amazon.com/ and create your developer account if you don’t have one. If you already do, just login. Go to the Alexa tab, select Alexa skills kit and then click Add new Skill.

The first tab we fill up is Skill Information. Select Skill Type as Custom Interaction Skill, Name as IsArmstrong and Invocation Name as Armstrong. The Name here is our skill name and Invocation Name we call when we have to start the skill, example: ‘Alexa, start Armstrong’.

The second tab is our Interaction Model. This mainly describes how we will interact with our Skill. The first text box, Intent Schema, tells Alexa the various speech intents our skill will posses. Fill it with the following JSON:

{

"intents": [{

  "intent": "AnswerIntent",

        "slots": \[{

              "name": "number",

             "type": "AMAZON.NUMBER"

         }\]

  }\]

}

Ignore the Custom slot types for now. Under the Sample Utterances, put in the following:



AnswerIntent {number}AnswerIntent My number is {number}AnswerIntent Is {number} an armstrong number

Now hit Next and lets proceed.

While our Interaction Model is being built let us complete rest of the tabs.

For the Configuration tab, click on the radio button that says HTTPS and checkbox that says North America. In the text box, put in the ngrok HTTPS URL and hit Next. It should look something like this.

In the SSL Certificate tab select the option that reads, My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority. Hit Next.

Testing Your Skill

Now comes our testing phase. You should see a screen like this.

In the box that says Enter Utterance, let’s start by putting in our invocation phrase which in this case is, “start armstrong”. Alexa’s response should look something like this.

You can click on Listen and hear your response read out my Alexa.

Go ahead and type one hundred fifty three. This is the response.

Now, if you have an Alexa you can go and enable the skill there but that isn’t the point of this tutorial. Head over to Echoism.io and log in with your Amazon id.

Now hold down the mic and test your skill. Keep the Console open so you can see what’s going on.

Here is how my conversation went:

Me: “Alexa, start armstrong”

Alexa: “Hello. Welcome to the IsArmstrong skill. Give me a number and I will tell you if it’s an Armstrong number.”

Me: “Ask Armstrong if 153 is an Armstrong number”

Alexa: “Yes, This number is an Armstrong number!”

Conclusion

The skill we built was is pretty simple. Alexa skills, the good ones at least require a lot more code and lot more testing. If you want to go ahead and explore other skills head over to the Alexa store or if you have an idea and want to deploy your own here is another great tutorial: http://moduscreate.com/build-an-alexa-skill-with-python-and-aws-lambda/

Happy Developing 🎉