creating Alexa skills for Amazon Echo

For the team's 2016 Christmas present Alick brought everyone an Amazon Echo Dot, and then we all used the devices as the basis for our Christmas hack day, right before our annual office party.

During the day we got 6 prototype skills under way, some of which we've got a few video clips of working, which you'll find links for below. You can also find a link here to a video which shows all of them working, as well as a few interviews with team members around the challenges they faced over the day.

Prior to the hack day, I put together an overview of how to create a skill for the rest of the team to work from, which you can see in the section below 'create your Amazon skill'.

the prototypes

The prototypes we worked on were as follows.

the main challenges

The main challenges we hit over the day were:-

  1. HTTPS. For us to pull data from staging environments running client's Drupal websites we needed those staging sites to have valid SSL certificates, which in most cases wasn't the case.
  2. Getting Alexa to recognise people's real names or usernames
  3. Pulling text as plain text from Drupal
  4. A Composer dependancy meant using the Alexa Drupal module wasn't as easy as we'd hoped, so that might be an area we look to help contribute more to in the future.

next steps

Next steps for us with Skills development are as follows:-

  1. Take some of these prototypes to fully live versions 
  2. Think about what other data sources we can integrate with

create your Amazon skill

Prerequisite

You will need to setup a secure server in order to host your project. It's easy to do this with Digital Ocean and Letencrypt, read more.

Go to https://developer.amazon.com and sign in with your Amazon account. Click on the Alexa menu tab and choose Alexa Skills KitAdd a new skill on the top right.

skill information

Name it miggle example, and fill in the form
For Skill Type, choose Custom Interaction Model
For Invocation name, use a short phrase of your choice such as miggle ;)

interaction model

Put in Intent Schema. You can find an example schema in the example directory of this project
Learn more about the intent schema

Put in Sample Utterances. You can find example utterances in the example directory of this project
Learn more about utterances

configuration

put in the URL of your endpoint.
choose No for Account linking

SSL Certificate

Choose the relevant option, if you've used Letsencrypt select the first option.

Click save and note down the ID displayed above the configuration form


coding your skill with Silex

Before starting you may want to look at the Silex documentation

Also take a look at the documentation for the Alexa PHP library

Back in the Amazon console, edit your skill and click on the Testing tab. Here you can simulate the requests that Alexa will send to your endpoint.

Make sure that you have the skill enabled for testing on your account, this will allow you use the skill on your Echo device.

Head down to the Service Simulator and try out some Utterances.
Even if you haven't set up your Silex app yet you can still test the skill and see what sort of request you will be expecting from Alexa.

get stuck in
  • Clone the example repository:
    git clone [email protected]:miggle/alexademo.git alexa

  • Change directory into the repo and remove the current remote
    cd alexa
    git remote remove origin

  • Add your own git remote:
    git remote add origin [email protected]:name/repo
    git push origin master -u
  • Pull down the dependencies with composer:
    composer install
  • Update the /alexa route once your ready to create your own skill
  • Make sure you add your app ID. You'll find this at the top of the configuration forms in the Amazon developer console.

testing your live skill

Now you can deploy your code live it's easy to test your work through a number of means.

Amazon simulator

This was mentioned before, in the skill setup on https://developer.amazon.com there is a Testing tab when configuring a skill. Here you can simulate how the skill acts on specific utterances.

Echosim.io

Echosim.io is a community created Echo simulator, it's similar to the Amazon simulator but allows you to test utterances via a microphone input instead of typing the phrase.

the Echo itself!

You will need to ensure that you have the skill enabled for testing on your account.


testing your skill locally

Postman is a popular app to help test your endpoints, you will need to setup a self sign certificate on your local environment and tell Postman not to verify the SSL in the settings.

If you want to take back control of your web sites and applications then get in touch with miggle to see how we can deliver operational freedom for you in Drupal.