github alexa/alexa-skills-kit-sdk-for-nodejs 1.0.11
Adding support for Display.ElementSelected events

latest releases: v2.14.0, v2.12.1, v2.12.0...
6 years ago

Added support for Display.ElementSelected events.

When using a list Display.RenderTemplate. Each item in a list can be made selectable by touch. For each selectable element on the screen, the skill developer provides an associated token that they will receive in the callback response when the element is selected. See the list templates in the Display Template Reference. The developer may name the tokens using their preferred methodology.

The skill can set a token field on any selectable element, and this token is returned in a Display.ElementSelected request if that element is selected. An example of such an event is shown below.

 "request": {
    "type": "Display.ElementSelected",
    "requestId": "amzn1.echo-api.request.7zzzzzzzzz",
    "timestamp": "2017-06-06T20:05:04Z",
    "locale": "en-US",
    "token": "getTopicName-Cookie-Contest"
  }

Creating an 'ElementSelected' function in your handler will allow you to respond to these types of events. In the example below, the handler will emit a voice response with the token value that was selected.

let handler = Alexa.CreateStateHandler(STATES.start, {
    'ElementSelected': function () {
        const token = this.event.request.token; // the token of 
        this.emit(':tell', 'you clicked on an element with token ' + token);
    }
}

See the Display interface reference for more information

Don't miss a new alexa-skills-kit-sdk-for-nodejs release

NewReleases is sending notifications on new releases.