I think I know why this is happening, I had a similar problem and this is what I did.
If you want to write some date to your database, you need to make sure that you do not call this.emit (*****) until you are done. As soon as you return a response to the user, the stream closes and your information is not saved.
The easiest way to solve this problem is to return a response to the user after confirming that the information has been saved.
In the case of Firebase, something like this:
function writeUserData(userId) { // Get a key for a new Post. var userKey = db.ref('users/').push().key; var reference = db.ref('users/' + userKey).set({ user: userId }); reference.then(() => { alexa.emit(':ask', "Works"); }, (err) => { alexa.emit(':ask', "Does not work"); });
}
I could not save anything until I began to do so.
Hope this helps.
source share