Build an Amazon Alexa Skills in 10 Minutes and Get Free Echo

2019-10-20

Background

This guide is going to show you how to build an Amazon Alexa Skills in 10 minutes by using python, aws and an information api.

In addition, Amazon is currently running a promotion for giving out Echo for free. In summary:

  • Publish your very first, new Alexa skill during the promotion period and earn an Amazon Echo Dot.
  • Publish three new Alexa skills during the promotion period, where one of them is used by at least 75 unique users during the promotion period, and earn an Echo Show 5 voucher.
  • Add the Alexa Presentation Language to one of your skills (newly published or updated) during the promotion period and reach at least 150 unique users during the promotion period, and you will earn an Amazon Echo Show.

Find more details here

What is the final product look like

To see what the final product look like, you will need to download the Alexa app and enable the skill Joke Teller

20191021221611.png

To Test it, simply say:

  • 'Alexa, ask joke teller to tell me a joke'
  • 'Alexa, ask joke teller to give me something fun'

It will return you a random joke.

Prerequisite Knowledge

  • Good understand on English
  • Good knowledge on using a web browser (Chrome, Safari or Firefox)

Guideline

Pick an API you want to use

Go through the API list in this link, I will suggest to start from a simple api that returns a sequence. I have picked the icanhazdadjoke api which will randomly return a joke, so my app name will be joke teller.

Register an Amazon developer account

Click this link for registration, fill in required information. You can use your Amazon account to log in.

Register to the Amazon Free Echo Promotion

Go to here and fill the promotion form.

Create your first skill

After login to your development account ,go to this link.

You will see something like this, click Create Skill:

20191021213921.png

Fill in the required information:

  • The name of your skill
  • Use Custom Model to build the skill
  • Use Alexa-Hosted(Python) as backend resources which is free in the AWS

20191021214205.png

Now you need to set up your Invocation name, which is the name that will active your skill. The name I used here is "joke teller"

20191021215011.png

After setting the Invocation name, we will need to set up the Intent. Add a new intent with a name. I used the name joke. Intent is something that will response the user's query. As we are only building a simple skill, so we only have one intent without any slots. Examples intent:

  • Give me some fun
  • Make me laugh

20191021215141.png

After adding few intents, you need to click save model and then build model.

20191021215637.png

Congratulations, you are almost there.

Now go to Code section -> Open lambda_function, and copy and paste below code to an empty space, change the "joke" to the name of your intent:

class jokeIntentHandler(AbstractRequestHandler): """Handler for shouldI.""" def can_handle(self, handler_input): # type: (HandlerInput) -> bool return ask_utils.is_intent_name("joke")(handler_input) def handle(self, handler_input): # type: (HandlerInput) -> Response speak_output = requests.get("https://icanhazdadjoke.com/", headers={"Accept":"text/plain"}).text return ( handler_input.response_builder .speak(speak_output) # .ask("add a reprompt if you want to keep the session open for the user to respond") .response )

This code basically returns a random joke by calling the joke api we just pciked.

20191021215925.png

It is also worth changing any wording you want to change, I believe you can understand this easily.

20191021220236.png

Finally, add below code at the end of the section, then click Save and Deploy

sb.add_request_handler(jokeIntentHandler())

20191021220407.png

You can now test your skill in the test tab to make sure it works. In my scenario, I can say:

"ask joke teller to make me laugh"

20191021220729.png

Publish Your Skill

Now we can start to publish our skill, go to distribution and fill the basic information.

20191021220849.png

One thing needs to be careful is the Example Phrases, you will need to make sure the example phrases are in your intent. For example if your intents are:

  • Give me some fun
  • Make me laugh

Then your example phrases can be one or both of below:

  • Alexa, ask joke teller to make me laugh
  • Alexa, ask joke teller to make me laugh

Save and Continue when everything is ready, you will also need to fill in both Privacy Section and Availability.

Please use the same example phrases as testing instructions in Privacy Section.

20191021221836.png

Go to Certification after completing the whole distribution section, Run both Validation Test and Functional test to make sure everything is OK.

20191021221247.png

And then go to Submission to Submit the skill, you skill will be in the Alexa Skill store after few days.

20191021221330.png

Summary

As you can see it is very simple to create the simple skill, you can be flexible on any of the API to make your skill more fun. According to the terms, you will receive your echo dot in 60 days.