This post has been updated for the latest - please see our 2018 version here

The Chirp Alexa Toolkit is a collection of code snippets, audio API, and
guides that make it easy to enable Alexa-enabled devices to send data to other nearby devices using sound.

Imagine that you could send data over sound using Alexa to any audio-capable,
nearby devices that share the same physical space but might not be known on
the network, logged-in, authenticated, or otherwise affiliated with the Amazon
account of the Alexa owner. For example, you could have Alexa check in a hotel
guest by simply “chirping” a code to the guest’s mobile app, or seamlessly
providing the guest with Wi-Fi information by having Alexa broadcast Wi-Fi
security configuration details, encoded into a sonic barcode.

A few example use cases…

This example shows how to enable Alexa to send information to everyone in the
room regardless of their authentication state or relationship to the owner’s
device or network — the users are simply proximal within the same physical
space.

In the example below the exchange is reversed. Here Alexa can speak to nearby
devices and assist with their configuration, their setup or simply send them
relevant data for the user’s current demands.

We are already looking forward to seeing additional creative ways in which
Chirp’s data-over-sound technology can enable new and interesting interactions
between devices on the Alexa platform.

Creating a Chirp-enabled Alexa Skill

The newly released Chirp Alexa Toolkit is a set of three components that is
provided to developers to make integration easier.

In this post we show how to integrate Chirp with Alexa Skills. At the end of
this tutorial, you will be able to send a packet of data from Alexa to the
Chirp Share iOS or Android app. The data will contain information about the
image type, position, and colour.

We’ll use the following three components:

  1. Custom Alexa skill, which defines the Alexa configuration and is the basic configuration for Alexa to be able to chirp commands
  2. Lambda function that defines the logic for the Alexa skill
  3. Chirp API that serves an mp3 file for Alexa to play

As shown in the following diagram, a user asks Alexa to chirp. This triggers a
Lambda function, which in turn returns a JSON response with the mp3 endpoint
URL for Alexa to play. Alexa requests the mp3 file from the Chirp API and
plays the chirp.

Before we get started, you need access to the Chirp API. This requires signing
up for a developer account on the Chirp Admin center. After you sign in, download the zip package with code samples from the Chirp Admin center
downloads. We will also use the Chirp Share app as a receiving device for simplicity. You can download the Chirp Share app for Android here and for iOS here.

Step 1 — Create and configure a new Alexa custom skill

To create a new Amazon Alexa custom skill, go to
https://developer.amazon.com/, choose the Alexa tab, and then choose
Get Started.

Next, you need to provide some basic skill information. Pay special attention
to the Language field because it’s important to select the language of the
country you are in. Also, don’t forget to enable the Audio Player directive
because we are going to play mp3 chirps.

The next step involves using the interaction model, where we will configure
the skill intent schema and the sample utterances. For more information about
the intent schema and sample utterances, see Alexa Skills Kit Custom
Interaction Model Reference
.

In the Alexa Toolkit zip file that you downloaded from the Chirp Admin Center,
you will find a sample JSON document that defines the intent schema. Copy and
paste the contents of this document into the intent schema field.

We are not using Custom Slot Types in our example, so leave it blank.

The sample utterances represent the phrases that we will use to trigger our
custom skill. Provide a few sample utterances, as shown in the following
screenshot.

Now we need to configure the endpoint that Alexa will trigger when the skill
is invoked. In our case, we will create a new Lambda function. For more
information about AWS Lambda, see https://aws.amazon.com/lambda.

STEP 2 — Create and configure a new Lambda function

Go to the AWS Management Console, choose AWS Lambda, and create a new
function. Choose the environment that you prefer. We provide code samples for
Python and Node.js.

Next, choose Alexa Skills Kit as a trigger.

Next, configure the function that will be triggered. In the downloaded zip
file, you will find two folders that contain code samples for the Lambda
function. Install and include dependencies within the zip folder before you
upload it.

## Install dependencies for Node.js lambda function


cd nodejs


npm install


## Install dependencies for Python lambda function


cd python


pip install -r requirements.txt -t ./

You will also need to update the intent name and Chirp API credentials. To do
this, open the index.js or index.py file and update MY_APP_KEY and
MY_APP_SECRET with the credentials of your application from the
Chirp Admin Center, and ALEXA_INTENT_NAME with the
intent name that you used when you created the Alexa skill.

The sample code contains a list of identifiers that are predefined icons to
work with the Chirp Share demo app. Each of the identifiers represents an icon
that has parameters like position, color, and orientation. The script will
select a random identifier from the list, and then will create a Play
Directive for Alexa to play an mp3 file.

Now, archive the updated files and upload them to AWS by choosing Upload a
.ZIP file in the code entry type field on the Lambda function code
configuration.

Next, configure the function handler and execution method.

STEP 3- Connect an Alexa skill to the Lambda function

Copy the ARN from the created function and paste it to the Amazon Alexa Skill
configuration tab.

After saving the Alexa configuration, you can test your Lambda function in the
Alexa Toolkit Service Simulator. Just type in the utterance you want, and then
click on Ask Chirp.

After you’ve tested it successfully, ask Alexa to chirp using the registered
utterance. Open the Chirp Demo app on your device, say “Alexa, chirp using
Chirp” and you should receive the played icons on your mobile device.

Next steps

The release of the Chirp Alexa Toolkit is the first step to make it easier for
engineers who develop Alexa skills to use Alexa to send data to nearby devices
without any prior configuration.

We are actively listening to feedback from those using the Toolkit about how
we can continue to improve for a seamless integration experience. We also very
much look forward to hearing which unique opportunities have been taken
advantage of by the engineering community through the use of the Chirp Alexa
toolkit and the unique capabilities that it delivers.

Please reach out to contact@chirp.io to share your feedback. We look forward to hearing how you get on.