Integrating Amazon Alexa with Atmosphere® SmartFlows

Expand your capabilities and reduce the complexity of your Amazon Alexa app through integration with Atmosphere® SmartFlows.

Building the Flow

Step One: Create your target Atmosphere® SmartFlows.

 

  1. Click, drag, and drop an INBOUND API trigger onto your board. More guidance on using APIs with SmartFlows can be found in the Quick Start Guide.
  2. Click, drag, and connect an SMS block. Depending on how you would like to interact with your user, this could also become EXTERNAL WEB CALL, DIAL, or more. Configure the SMS block to send the message you would like the user to receive.

 

 

 

Step Two: Capture your SmartFlow’s flow idYour Alexa code will need this information to invoke the Smartflow.

 

Step Three: Save and deploy!


Getting Started with Amazon Alexa

Step One: Create a Developer account at https://developer.amazon.com/alexa.

 

Once you’ve created your account, navigate to the Alexa Skills Set page.

 

 

Step Two: Create a skill.

 

 

Amazon has created helpful guides for building your first skill:

https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html

https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html

 

Unless you have your own backend resources for a skill, be sure to select an Alexa-Hosted skill.

 

 

Step Three: Update your code to communicate with SmartFlows. To update your code, we need to update your intent handler. Find the appropriate intent and add in code that will allow you to call a SmartFlow:

 

 

To update your code, we first need to add in some code that will allow you to call a SmartFlow:

const postSmartFlowsData = function(data) {

    return new Promise((resolve, reject) => {

        var https = require(‘https’);

   

        console.log(data);

        const options = {

           

            host : “smart-flows.intelepeer.com”,

            protocol: “https:”,

            method : “POST”,

            port:443,

            path : “/api/apitriggers”,

            headers : {

                “Content-Type”: “application/json”,

                “Accept”: “application/json”,

                “Content-Length” : Buffer.byteLength(data)

            },

            body: data

        };

        

        console.log(options);

        const req = https.request(options,(response) => {

            if (response.statusCode  299) {

                reject(new Error(‘Failed with status code: ‘ + response.statusCode));

            }

     

            var body = ”;

           

            response.on(‘data’, (chunk) => body+=(chunk));

            response.on(‘end’, () => resolve(body));

        });

       

        req.on(‘error’, (err) => reject(err));

       

        req.write(data);

        req.end();

  })

};

At minimum, our function requires that we pass it a JSON object with the following information:

{

ANI: ‘+1720XXXXXXX’, // a customer identifier. This can be a phone number, email, chat handle

DNIS: ‘+1720XXXXXXX’, // the dnis identifier. This must match number on our network.

flowId: // the identifier for your smartflow.



… add any additional input variables. For our example we are going to add in the text generated by alexa

Text:  handlerInput.requestEnvelope.request.intent.slots.myMessage.value

}

Step Four: Deploy your updated code and test. Amazon Alexa provides you several methods to test your integration. We will allow you to choose the method that best meets your needs.