Closed steve228uk closed 1 year ago
I agree, this would be a good parameter to expose
This is a much needed feature. Current workaround is to set a sessionAttribute in Content Designer item {{setSessionAttr 'shouldEndSession' true}}
. And then amend fulfillment/lib/middleware/alexa.js assemble()
to
exports.assemble=function(request,response){
let sessionAttributes = _.get(response,'session',{});
return {
version:'1.0',
response:{
outputSpeech:_.pickBy({
type:response.type,
text:response.type==='PlainText' ? response.message : null,
ssml:response.type==='SSML' ? response.message : null,
}),
card:_.get(response,"card.imageUrl") ? {
type:"Standard",
title:response.card.title || request.question,
text:_.has(response.card,'subTitle')? response.card.subTitle +"\n\n" + response.plainMessage:response.plainMessage,
image:{
smallImageUrl:response.card.imageUrl,
largeImageUrl:response.card.imageUrl
}
} : {
type:"Simple",
title:_.get(response,"card.title") || request.question || "Image",
content:_.has(response.card,'subTitle')? response.card.subTitle +"\n\n" + response.plainMessage:response.plainMessage
},
shouldEndSession:_.get(sessionAttributes,'shouldEndSession',false)
},
sessionAttributes:sessionAttributes
}
}
Currently when a response is given Alexa will continue to listen as the session is not ended. It might be a good idea to expose this as an option so the middleware does not need to be edited manually.
https://github.com/aws-samples/aws-ai-qna-bot/blob/3e914e8c3f475db1811e987c7b45223e627116ee/lambda/fulfillment/lib/middleware/alexa.js#L103
The same could be said for the stop intent response:
https://github.com/aws-samples/aws-ai-qna-bot/blob/3e914e8c3f475db1811e987c7b45223e627116ee/lambda/fulfillment/lib/middleware/alexa.js#L72