When I Use Promise With Dialogflow Library In Server - Get Error
I try to execute this code on Firebase Cloud Functions const functions = require('firebase-functions'); const admin = require('firebase-admin'); const firebase_database = require('
Solution 1:
The problem is that, if you're using an async function, then your intent handler must also return a Promise. It isn't enough that you send the reply as part of the then()
clause, you must also return the Promise that the then()
is part of.
In your case, this looks fairly easy. In the searchColleagueByName()
function, you would return then once().then().catch()
result, which is a Promise. (Since then()
and catch()
return a Promise.)
So it might look something like this:
return firebase_database.ref().once('value')
.then(team => {
agent.add("some name " + lastname);
})
.catch(err=>{
agent.add("something wrong");
})
Post a Comment for "When I Use Promise With Dialogflow Library In Server - Get Error"