Search code examples
alexa-skills-kitalexa-presentation-language

How to get token of currently rendered document in screen?


My pause handler handles pause action from multiple cards. Here is my PauseHandler looks like,

    @Override
    public Optional<Response> handle(HandlerInput input) {
                
        List<Command> commands = new LinkedList<Command>();       
        ControlMediaCommand pauseVideoCommand = ControlMediaCommand.builder()
                .withCommand(MediaCommandType.PAUSE)
                .withComponentId(PLAYER_COMPONENT_ID).build();
        commands.add(pauseVideoCommand);

        ExecuteCommandsDirective executeCommandDirective = 
                ExecuteCommandsDirective.builder()
                .withToken(Constants.DOCUMENT_TOKEN)
                .withCommands(commands)
                .build();
        
        String speechText = "Okay";
        return input.getResponseBuilder()
                .withSpeech(speechText)
                .addDirective(executeCommandDirective)
                .build();
       }
}

Now my pause handler needs to handle pause via voice for another APL document. I'm trying to figure out if there is a way to uniquely identify the document (something like token) while handling pause so that i can choose appropriate action for pause.


Solution

  • You can always use session attributes to store a token for the last document sent when you send it.

    https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-nodejs/manage-attributes.html