To get my example working, you must request a Marta API key. Other transit systems may have different authentication workflows.
I used node-alex, but I've heard that alexa-app is really good too.
Build a class to query the transit APIIt is good to separate out concerns here and write methods that will query the API for train arrival data. I kept this code in marta_api.js. This is a great opportunity to write unit tests. If you want to build an Alexa app for a different transit system, you could easily modify this class in my project to make an Alexa skill for your transit system (provided that system has an API).
Deploy App to a Platform ServiceI used Heroku, but a lot people like to use the AWS Lambda service. Heroku lets you link your Github repo directly to the app. It will pull any changes you make automatically. In order to get it running you need to set necessary environment keys like process.env.MARTA_API_KEY. For my app, you'll also need to add a Redis Cloud service in Heroku.
Now you need to go create a skill in Amazon for testing. They'll ask you for an intent schema, custom slot types, and sample utterances. Be sure to provide lots of utterances! That will make the Machine Learning model more accurate in intepreting the user's input.
{ "intents": [ { "intent": "Marta", "slots": [ { "name": "Direction", "type": "DIRECTION" }, { "name": "Station", "type": "STATION" } ] }, { "intent": "AMAZON.HelpIntent" }, { "intent": "AMAZON.StopIntent" } ]}
Handle speech errorsYou need to be able to handle several different error states to pass the rigorous skill submission process. Walk through the checklist and ensure that you correctly handle situations where the user asks for help, gives invalide requests, etc.
Test your skill
Amazon provides developers with a built-in testing tool in the skill submission section, but it's also helpful to deploy your skill to an actual Echo device and test that way as well.
Submit your skill!After going through the submission checklist, submit your skill through the Alexa developer portal. The team has a 7 day SLA, but I've found that they typically respond within 3 days. Good luck!
My submitted Alexa skill can be found at Times for MARTA if you want to try it!
Comments