Raspberry Pi Alexa - Build your own Amazon Echo
This guide will show you how to build and set up your very own fully functional Raspberry Pi Alexa device that will respond to your voice commands just like Amazon Echo.

This tutorial will show you how to utilize Alexa on your Raspberry Pi to build your own Amazon Echo. This Raspberry Pi Amazon Echo utilizes Alexa so that it comes with all the other bells and whistles of Amazon’s Echo’s major functionality minus the music services like Spotify.

That meaning you have access to Alexa, Amazon’s own virtual assistant, something that is much like Microsoft’s Cortana, Apple’s Siri and Google Now. This integration with Alexa gives you the ability to do numerous different things such as unit conversions and checking sports scores.

All you need to build your own Amazon Echo is a Raspberry Pi with a USB Microphone, Speakers and also an Amazon Developer account so we can set up Alexa for our Raspberry Pi.

Equipment List

Below are all the bits and pieces that I used for this build your own Amazon Echo tutorial, you will need a microphone, speakers handy to be able to set this up.


Raspberry Pi

Micro SD Card

Power Supply

Network Connection

USB Microphone


GUI Enabled (Access via VNC or Keyboard/Mouse)


Raspberry Pi Case

Registering for an Amazon Developer Account

1. Before we get started with setting up the Raspberry Pi, we will first have to create our own Amazon Developer Account.

We can do this by going to Amazon’s Developer website and following the prompts. We won’t go through the exact steps to set up your account as it is self-explanatory.

Once you have created your account and logged in, we can then proceed with setting up everything we need to configure our Raspberry Pi Alexa service.

Upon logging in you will be greeted with the following screen, click on the Alexa tab.

Amazon Developer Main Screen

2. On the next screen, we need to select Alexa Voice Service by clicking the Get Started Button underneath it.

Amazon Developer Get Started Screen

3. Finally, we can start setting up our new device, on this new screen we need to click Register a Product (1.) then underneath that click Device (2.)

Registering with the Alexa Voice Service

4. On this next screen, we need to define both our Device Type ID and our Display Name, you can set these to anything you like, but for our purposes, we will set the Device Type ID to Raspberry_Pi and Display Name to Raspberry Pi. Remember what you wrote down for your Device Type ID as we will need this later.

Once you have filled out this information, click the Next (2.) button.

Amazon Developer Create a new device type

5. On this screen, we need first to use the drop-down box to select “Create a new profile” (1.).
Once you have done that, we need to fill out the Security Profile Name and Security Profile Description.

You should keep these descriptive but straightforward, for our tutorial we are just going to use PiEcho and Raspberry Pi Echo.

The Profile Name field makes it easy to find the profile again if you need to set up an additional Device. The Description field is used to give an idea of what the profile itself is set up for.

Once you have filled out these two fields, you can press the Next (3.) button.

Amazon Developer Security Profile

6. On this screen, we are presented with a whole bunch of information that we will need to write down somewhere safe. This page contains the information we will use for the Raspberry Pi to connect to Amazon’s Alexa service. Write down the Client ID and the Client Secret. All this information will be needed to be plugged into the scripts later.

Once you have written down the information, click on the Web Settings (2.) tab.

Amazon Developer Important Details

7. Now on this next screen, we need to click the edit button before we can continue.

Amazon Developer Edit Web Settings

8. With this screen, we need to pay attention to Allowed Origins and Allowed Return URLs. Next to both of these you will need to click “Add Another link“. This selection will allow access to two textboxes.

In the text box, next to Allowed Origins enter: https://localhost:3000
In the text box, next to Allowed Return URLs enter: https://localhost:3000/authresponse

Once you have entered that data correctly, click the Next (2.) button.

Amazon Set allowed Origins and Allowed Return URLs

9. This last bit is the final step to set up our new device with Amazon. You could set these to whatever you want, but for our tutorial, we will set the Category to Home Automation, and Description to “Raspberry Pi Echo“.

Once you have filled out all the information, you can press the Submit (2.)button.

Amazon Save New Device

10. With this, all filled out and setup you can now proceed with the rest of this tutorial. Make sure that you have the Security Profile ID, Client ID and Client Secret keys that you wrote down earlier in this tutorial as we will need them shortly.

Setting up Alexa on your Raspberry Pi

1. With the developer account all set up, we can now proceed with cloning the Alexa AVS samples to our Raspberry Pi and installing it.

While you can clone and install the samples over an SSH connection, to set up and make the initial connection, you will have to utilize the Desktop GUI.

For now, either load up the terminal application or connect to your Raspberry Pi over SSH. If you’re running Raspbian light, then it’s likely GIT isn’t pre-installed, follow the first section in the GIT tutorial to learn how to do it.

Once ready, begin by cloning the Alexa AVS Samples repository by entering the following command.

git clone https://github.com/alexa/alexa-avs-sample-app.git

2. Once the repository has finished cloning, we will CD (change directory) into its directory by utilizing the following command.

cd ~/alexa-avs-sample-app

3. Now that we have changed directory we can modify the automated_install.sh file, you will need to have the Device Type ID, Client ID and Client Secret handy for this step.

Run the following command to begin editing the file.

nano automated_install.sh

4. Within this file, you will need to change three values.

Replace YOUR_PRODUCT_ID_HERE with the Device Type ID.
Replace YOUR_CLIENT_ID_HERE with your Client ID.
Replace YOUR_CLIENT_SECRET_HERE with your Client Secret.

Refer to the screenshot below if you are unsure of what your file should look like when you have filled out the values.

Automated_Install.sh editing

Once you have filled out the specific values and are sure they are correct, we can then save the file by pressing Ctrl + X then Y and then pressing Enter.

5. With that all done we can now proceed with the installation of the Alexa samples. Run the following command to begin with the installation process.

. automated_install.sh

6. You will face several prompts before installation begins, the first is a general license prompt. Type Y and press Enter to continue.

automated_install license agreement

7. Just type in Y and press Enter at the next step as we have already created an Amazon Developer Account.

Have Amazon Developer Account

8. Now it will ask you to confirm the credentials we entered earlier. Type in Y and press Enter to continue.

Verify information is correct

9. Now we will need to set the locale for Alexa to utilize, for our tutorial we will just be using en-US, so type in 1 and press Enter to continue.

Setting Locale

10. On this next screen, we will need to select the interface we want to output the audio to. We will be hooking our Raspberry Pi up to a 3.5mm jack speaker. So, we will type in 1 and press Enter to continue.

Select Audio Output

11. The final screen before the installation process begins will ask if you want to enable Alexa wake word detection. Since we want this to work as an Amazon Echo, we will type in Y and press Enter to continue.

Enable Wake Word Detection

The installation will begin immediately, and this can take considerable time so now is a good time to grab a coffee.

Setting up Raspberry Pi Alexa for your Amazon Echo device

1. To complete the following steps, you will need to either be connected to your Raspberry Pi over VNC or through a physical connection. You will need access to the display to be able to utilize a Java-based client that authenticates the connection with Amazon.

To get started we first need to start the Alexa Web service, and we can do this with a few simple commands. Launch up the terminal application and type in the following couple of commands to start the service

cd ~/alexa-avs-sample-app/samples/companionService
npm start

If the service has successfully started up, you will see a result like below displayed in the terminal.

Start companion service

2. Open a new tab in the terminal application by pressing Ctrl+T. In this new tab, we will begin initializing the Java App that registers our device.

We can begin this process by running the following two commands.

cd ~/alexa-avs-sample-app/samples/javaclient
mvn exec:exec

3. These two lines of code will open a window asking you to authenticate your device. Click Yes to allow it to open a window in Chromium automatically. A second dialog will pop up asking you to click Ok, ignore this for now.

Login to reg and authenticate

4. The web browser window that opens will initially warn you that the connection is not private as we are running a self-generated SSL certificate. We can get around this by clicking Show Advanced, and then click Proceed to localhost (unsafe).

Amazon Connection not private warning

5. You will now be prompted to login into your Amazon account within the web browser, fill out your details and press the Sign in using our secure server button.

Login to Amazon Web Services

6. Once you have logged in you will see an authentication screen for your device. Click Okay to proceed. Once completed, it will show “Device Tokens Ready“.

Give Amazon Web Services Permission

7. After you have seen the Device Tokens Ready page, you can now click Ok on the second Java dialog that popped up. This step will finalize the registration of your device and provide the Java applet with the authentication token to work.

Press Ok

8. Finally, we can start up the wake word engine. Open a new tab in the terminal application by pressing Ctrl + T. This allows it so you can say the word “Alexa” to get your Raspberry Pi Amazon Echo device to start listening. For our tutorial, we will be utilizing the KITT.AI wake word software as it is completely free.

Run the following two commands to start up the wake word engine.

cd ~/alexa-avs-sample-app/samples/wakeWordAgent/src
./wakeWordAgent -e kitt_ai

Raspberry Pi Alexa should now be up and running, and you should have an operational Amazon Echo device. You can now go ahead and try it out by saying the word “Alexa“. Once the Raspberry Pi Amazon Echo device hears the word, it should beep indicating that it’s listening. When you hear the beep, you can then ask your question, such as “What’s the weather?“.

If your microphone is having issues, picking up your voice, then follow the steps shown below to increase the gain on the microphone.

If you are not having issues you can skip ahead to our section on getting the Amazon Web Services to start on boot.

Wake Word Agent Running

Improving your Microphone Gain

1. If your microphone is having trouble picking up your voice, then one solution would be to increase the microphone gain. It is possible to do this by utilizing alsamixer.

To launch alsamixer type the following command into terminal:


Alsa Mixer

2. Once the AlsaMixer app has loaded up, you can press F6 to select a different USB Device, use the arrow keys to select your microphone and press Enter.

3. With your microphone selected, use the arrow keys to increase the capture volume. Once you are happy with the capture volume, you can press ESC to exit.

4. Now to keep these new setting, we will need to tell alsa to store the new settings and make them permanent. To do this, we can run the following command:

sudo alsactl store

Getting your Amazon Echo to start on boot

1. If you want your Raspberry Pi Amazon Echo to startup on boot, there are several things we will have to do. Please note that you will still have to have your Raspberry Pi boot into the GUI and not command line due to the Java client that Amazon Echo relies on.

To get started let’s first create our startup script by running the following command:

nano /home/pi/alexa_startup.sh

2. Within this file, we want to add the following lines, make sure you copy them exactly as they are. This script will load up a new terminal tab for every service and start it automatically.

In between each terminal command, we will temporarily sleep to ensure that the services have properly started before we start on the next step.

lxterminal -t "NPM"  --geometry=40x2 --working-directory="/home/pi/alexa-avs-sample-app/samples/companionService" --command npm start &
sleep 30
lxterminal -t "JVM"  --geometry=40x2 --working-directory="/home/pi/alexa-avs-sample-app/samples/javaclient" --command mvn exec:exec &
sleep 120
lxterminal -t "WAKE" --geometry=40x2 --working-directory="/home/pi/alexa-avs-sample-app/samples/wakeWordAgent/src" --command ./wakeWordAgent -e kitt_ai &

Once you have written the bash script correctly, save the file by pressing Ctrl + X then Y and then pressing Enter.

3. Now change the permissions on our new startup script so that we can run it from a separate script.

chmod 755 /home/pi/alexa_startup.sh

4. Finally, we will have to modify LXDE’s (Raspbian desktop) autostart script, and we will change this to run our Alexa startup script. Run the following command to edit the autostart configuration.

nano /home/pi/.config/lxsession/LXDE-pi/autostart


@xscreensaver -no-splash

Replace With

#@xscreensaver -no-splash

Add Below


Your file should end up looking something like what is displayed below, with our two additional lines.

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash

Save the file by pressing Ctrl + X then Y and then pressing Enter.

5. With that all done, you can now restart your Raspberry Pi by running the following command. Wait about two minutes for your Raspberry Pi to fully reboot and for the three programs that control Alexa to startup.

sudo reboot

You should now have a fully operational, build your own, Raspberry Pi Amazon Echo up and running. If you found this tutorial helpful or you have run into any issues, then feel free to head over to our forums.

Ultimate Books of Pi Bottom
Subscribe to get our FREE Crash Course to the Raspberry Pi.