AWS Startups Blog

Send Data-over-voice Using Alexa with the Chirp Toolkit

Guest post by Tomasz Kurzydym, AWS Professional Services Consultant and Dinu Chiriac, Senior Engineer at Chirp

chirp

Imagine if you could use Alexa to send data over sound to any nearby audio-capable 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, encoded into a sonic barcode. These possibilities and more are now available with the Chirp Alexa Toolkit.

Chirp is a London-based startup that provides data-over-sound technology solutions that aid interoperability between networks and devices and simplifies the connection and data-sharing process between devices using sound. Chirp technology encodes data into a series of audible or ultrasonic pitches and tones to form a “sonic barcode.”

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

Chirp Alexa Toolkit

With help from Dinu Chiriac from Chirp, 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 color.

Integrating Chirp with Alexa skills

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.

Lambda function and Chirp API

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.

Step 1 of creating an Alexa skill

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.

pay attention to language field when configuring Alexa skills

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.

copy and paste JSON document into 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.

provide few utterances

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.

choose the environment

Next, choose Alexa Skills Kit as a trigger.

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 and include dependencies before uploading

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 a 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.

archive and upload files to AWS by choosing Upload a .ZIP file

Next, configure the function handler and execution method.

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.

copy and paste the ARN from the created function

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.

Test the Lambda function the Alexa Toolkit Service Simulator

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.

Open the Chirp Demo app on your device, say “Alexa, chirp using Chirp”

 

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.