Skip to content

Instantly share code, notes, and snippets.

@bbezerra82
Created June 25, 2020 15:40
Show Gist options
  • Save bbezerra82/a87a61dd65c79b2b3fc5517412e34100 to your computer and use it in GitHub Desktop.
Save bbezerra82/a87a61dd65c79b2b3fc5517412e34100 to your computer and use it in GitHub Desktop.
code snippet for logging requests and responses
.addRequestInterceptors(function (handlerInput) {
const { requestEnvelope } = handlerInput;
const type = Alexa.getRequestType(requestEnvelope);
const locale = Alexa.getLocale(requestEnvelope);
if (type !== 'IntentRequest') {
console.log(`${type} (${locale})`);
} else {
console.log(`${requestEnvelope.request.intent.name} (${locale})`);
}
console.log(`\n********** REQUEST *********\n${JSON.stringify(handlerInput, null, 4)}`);
})
.addResponseInterceptors(function (request, response) {
if (response) console.log(`\n************* RESPONSE **************\n${JSON.stringify(response, null, 4)}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment