Created
June 25, 2020 15:40
-
-
Save bbezerra82/a87a61dd65c79b2b3fc5517412e34100 to your computer and use it in GitHub Desktop.
code snippet for logging requests and responses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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