alexa-app
alexa-app copied to clipboard
Echo Show Support
Would be nice to add built-in function to check Echo Show Support.
Also example in Docs isn't valid:
app.post(req, res, type, exception) {
// If the device does not support display directives then remove them from the response
if (!system.supportsDisplay(req))) {
res.response.response.directives = []
}
}
The actual interface of app.post is app.post = function () {...}. And system is not defined ;-)
Would appreciate if you could help track this down.
This framework doesn't have supportsDisplay() function.
It needs to check that path: req.data.context.System.device.supportedInterfaces.
Amazon Skill Testing tool contains this object in supportedInterfaces:
{
AudioPlayer: {},
Display: {
templateVersion: '1.0',
markupVersion: '1.0'
}
}
I don't know if Display must be empty or must not exist in case of no screen.
The second thing I want to say is don't suggest users to clear directives res.response.response.directives = []. This line will also remove other directives, AudioPlayer for example.
I use my own helper function that I call within the app:
var has_display = function(request) {
try {
return !!request.data.context.System.device.supportedInterfaces.Display;
}
catch(e) { return false; }
};
I agree, stripping directives is a bad idea. Especially now that there are new non-display directives.
I plan to work on this, at some point, so there is more Display support built in.
@matt-kruse @dblock What do you think about adding supports* helpers to alexa.response?
response.supportsVideoApp(): bool
response.supportsDisplay(): bool
response.supportsAudioPlayer(): bool
Or suggest your vision of the app structure.
I realized that those functions will use request.data, but keeping them in response sounds better for me.
I already have helper functions like these and many more in my local version of this lib, I just find the structure and tests required in the release version to be a bit too much for me to contribute them back.
Since the functions require request data, putting them in response isn't possible. But I've found this with other things, too. One fix is to actually put the request json into the response object when it's created, so it can reference data like this.