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('./conf/firebase');
const { WebhookClient } = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
function searcheColleagueByName(agent){
var lastname = agent.parameters.lastname;
firebase_database.ref().once('value')
.then(team => {
agent.add("some name " + lastname);
})
.catch(err=>{
agent.add("something wrong");
})
}
and after when i make request to my bot from telegram I get error in firebase console:
Error: No responses defined for platform: null
at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
What's wrong? why when I use promisse
my agent can't give me an answer?
javascript firebase-realtime-database dialogflow google-assistant-sdk
add a comment |
I try to execute this code on Firebase Cloud Functions
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firebase_database = require('./conf/firebase');
const { WebhookClient } = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
function searcheColleagueByName(agent){
var lastname = agent.parameters.lastname;
firebase_database.ref().once('value')
.then(team => {
agent.add("some name " + lastname);
})
.catch(err=>{
agent.add("something wrong");
})
}
and after when i make request to my bot from telegram I get error in firebase console:
Error: No responses defined for platform: null
at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
What's wrong? why when I use promisse
my agent can't give me an answer?
javascript firebase-realtime-database dialogflow google-assistant-sdk
You only define a function in the body of theonRequest
callback; you don't do or return anything. NB: where would you get the value ofagent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.
– trincot
Nov 19 '18 at 20:28
add a comment |
I try to execute this code on Firebase Cloud Functions
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firebase_database = require('./conf/firebase');
const { WebhookClient } = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
function searcheColleagueByName(agent){
var lastname = agent.parameters.lastname;
firebase_database.ref().once('value')
.then(team => {
agent.add("some name " + lastname);
})
.catch(err=>{
agent.add("something wrong");
})
}
and after when i make request to my bot from telegram I get error in firebase console:
Error: No responses defined for platform: null
at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
What's wrong? why when I use promisse
my agent can't give me an answer?
javascript firebase-realtime-database dialogflow google-assistant-sdk
I try to execute this code on Firebase Cloud Functions
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firebase_database = require('./conf/firebase');
const { WebhookClient } = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
function searcheColleagueByName(agent){
var lastname = agent.parameters.lastname;
firebase_database.ref().once('value')
.then(team => {
agent.add("some name " + lastname);
})
.catch(err=>{
agent.add("something wrong");
})
}
and after when i make request to my bot from telegram I get error in firebase console:
Error: No responses defined for platform: null
at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
What's wrong? why when I use promisse
my agent can't give me an answer?
javascript firebase-realtime-database dialogflow google-assistant-sdk
javascript firebase-realtime-database dialogflow google-assistant-sdk
edited Nov 19 '18 at 21:45
Prisoner
34.7k33258
34.7k33258
asked Nov 19 '18 at 20:16
missing17missing17
298
298
You only define a function in the body of theonRequest
callback; you don't do or return anything. NB: where would you get the value ofagent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.
– trincot
Nov 19 '18 at 20:28
add a comment |
You only define a function in the body of theonRequest
callback; you don't do or return anything. NB: where would you get the value ofagent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.
– trincot
Nov 19 '18 at 20:28
You only define a function in the body of the
onRequest
callback; you don't do or return anything. NB: where would you get the value of agent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.– trincot
Nov 19 '18 at 20:28
You only define a function in the body of the
onRequest
callback; you don't do or return anything. NB: where would you get the value of agent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.– trincot
Nov 19 '18 at 20:28
add a comment |
1 Answer
1
active
oldest
votes
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");
})
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382012%2fwhen-i-use-promise-with-dialogflow-library-in-server-get-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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");
})
add a comment |
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");
})
add a comment |
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");
})
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");
})
answered Nov 19 '18 at 21:02
PrisonerPrisoner
34.7k33258
34.7k33258
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382012%2fwhen-i-use-promise-with-dialogflow-library-in-server-get-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You only define a function in the body of the
onRequest
callback; you don't do or return anything. NB: where would you get the value ofagent
from? Also, your code has more opening parentheses and braces than closing ones. Please take care of indenting you code properly.– trincot
Nov 19 '18 at 20:28