Reputation: 541
I am building an Amazon Alexa skill that gets data async from Google's Firebase.
When I run the Lambda function locally and call it from my Alexa skill all intents work as expected.
However when I zip up the files (not the folder) and move it to AWS lambda the function times out even thought the data has been received and the response object created as expected.
The built in intents are all working as expected too
My code is on GitHub here
The error log and console.log outputs
I have tried to find any solutions via here and google but no luck. It could be that I have been searching the wrong things or this is a specific problem
Upvotes: 2
Views: 332
Reputation: 541
When using firebase with lambda it would appear that you need to initalize and then delete the instance for the response to be returned.
this is a code snippit that I got to work
const Alexa = require("ask-sdk");
const firebase = require("firebase");
var config = {
...
};
const GetOrderIntent = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return (
request.type === "IntentRequest" &&
request.intent.name === "GetOrderIntent"
);
},
async handle(handlerInput) {
firebase.initializeApp(config);
try {
const store = await firebase
.database()
.ref(`teams/${team}`)
.once("value");
// ANY OTHER CODE HERE
} catch (error) {
// HANDLE ERROR
}
// CLOSE THE CONNECTION
await firebase.app("[DEFAULT]").delete();
return handlerInput.responseBuilder
.speak(speechOutput)
.withSimpleCard(SKILL_NAME, speechOutput)
.getResponse();
}
};
Upvotes: 2