Part 1: The Amazon Echo
Allows the developer to work in a voice-controlled environment without needing to build a speech recognition engine of their own.
Amazon's service sends your app parsed responses in string form.
Part 2: AWS Lambda & Echo's Dev Workflow
a. Settle on an Idea
b. Create your Intent Schema
c. Provide Alexa some Sample Utterances
d. Write your Lambda Function
e. Create your skill
Part 3: Echo's Echo
Why doesn't a device named 'Echo' have the ability to echo responses?
Tell Alexa the types of commands allowed in your app
{
"intents": [
{
"intent": "EchoIntent",
"slots": [
{
"name" : "Echo",
"type": "AMAZON.LITERAL"
}
]
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
}
]
}Tell Alexa the form of commands and interactions
EchoIntent {echoa|Echo} {echob|Echo}But wait? Why wouldn't this work...
EchoIntent {only_echo|Echo}exports.handler = function (event, context) {
try {
if (event.session.new) {
onSessionStarted({requestId: event.request.requestId}, event.session);
}
if (event.request.type === "LaunchRequest") {
// call onLaunch function
} else if (event.request.type === "IntentRequest") {
// call onIntent function
} else if (event.request.type === "SessionEndedRequest") {
onSessionEnded(event.request, event.session); // Handle session end
context.succeed();
}
} catch (e) {
context.fail("Exception: " + e);
}
};//Called when the user specifies an intent for this skill.
function onIntent(intentRequest, session, callback) {
var intent = intentRequest.intent,
intentName = intentRequest.intent.name;
// Dispatch to your skill's intent handlers
if ("EchoIntent" === intentName) {
echoReply(intent, session, callback); // Handle the EchoIntent
} else if ("AMAZON.HelpIntent" === intentName) {
getWelcomeResponse(callback); // Handle the HelpIntent
} else if ("AMAZON.StopIntent" === intentName) {
getStopResponse(callback); // Handle the StopIntent
} else {
throw "Invalid intent";
}
}//function getStopResponse(callback)
function getWelcomeResponse(callback) {
// If we wanted to initialize the session to have some attributes
// we could add those here.
var sessionAttributes = {};
var cardTitle = "Welcome";
var speechOutput = "Entering echo mode. " +
"I will now repeat everything you say until I hear 'stop'" +
", or it stays quiet for 5 seconds.";
// If the user either does not reply to the welcome message or
// says something that is not understood, they will be prompted
// again with this text.
var repromptText = "";
var shouldEndSession = false;
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput,
repromptText, shouldEndSession));
}function echoReply(intent, session, callback) {
var cardTitle = intent.name;
var wordsToRepeat = intent.slots.Echo;
var repromptText = "";
var sessionAttributes = {};
var shouldEndSession = false;
var speechOutput = wordsToRepeat.value;
repromptText = "";
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput,
repromptText, shouldEndSession));
}If you don't have an Echo, there's a JSON based tester in the Amazon Developers Console