Dialogflow-fulfillment-nodejs: Error: No responses defined for platform: undefined

Created on 8 Apr 2018  路  8Comments  路  Source: dialogflow/dialogflow-fulfillment-nodejs

I'm using the samples given here and here.

But I'm not able to make it work. When I deploy my cloud function and then test it by typing something in the Actions on Google Simulator or Try it Now section on DialogFlow, I'm not getting any response.

When I check the Cloud Functions Logs, this is what I get:

Unhandled rejection
Error: No responses defined for platform: undefined
at WebhookClient.send_ (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:428:13)
at promise.then (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:246:38)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)

Here's my Cloud Function Code: https://codepen.io/anon/pen/LdMNBJ?editors=0010

I think I'm using http inside the function due to which it's throwing an error. But I'm not pretty sure about it?

Most helpful comment

Okay, so here's what I did to make this work properly.

  1. I used request-promise-native instead of http to make the AJAX Call.

const rp = require('request-promise-native');

  1. I returned a promise from the handler of the promise that rp returns.

return rp(options).then(data => { // Extract relevant details from data. // Add it to the agent. agent.add('Here's the data: ', JSON.stringify(data)); return Promise.resolve(agent); });

Here's a CodePen Just in case you need one.

All 8 comments

Can you update your code to use the most recent version? (0.3.0-beta.3), this issue should be fixed in 0.3.0-beta.3

@matthewayne , sure. Let me give it a try. :)

@matthewayne , doesn't work. BTW, there's something that I noticed. I have an HTTP call inside which, I'm adding response for my agent. Is there an issue with using async functions and then responding from within one of the handlers?

I'm still getting the same error.

Any progress on this? I am having the same issue, also with an http call inside the handler, following the suggestions here: https://stackoverflow.com/questions/49744277/using-3rd-party-api-within-dialogflow-fulfillment

For me this turned out to be the result of passing an object to the agent.add method (instead of a formatted string).

@aliasmrchips Would you be able to post a small sample of what object you passed to the agent.add method please?

Okay, so here's what I did to make this work properly.

  1. I used request-promise-native instead of http to make the AJAX Call.

const rp = require('request-promise-native');

  1. I returned a promise from the handler of the promise that rp returns.

return rp(options).then(data => { // Extract relevant details from data. // Add it to the agent. agent.add('Here's the data: ', JSON.stringify(data)); return Promise.resolve(agent); });

Here's a CodePen Just in case you need one.

Okay, so here's what I did to make this work properly.

  1. I used request-promise-native instead of http to make the AJAX Call.

const rp = require('request-promise-native');

  1. I returned a promise from the handler of the promise that rp returns.

return rp(options).then(data => { // Extract relevant details from data. // Add it to the agent. agent.add('Here's the data: ', JSON.stringify(data)); return Promise.resolve(agent); });

Here's a CodePen Just in case you need one.

@SiddAjmera you just need to return the agent.add, don't need to wrap in a promise resolve

Was this page helpful?
0 / 5 - 0 ratings