IMG_7307

How to make the Amazon Alexa sample app boot automatically on the Raspberry Pi

Here’s a quite clean and unhacky way to make the Amazon Alexa sample app on the Raspberry Pi boot headless:ish, without supervision or a monitor connected.

Lately I’ve been doing some experiments with the Amazon Alexa voice service with a Raspberry Pi. Amazon provides a sample app with automated install and lot’s of functionality that you need to use it.

However, the sample app requires different terminal windows and applications to run in a desktop environment. This means you will have to have a monitor connected and you need to do manual handling each time the application boots, which is bad if you want to make things like IoT applications that run without supervision and will reboot themselves.

There currently don’t seem to be any unhacky option around to make it headless. But with the help of a Linux savvy friend I managed to make it kinda headless, at least it boots without supervision and monitor connected.

1. First, set up Alexa on the Raspberry with Rasbian Jessie (PIXEL desktop) according to this guide, but skip the last step:

https://github.com/alexa/alexa-avs-sample-app/wiki/Raspberry-Pi

Then do this:

2. Create the file /usr/local/bin/startAlexaServices with the following content (if you want the wakeWordAgent):

#!/bin/bash

lxterminal --working-directory="/opt/deploy/alexa-avs-sample-app/samples/companionService/" -e "npm start" & 
lxterminal --working-directory="/opt/deploy/alexa-avs-sample-app/samples/javaclient/" -e "mvn exec:exec" &
lxterminal --working-directory="/opt/deploy/alexa-avs-sample-app/samples/wakeWordAgent/src" -e "./wakeWordAgent -e kitt_ai" &

3. Make the file executable:

chmod +x /usr/local/bin/startAlexaServices

4. Edit /home/pi/.config/lxsession/LXDE-pi/autostart and add the file to it:

@/usr/local/bin/startAlexaServices

5. Reboot and three terminal windows with the apps should start upon boot