/muni-alexa-skill

Simple skill for Amazon Alexa which will return arriving Munis for your stop

Primary LanguageJavaScript

MUNI Alexa Skill

Add incoming MUNI predictions to Amazon Echo's Alexa using this small skill. It's not published in the skills directory but you can deploy it with your own settings using AWS Lambda function and let it run for free.

Currently the skill only supports one stop and you need to hardcode the SFMTA stop number in index.js. Look up the nearest stop around your place using 511.

Adding a new developer skill

To get started, add a new Alexa Skill Set in Amazon Developer Console. Once you created a new app, give it the following settings:

Skill Information

  • Application Id - Copy this to index.js
  • Skill type: Custom Interaction Model
  • Name: Name of your choosing, e.g. "Arriving Muni"
  • Invocation Name: Command that your Alexa listens, e.g. "arriving muni"

Interaction model

For Intent Scema, set:

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

As this script is only invoced using the invocation name, no Sample Utterances is really needed, but as the form requires a value:

GetNextMuni lol

Configuration

It's dead simple to deploy Alexa skills using AWS Lambda, so for Endpoint select Lambda ARN (Amazon Resource Name). Now, construct your Lambda function with node_modules directory. This is required as Lambda is unable to pull NPM modules and they need to be bundled with the code. Please note that at this point you should have set applicationId and muniStop variables in the index.js:

git clone https://github.com/jorilallo/muni-alexa-skill.git
cd muni-alexa-skill

npm install
zip -r lambda_function.zip *

After this you'll need to deploy lambda_function.zip as a Lambda function:

  1. Login to AWS Console and visit Lambda settings
  2. Select Create Lambda Function
  3. Skip blueprint selection
  4. Set function name, e.g. nextMuni and select Node.js runtime
  5. Upload as a Zip file (lambda_function.zip) to Lambda function
  6. Use index.handler handler and select Basic Execution Role for Role
  7. Create Lambda function. Click the "Event Sources" tab and select "Alexa Skills Kit"
  8. Finally, copy ARN from top right corner to your custom Alexa skill settings.

Once you have completed these steps, and pointed Alexa skill to the Lambda function, you should be able to test your skill with your "Alexa, ask arriving muni". While this isn't really natural, the list of invocation words is still somewhat limited.