"My Train" for Amazon Echo

"My Train" for Amazon Echo

Access real time train information with the help of Alexa on Amazon Echo and Translink's Real Time Rail data feed, accessible on OpenDataNI.

By creating the free Amazon Echo “My Train” skill, I have provided a service that tells you the latest train time information for a journey of your choice on the Translink train network. (A skill is Amazon’s name for an app on their Alexa voice platform.) The skill can be found here:

https://www.amazon.co.uk/IrishClanger-My-Train/dp/B01M8LZ0RT

If you are a new user, the program asks you what your departure and destination train stations are for your journey. It utilises the Alexa Skill Kit (https://developer.amazon.com/alexa-skills-kit) to recognise your speech. The program saves your journey for future lookups to save you time later.

The skill then queries the departure data for your chosen start station in XML format from OpenDataNI’s Translink feed. It parses the data and finds the trains that call at your chosen destination.

The skill then reads out the upcoming train times that match your route and advises if they are on-time, delayed (including the expected new time of departure) or cancelled. It reads up to the next 3 trains and, if there are any more available in the feed information, asks if you want to hear any more.

The skill then stores your journey in a database, so for future queries all you need to say is “Alexa, open My Train” and the skill will read out the latest schedule information for your stored journey. The skill can also provide information on which platform the train leaves from and can provide the return journey information instead. In addition to the spoken output, the skill provides a text version of the response in the Alexa app available on the web, iOS and Android.

The idea for the skill was inspired by my desire to create a local skill useful to the public, including my wife who is a regular rail traveller. I was pleasantly surprised to find that OpenDataNI host a free feed of the train data from Translink that was easy to incorporate into my program.

The fact that the skill is voice activated and provides spoken responses, as well as text, means it is quick to ask for your train information before you leave on your journey and get an up-to-the-minute answer as to the status of your chosen train.

Here is an example of the text output in the accompanying app:

Marino to Botanic

My Train

08:44 from Bangor to Portadown on platform 1 is expected on time.

09:14 from Bangor to Lisburn on platform 1 is expected on time.

09:44 from Bangor to Lisburn on platform 1 is expected on time.

For the more technically minded, I use the Translink real time arrivals and departures data feed, provided by OpenDataNI for free, in an Alexa Skills Kit node.js program running on Amazon AWS Lambda services to process the schedule information. I store your chosen journey on Amazon DynamoDB with an anonymous key provided by Amazon.

The skill contains a list of the valid station names and attempts to match your spoken station with this list. It then tries to convert the spoken station name into the station code via the OpenDataNI feed. If your spoken station does not produce a code, then the skill will ask you to repeat your choice.

The skill also copes with such issues as our pronunciation of Holywood, and uses alternate spellings to ensure Alexa pronounces names correctly (such as substituting Coalraine for Coleraine).

Click here for an audio demonstration of the My Train Amazon Echo skill in use.

Launch website