Create the Skill
Write Some Code
With the skill created, it's time to write some code! I started with this detailed introduction post from Brian Donohue which includes sample code and instructions that got me to the point of being able to shout "Tell Lorna ping" at Alexa (my skill is called "Lorna") and have her reply "ping ack". At this point I have both the lambda function and the Skill itself in place, and I needed to make it do something useful.
What I wanted to do: get a list of the imminent buses from the stop near my house. It's really helpful to know if you should run or if there's no bus for 10 minutes and you have time to also put the towels in the washing machine or talk to the cat or whatever. I know that 10 minutes waiting for a bus seems reasonable in many situations but I live near a main route into a European city so my standards are different :)
By watching what happens when I request the bus stop information on my phone, I was able to get a URL to a specific webpage with the current departures on it. This is a pretty fragile setup; I scrape data from a web page that wasn't intended for this purpose and which might vanish at any moment, using a regex that really relies on no formatting changes in the page. However it does work and I'm comfortable with this for a hobby/personal project.
If you're looking for info on Leeds buses, try this:
http://yorkshire.acisconnect.com/Text/WebDisplay.aspx?stopRef=[the bus stop number that also works with the SMS system]. It also has info on which buses have low floors, plus any extra announcements.
Update The Skill
Once I was able to make the web request and parse the results using my local node toolchain, I then added that functionality into my lambda script. I found that publishing the skill was a painful process (
check for further posts on Amazon lambda because I'm changing my workflow and may have better advice sooncheck out my followup post on a better workflow for this) because I had to:
- Put the code into a web-based text editor (you can upload zip files to s3 and do something but I don't have this sorted out yet)
- Go Actions -> "Publish a new version"
- Go Triggers and set up a new trigger linking the Alexa Skills Kit to my function
- Go back to the Alexa Developer Console, click Configuration and update the version number at the end of the Lambda URN field
Creating Alexa Skills
Tips, tricks, showing off your own skills: all welcome in the comments box.
Edit: A few people asked me about my actual skill code, so it's available on GitHub if you want it (you need to find a bus stop URL if you want to actually use the skill), as I say based heavily on the sample code from Brian.