I recently started development alexa skills (using SMAPI and ASK SDK) and use on backend side Firebase with nodejs. I deploy my code on Cloud Functions and put my function uri on the endpoint in skill manifest file. I have problem when launching my skill.
`const AlexaASK = require('ask-sdk-core');
const LaunchRequestHandler = {
canHandle(handlerInput) {
return AlexaASK.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
},
handle(handlerInput) {
const speakOutput = "launch request message";
const repromptOutput = "reprompt message";
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(repromptOutput)
.getResponse();
},
};
const ExitHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === `IntentRequest` && (
request.intent.name === 'AMAZON.StopIntent' ||
request.intent.name === 'AMAZON.PauseIntent' ||
request.intent.name === 'AMAZON.CancelIntent'
);
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak(exitSkillMessage)
.getResponse();
},
};
const SessionEndedRequestHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
},
handle(handlerInput) {
//console.log(`Session ended with reason: ${JSON.stringify(handlerInput.requestEnvelope)}`);
return handlerInput.responseBuilder.getResponse();
},
};
const ErrorHandler = {
canHandle() {
return true;
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak("error")
.reprompt("error hanlder")
.getResponse();
},
};
exports.alexaskill = functions.https.onRequest((req, response) => {
const skillBuilder = AlexaASK.SkillBuilders.custom()
.addRequestHandlers(
LaunchRequestHandler,
ExitHandler,
SessionEndedRequestHandler
)
.addErrorHandlers(ErrorHandler)
.create();
response.send()
});`