-
-
Save steveandroulakis/ab7bffd87b6546f85abddf2f4f9a67cc to your computer and use it in GitHub Desktop.
In case anyone wants to use APL with the Alexa-App framework (https://github.com/alexa-js/alexa-app)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Making alexa-app work for APL | |
var alexa = require("alexa-app"); | |
var app = new alexa.app(); | |
// any old APL document will do | |
var testAplDoc = require('./templates/test_apl.json') | |
// determines if the device has a screen | |
var has_display = function (request) { | |
try { | |
if ('Alexa.Presentation.APL' in request.data.context.System.device.supportedInterfaces) { | |
return true; | |
}; | |
return false; | |
} catch (e) { | |
return false; | |
} | |
}; | |
// on launch, displays an APL screen | |
app.launch(function (request, response) { | |
response.say("OK").send(); | |
if (has_display(request)) { | |
response.response.response.directives.push(testAplDoc); | |
response.shouldEndSession(false); | |
response.say("SCREEN").send(); | |
} | |
// because this is an async handler | |
return false; | |
}); | |
// Catches an APL TouchWrapper event and says the argument | |
app.on('Alexa.Presentation.APL.UserEvent', function (request, response) { | |
var componentArgument = request.data.request.arguments[0]; | |
console.log(componentArgument); | |
response.shouldEndSession(false); | |
response.say(componentArgument).send(); | |
return false; | |
}) | |
// connect to lambda | |
exports.handler = app.lambda(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment