Over a million developers have joined DZone.

App Integration With Alexa

DZone's Guide to

App Integration With Alexa

See how to integrate voice commands into your app with some help from Amazon's Alexa, an AWS Lambda function, and MuleSoft.

· IoT Zone ·
Free Resource

Digi-Key Electronics’ Internet of Things (IoT) Resource Center Inspires the Future: Read More

Application integration assembles methods and tools for organizing exchanges between applications, and intra- and inter-enterprise business processes. A strategic tool for enterprises, it introduces genuine reactivity into information systems facing business changes, and as a result, provides a significant edge in optimizing costs.

Alexa is Amazon’s voice service and the brain behind tens of millions of devices like the Amazon Echo, Echo Dot, and Echo Show. Alexa provides capabilities, or skills, that enable customers to create a more personalized experience. There are now tens of thousands of skills from companies like Starbucks, Uber, and Capital One as well as other innovative designers and developers.

Use Case of Integration With IoT Device: Create a Custom Alexa Skill

You might want to keep up with your fitness goals by getting Fitbit data with Alexa. You can stay in touch with your progress and get motivated as you go about your day.

You can check in on your daily Fitbit progress with Alexa, ask Alexa if you hit your sleep goal, how you did yesterday, or just get a quick update on the stats you care about the most.

What Information Can Alexa Tell Me?

Alexa can access the data you’ve already synced, but it can’t sync the latest data from your device. Alexa can tell your Fitbit stats for today, yesterday, or a specific day of the week that you name. Alexa can only access the information you synced from your Fitbit device.

Alexa can tell you information about the following Fitbit stats:

  • Steps taken
  • Distance covered
  • Active minutes
  • Flights climbed
  • Hours slept
  • Weight
  • If you exercised
  • Calories burned
  • Calories remaining
  • Water logged
  • Resting heart rate
  • Battery life on device

Chain of Events

1. Alexa receives data from the user through Alexa by questions and prompting.

2. These requests are handled by a function hosted on Amazon Web Services’ (AWS) Lambda (Node.js code).

3. The AWS code handles requests/information based on invocation phrases.

4. The data is then consolidated into a single JSON object that contains the details needed to register a guest.

5. A POST request is made to an API hosted on Cloudhub, sending the JSON object (with authentication headers, etc).

6. This API is HTTPS-based and uses basic authentication.

7. The API receives the JSON and calls the Fitbit developer API with the required OAuth credentials.

8. The API makes a POST to the Fitbit API.

Interaction Model Defined for Alexa Interaction

Image title

The following are the examples of utterances to get health details.

exports.getUserInfo = {
    "slots": {},
    "utterances": ["Tell me about my details",
        "I want to hear about my details"]

exports.getSleepDetails = {
    "slots": {},
    "utterances": ["How I slept "]

exports.fitbitSteps = {
    "slots": {},
    "utterances": ["How many steps I have taken "]

exports.fitbitActiveMinutes = {
    "slots": {},
    "utterances": ["How many active minutes I have  "]

exports.fitbitActivity = {
    "slots": {},
    "utterances": [" get me my health details"]
exports.fitbitCaloriesBurned = {
    "slots": {},
    "utterances": ["How many calories burned  "]
exports.fitbitFloor = {
    "slots": {},
    "utterances": ["How many stairs I climbed  "]

exports.fitbitWaterConsumption = {
    "slots": {},
    "utterances": ["How much water I have  had "]

exports.fitbitFoodConsumption = {
    "slots": {},
    "utterances": ["How much food I have  had  ",
        "What is my calories intake "]

exports.fitbitDistance = {
    "slots": {},
    "utterances": ["How far I walked  "]

exports.getRestingHeartRate = {
    "slots": {}
    "utterances": ["What my resting heart rate is"

Fitbit Mule Flow

Image title

Here are a couple of URIs you'll be using:

Integration is working in a seamless way and provides health details by asking Alexa things like:

  • "Alexa, ask Fitbit how I'm doing today."

  • "Alexa, ask Fitbit how I slept last night."

  • "Alexa, ask Fitbit how many steps I've taken."

Digi-Key’s IoT Component Selector is your one-stop-shop for the IoT

iot ,app integration ,voice command ,alexa skills ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}