AWS GoT Hack: Alexa Skill

To recap, I'm working on a 48-hour hack to help learn about AWS.  My goal is to:

Create a "Game of Thrones" Alexa skill that allows the user to ask if a character is alive or dead, and RESPONDS WITH an accurate answer.

So, where to start? I could start with scraping the data off of Wikia (actually, it should be better than scraping as Wikia has an API to access content). Or, I could work on the database schema, if I need one.  Or I could look at development and deployment tools. But, to paraphrase Steve Jobs, I should "Start with the user". So, let's restate the questions and answers that make up our minimal viable product.

Q: Is {{name}} [[alive|dead]]?
A: [[Yes|No]], {{name}} is alive.
A: [[Yes|No]], {{name}} died on {{DeathDate}} during episode {{DeathEp}}
A: I don't know who {{name}} is.  Can you please ask again?

Q: Where do you get your data?
A: My data comes from the Game of Thrones Wikia at gameofthrones.wikia.com

We should be able to handle the first question and it's third answer, and the entire second question fairly quickly with our Alexa Skill configuration and a small amount of Lambda code.

Alexa Skill

First thing to do is go to my Alexa Skills on the Amazon Developer Console. I "Add a New Skill" and name it "Game of Thrones Wikia".  I also use that for the invocation name.  I'm not sure that Amazon is going to approve a skill that uses the names "Game of Thrones" or "Game of Thrones Wikia", but that's what it is, so I'll try that first.

Now I have to design my intent schema and my sample utterances.  An intent represents an action that is passed to your skill's service. It can include arguments, or variables, associated with the action. The sample utterances map actual verbal requests to intents. You can sort of assume the sample utterances are what Alexa hears, and the intent schema tells her how to pass the information on to the service.

Sample Utterances

Best to start with the sample utterances, although the developer console UI starts with the intents.

The second question is the easiest, so let's start with that: "where do you get your data". We can also cover some other ways the user might ask, e.g. "where did you get your data" and "where do you get your information".  It gets quite repetitive.  I hope Amazon comes up with some sort of shorthand, soon.

Warning: the Alexa Skill UI times out pretty fast, it's not a bad idea to refresh the page after you haven't been there a while, and to save whenever you update it. As a matter of fact, we should keep this data somewhere else, like in a Git repo, so we don't loose it due to the UI weirdness.  But let's leave that 'til after we get Alexa talking.

The actual utterances are formatted as the name of the intent followed by the utterance, so:

AttributionIntent where do you get your data
AttributionIntent where did you get your data
AttributionIntent where do you get your information
AttributionIntent where did you get your information

Intent Schema

The intent schema to match a single intent without any arguments is super easy:

{
  "intents": [
    {
      "intent": "AttributionIntent"
    }
  ]
}

It will get more interesting when we add our other question.

Configuration

This is where we tie our skill to the code that creates the response. I can choose AWS Lambda or an https end-point. Since I'm trying to use lots of AWS services, it makes sense, and I have sample code, I'm going to choose Lambda.

To specify your Lambda function, you use an ARN. You get the ARN when you create your function in the AWS Lambda Dashboard, so that's where we'll go in the next blog post.