question

Keyon Jukes avatar image
Keyon Jukes asked

APLA not responding with output

Welcome

Hello all, I am trying to use APLA (Alexa Presentation Language for Audio) to give dynamic responses with both speech and audio sound when users get a answer correct or incorrect. I get the functionality to work one time, then the skill subsequently does not return any response. I will attach my code below to see if anyone may be able to assist me in understanding why APLA does not return sound more than once, just text on the second time of render. Is it my code? is it that the token must be unique each time APLA is used? Once again, it plays once and then when answering a second question, it shows text output of the correct response in the Alexa developer console testing tab but the APLA does not speak anything which is causing failed certification.

I've tried removing the .speak() portion and just having the APLA then a reprompt and getResponse, I have tried to make speakOutput be initializied to empty strings, I have used ternary operators to conditionally use winning or losing audio and speakOutput which works the first two times, then goes blank and returns no speech response. Can anyone help me see what I am doing wrong.


For additional context, I have a guessAuthor handler and a roundOne handler. The guessAuthor handler contains the response which returns the APLA and the roundOne handler delivers a random question to the user and gets their answer. The code which gives the question in the roundOne handler works, but the guessAuthor only responds one time with APLA and all subsequent times returns text but does not speak any output again. Are there some rules which prohibit APLA from being used multiple times or something? Or can it just be I have setup the APLA wrong?

My Code


//last apla attempt

if(winner){

let winningResponse = handlerInput.responseBuilder;

return winningResponse

.addDirective({

type: "Alexa.Presentation.APLA.RenderDocument",

token: AUDIO_TOKEN,

document: audioDocument,

datasources: {

"soundsource": correctsound,

"speechsource": speakOutput

}

})

.speak('hmmm')

.reprompt(speakOutput)

.getResponse();

} else {

let losingResponse = handlerInput.responseBuilder;

return losingResponse

.addDirective({

type: "Alexa.Presentation.APLA.RenderDocument",

token: SEQUENCE_TOKEN,

document: sequenceDocument,

datasources: {

"soundsource": incorrectsound,

"speechsource": speakOutput

}

})

.speak('hmmm')

.reprompt(speakOutput)

.getResponse();

}


Ternary Operator Version

//apla

// return handlerInput.responseBuilder

// .addDirective({

// type: "Alexa.Presentation.APLA.RenderDocument",

// token: winner ? AUDIO_TOKEN : SEQUENCE_TOKEN,

// document: winner ? audioDocument : sequenceDocument,

// datasources: {

// "soundsource": winner ? correctsound : incorrectsound,

// "speechsource": speakOutput

// }

// })

// .reprompt('say next round one quote for another quote or you can say stop to end this session, which would you like?')

// .getResponse();

alexaaudioapl
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

Nothing to stop APLA being used multiple times and the tokens don't need to be unique. Must be an issue in your code / APLA doc. Is the skill an Alexa hosted skill or hosted using your own AWS resources ?

Perhaps put the full code in github and share the repo so we can see the full picture if you're happy to do that ? If not then include the full code of your failing intent handler here. And to help readability please use the "code" formatting option "< >" in the format menu.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.