A Better way to Automate with Alexa

Recently a started a new habit: I take a train in the mornings to get to the office to work. The train comes at every half an hour, which means I don't want to miss it. To be on the safe side, I had to come up with a solution. The route to the train station is well predictable, it just a few minutes on foot. Trains usually, don't come early so the only variable left is the waiting time on the elevator. After all, the minimum and maximum time to get to the station is within narrow boundaries.

Initial Approach

I decided that some sort of a reminder could help to remind to get going on time. To create a reminder to leave, the simplest and easiest solution is to set an alarm exactly 10 minutes before the train usually arrives to the station. However, I am not a fan of the solution as if the alarm goes off, I have to manually disarm it, which is an extra effort to do, when I should prepare for leaving the flat.


The most convenient way would be to set a repeating reminder for every workday on an Alexa device. This would be just an announcement every morning at 8:40 AM to remind me to get ready.

But this quickly brings us to the next iteration of the idea: can I retrieve the live data the from the local public transportation company's website and time the reminder based on that data? This would help to deal with the cases when the train is delayed and I have a few more minutes to spend at home rather than at the train station.

Another convenient way would be to leverage the Alexa device capabilities and to get a notification at the right time. Then, I could just create an application which pushes a notification to the Alexa device. Although this seems very convenient, the way Alexa devices deliver notifications are not. The notification appears as a yellow glowing ring on the device, and I have to actively engage with the device to listen to the notification. I would end up in the same situation as with a simple alarm. I would need one more action to do instead of getting going.

Good Enough Solution

Finally, I created a mixed approach. I use a scheduled Alexa routine. The routine is triggered every weekday morning, and it announces the time when the train approaches the station. This way I get a notification, as well as I get a live update of the train schedule, therefore I know if there are any delays expected.

The routine consists of two actions:

  1. A predefined text as a reminder

  2. A custom text action

The first action just reminds me to prepare to leave, while the second action invokes a custom (non-public) skill which tells me when the next train is leaving.

As I am implementing a new Alexa skill for the purpose, it might seem convenient to integrate it with routines, however there is a constraint:

  • at the time of writing this blog post testing Alexa skill integration with routines is only possible through API if the skill is not in live stage

  • for skill connections, the skill must be certified and published, which I may not do if I want to keep it private

A faster and simpler solution is to use a Custom text action in the routine, which can also invoke the skill by using the following schema: Alexa, ask [skill name], [skill request text]. This will not read the question when the routine is engaged, but only read the answer.


Finally, I enabled Full Address and Location Services permissions for my Alexa skill. With these permissions I may retrieve the address of the Alexa device or an exact location with coordinates if the Alexa application runs on a phone. The address may be translated into an exact location by mapping APIs, here I use Bing Maps API.

With the exact location, I can determine which is the nearest station, thus I may retrieve the live schedule of the closest train station. With this enhancement I can ask the train schedule from Alexa on my phone, even on the way home during my daily commute.