Alexa Pi: Give AI to Your Raspberry Pi Like an Amazon Echo

By Sarvagnya Purohit


The rise of voice interfaces and artificial intelligence are possibly the most interesting thing in the world of modern day computing. This Raspberry Pi tutorial is a simple and fun project you can build without needing any extra components. This will make your Raspberry Pi talk with you! We will use Amazon’s Alexa Voice Service(AVS) to make this work. This will also help you step into the world of AI and introduce basic concepts of Artificial Intelligence.


Required Materials


  • Raspberry Pi (Raspberry Pi 2/3 is recommended but any RPi will work)
  • USB Mini Microphone (A headphone/webcam’s microphone with a USB Soundcard will also work. Any generic USB Microphone is OK)
  • Raspberry Pi Case (Optional)
  • Raspberry Pi WiFi Dongle (If you aren’t using any an Ethernet connection. Raspberry Pi 3 has built-in WiFi)
  • Raspberry Pi Setup (Connect everything like a keyboard, mouse, and screen to the RPi boot into Raspbian. You can also boot your Raspberry Pi remotely)
  • Speakers (Any powered speaker will work. I will be using my Bluetooth speaker)


  • Raspbian Jessie with Pixel Desktop (Burn it into you SD Card and plug it into you RPi)

Resources and Repositories


How Does it Work?

We first have to register an Amazon Developer’s Account so that we can access Amazon’s Developer Services. We use Amazon’s Alexa Voice Services(AVS) to install the Alexa AI for free on the Raspberry Pi. Once the AVS is downloaded and installed on our Raspberry Pi, we can ask it anything like today’s weather, a joke, information on a random person or any other thing that comes to mind that would like to know about. The RPi answers the questions you ask by connecting to Amazon’s Alexa servers through the AVS we installed and finding the appropriate answers.


Creating an Amazon Developer Account

Unless you already have one, go ahead to Verify your email and you have completed the first step!


Amazon developer- ogin


Registering Your Product and Creating a Security Profile

After you have completed creating your account, you’ll need to create your Alexa Device and a security profile. Keep a note of your Product ID, Client ID, and Client Secret after performing this step.

Login to the Amazon Developer Portal (

Click on Apps and Services Tab >> Alexa >> Alexa Voice Service >> Getting started.


Amazon Developer Console


Click Register a Product Type on the drop-down menu and click on Device.


Alexa product registry


Fill the values and save them:

Device Type Info

  1. Device Type ID – Provide a simple identifier for your product.
  2. Display Name – The display name in the developer portal and what is displayed to users when they register the product with Amazon.
  3. Click Next


Create a new device type


Security Profile

Click Security Profile on the drop-down menu and select Create a new profile

Alexa security profile


Enter a name and description for your security profile, then click Next. For example:

Security Profile Name: Alexa Voice Service Sample App Security Profile

Security Profile Description: Alexa Voice Service Sample App Security Profile Description


Alexa Service Sample App


Client ID and Client Secret will be generated for you.

Now click on the Web Settings Tab. Make sure the security profile you just created is selected in the drop-down menu, then click the “Edit” button.

Alexa Pi Web Settings

Allowed Origins: Click Add Another and then enter https://localhost:3000 in the text field that appears.

Allowed Return URLs: Click Add Another and then enter https://localhost:3000/authresponse in the text field that appears.

Click Next

Alexa Pi Allowed Origins

Device Details

Image – Use any of your custom images and then upload it.

Category – Other

Description – Alexa Voice Service sample app test

Do you have plans to make your product available to the general public? – No

Click Next


Alexa Pi Device Details


Enabling your Security Profile

Open a web browser, and visit

Near the top of the page, select the security profile you created earlier from the drop-down menu and click Confirm


Alexa Pi Select a Security Profile

Enter a privacy policy URL beginning with http:// or https://. For this example, you can enter a fake URL such as

[Optional] You may upload an image as well. The image will be shown on the Login with the Amazon consent page to give your users context.

Click Save.

Alexa Pi Consent Screen Info

Next to the Alexa Voice Service Sample App Security Profile, click Show Client ID and Client Secret. This will display your client ID and client secret. Save these values. You’ll need these. Keep a note of them.

Alexa Pi Voice Service App Security

Alexa Pi OAuth2 Credentials

Cloning the Sample App

Open terminal, and type the following:

cd Desktop
git clone


Updating the Install Script with Your Details

Before you run the install script, you need to update the script with the credentials that you got in step 3 – ProductIDClientIDClientSecret. Type the following in terminal:

cd ~/Desktop/alexa-avs-sample-app


Alexa Pi AVS Desktop 1


Paste the values for ProductIDClientID, and ClientSecret that you got from Step 3 above.

The changes should look like this:

  • ProductID=”RaspberryPi3″
  • ClientID=”amzn.xxxxx.xxxxxxxxx”
  • ClientSecret=”4e8cb14xxxxxxxxxxxxxxxxxxxxxxxxxxxxx6b4f9″


Running the Installation Script

You are now ready to run the install script. This will install all dependencies, including the two wake word engines from Sensory and KITT.AI.

Note: The install script will install all project files in the folder that the script is run from.

To run the script, open terminal and navigate to the folder where the project was cloned. Then run the following command:


cd ~/Desktop/alexa-avs-sample-app


You’ll be prompted to answer a few simple questions. These help to ensure that you’ve completed all necessary prerequisites before continuing.




When the wizard starts, it’ll take about 30 minutes to get everything downloaded and installed.


Running the Web Service, Sample App, and Wake Work Engine

Now that installation is complete, you’ll need to run three commands in 3 separate terminal windows:

1)  Terminal Window 1: to run the web service for authorization

  1. Terminal Window 2: to run the sample app to communicate with AVS
  2. Terminal Window 3: to run the wake word engine which allows you to start an interaction using the phrase “Alexa”.

Run all these steps in order else it will not work.

Terminal Window 1

Open a new terminal window and type the following commands to bring up the web service which is used to authorize your sample app with AVS:

cd ~/Desktop/alexa-avs-sample-app/samples

cd companionService && npm start


The server is now running on port 3000 and you are ready to start the client.

Terminal Window 2

Open a new terminal window and type the following commands to run the sample app, which communicates with AVS:

cd ~/Desktop/alexa-avs-sample-app/samples

cd javaclient && mvn exec:exec



Let’s walk through the next few steps relevant to Window 2.

  • When you run the client, a window should pop up with a message that says –

Please register your device by visiting the following URL in a web browser and following the instructions: https://localhost:3000/provision/d340f629bd685deeff28a917. Would you like to open the URL automatically in your default browser?

           Click on “Yes” to open the URL in your default browser.


click yes window


If you’re running Raspbian Jessie with Pixel desktop (and with Chromium browser), you may get a warning from the browser. You can get around it by clicking on Advanced -> Proceed to localhost(unsafe).


coonection private 1


connectionprivate 2


You’ll be taken to a Login with the Amazon web page. Enter your Amazon credentials.


alexa login

You’ll be taken to a Dev Authorization page to confirm that you’d like your device to access the Security Profile created earlier.


alexa login 2

   Click “Okay”.

You will now be redirected to a URL beginning with https://localhost:3000/authresponsefollowed by a query string. The body of the web page will say device tokens ready.


device token ready


Return to the Java application and click the OK button. The client is now ready to accept Alexa requests


token ready okay


Terminal Window 3

Skip this step to run the same app without a wake word engine.

This project supports two third-party wake word engines: Sensory’s TrulyHandsFree and KITT.AI’s Snowboy. The -e parameter is used to select the agent and supports two values for {{engine}}: kitt_ai and sensory.

Open a new terminal window and use the following commands to bring up a wake word engine from Sensory or KITT.AI. The wake word engine will allow you to initiate interactions using the phrase “Alexa”.

To use the Sensory wake word engine, type –

cd ~/Desktop/alexa-avs-sample-app/samples

cd wakeWordAgent/src && ./wakeWordAgent -e sensory

or, type this to use KITT.AI‘s wake word engine –

cd ~/Desktop/alexa-avs-sample-app/samples

cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai


You can now talk with your Raspberry Pi!


Make Your Raspberry Pi Run Remotely (Optional)

Now that you’ve got your AVS prototype running, you may want to get rid of the monitor, keyboard, and mouse. You can do that by using SSH and VNC. 


Last Step: Talk with Your Raspberry Pi, ENJOY!

You can now talk to Alexa by simply using the wake word “Alexa”. If you prefer, you can also click on the “Listen” button instead of using the wake word. Click the Listen button and wait for the audio cue before beginning to speak. It may take a second or two before you hear the audio cue.

Recommended Posts
Showing 16 comments
  • Nikhilesh

    Any idea if using amazon Developer account is chargeable or free to use?

  • Detromy

    Hi, thanks for the detailed write-up on Alexa. I do have an issue when running Terminal 2 with the code: “cd javaclient && mvn exec:exec”. My error message is: “bash: run: command not found”. Any idea how do I solve this problem?

  • Nick Marino

    Cant get past setting up the device in the Amazon Developer account. when adding the origin urls get error saying its not valid.

    Allowed Origins: Click Add Another and then enter https://localhost:3000 in the text field that appears.

    Allowed Return URLs: Click Add Another and then enter https://localhost:3000/authresponse in the text field that appears.

  • Sunny

    What kind of Mic is required for Audio Input – Do you necessarily need a USB Mic or a USB soundcard with an EP stereo jack mic?

  • Lanora

    Ebay same style nba jerseys china to offer. Online
    free shipping – nba jerseys china

  • Shubham Kumar

    I got an error when running the terminal2 command :”cd javaclient && mvn exec:exec”. the error was related to the 64-bit system and the codes are compatible with 32-bit. What should I do to remove this problem? Please help me.
    Thank you..!

  • Knute

    There appears to be only two choices for audio out, the audio jack and the HDMI port. Since a USB sound card is recommended, how do I get AlexPi to talk to me through it? I get no audio out, at all, although I can record audio and play it back through the USB card.

  • Mike

    I got to the “Dev Authorization page” and clicked OK and got a generic error.
    “We’re sorry!
    An error occurred when we tried to process your request. Rest assured, we’re already working on the problem and expect to resolve it shortly.”

    Any ideas?

    • Tom

      Happened to me, Your device needs to be the Device ID you named it, not the Amzn1XXXXX code. Then reinstall.

  • Alok N

    A great detailed tutorial with complete steps!! Amazing.. But, I have one question, can I change my location in this Voice Service..? When I ask for weather and time, it gives me weather at Seattle… I dont want that! Is there any way to change the location of the device..?


    • Sarvagnya Purohit

      Same happens with me. Try to be more specific in the question. When i ask about the weather in Mumbai, it gives it correctly. Its Alexa’s problem in its device too. Google Home is the only AI which traces the location and answers.

    • Tom

      Happened to me, Your device needs to be the Device ID you named it, not the Amzn1XXXXX code. Then reinstall.

  • akshay

    wow, this is awesome. I had never thought of this as an application. we can build an echo device for just $35. that is extremely cool.
    Thanks for a detailed tutorial.

    I am a big fan of raspberry Pis. I’ve worked a lot with them from building a 70 node cluster to using it for computer vision tasks. I share some of the things I do on my blog here:

    • Sarvagnya Purohit

      Thanx! I am glad u liked the tutorial! :)

Leave a Comment

32 − 22 =

Start typing and press Enter to search