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® SmartFlow.

  1. Click, drag, and drop an INBOUND API trigger onto your board. More guidance on using APIs with SmartFlows can be found in the Atmosphere® SmartFlows 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 flow id. Your Alexa code needs 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 Kit page.

Step Two: Click the Console button to navigate to the Alexa Developer Console and create a skill.

Amazon has created helpful guides for building your first skill:

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 allows you to call a SmartFlow:

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

Sample Code

Copy
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:

Sample Code

Copy
{
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

Copy
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 allow you to choose the method that best meets your needs.