Using Alexa for better voice commands

I previously used Tasker on my smartphone in order to issue voice commands. The issue is, I had to have my phone around me and waiting for commands at all times. It’s kinda clunky, it drains the battery, it’s not a great solution over all.

As it turns out, Amazon’s Alexa does indeed have an API and can be incorporated in other systems by supplying a web service that handles requests from Alexa.

There are a ton of ressources explaining how to implement a web service for Alexa, so I’m not going to go into that. As of now, I’ve setup two “intents”, in other words commands, to communicate with my smarthome:

  1. Getting the value of a block: A block, if you recall, is the thing storing the value of devices on my smarthome. By saying “how much is {block}?”, “how’s {block}?”, “what’s {block} at?” or similar, my smarthome receives a blockIntent with {block} set to the name of the block. It searches for a block with that name, retrieves the value and prefix / suffix and responds with “{block} is currently at {prefix} {value} {suffix}”. In short, I can ask if the door is open, the coffee machine is on or what the temperature is at.
  2. Commanding the system to do something: “Initiate protocol {number}”, “start protocol {number}” or “protocol {number}, please” all result in my smarthome receiving a protocolIntent, which starts a protocol. A protocol is an event with a name in the form “Protocol #{number}”, and as any event, has some kind of reaction specified. An example is protocol #8, which currently lights up an LED strip.

While this is also damn cool, it’s also limited in what can be done. Alexa only listens for up to 8 minutes, so you can’t just start the smarthome Alexa app and let it be running in the background, you have to restart the app every time you want to issue a command or use a shortcut invocation command (“Computer, say lutan to {command}”). The other thing is, you can’t use Alexa as a TTS service, as in, your webservice can’t make it speak without being asked first. Which is kind of a bummer, but can be fixed by using festival for TTS. Any maybe, one day, that comes to Alexa and I don’t have to use two different voices.