0

I am creating a chatbot using DialogFlow. Here, I am trying to get response from the API, which has been created by my development team (using python). They provided the API URL and requested to fetch data from it according to the users query. I have created a function in the inline editor and pasted the given API URL. Below is the API format they have created,

{
“data”: [{
“pincode”: “”,
“location_formatted_address”: “”,
“user_id”: “”,
“department_name”: “Education”,
“locality”: “”,
“status”: “Select_Status”
}]
}

Here, when a user gives a department name, it must respond the user with locality of that specific department.

In the Inline editor, I have applied the following logic to fetch the locality,

function getDatafromApI(agent){
  const name = agent.parameters.name;
  return getAPIData().then(res => {
     res.data.map(issues => {
        if(issues.department_name === name)
        agent.add(`${name}. ${issues.locality}`);

intentMap.set('Fetch API', APIData);

In the above code, "name" is the parameter given in the intent section. But, I am not getting any response. Any help?

1 Answers1

0

The inline editor uses Firebase. You will have to upgrade to Firebase "Blaze" OR "Flame" plan as the "Spark"(free) plan does not allow external api calls.

However if you have already upgraded Firebase plan and still seeing this error, you can see the execution logs by clicking "view execution logs" link at bottom of Dialogflow fulfillment window.

Ali Hasnain
  • 190
  • 1
  • 1
  • 9
  • Thanks for your response. I have already upgraded the Firebase plan. I have tried connecting DialogFlow with Google sheets, it worked well by fetching data from it. When I integrate with external API, am not getting any response. Even though the API's are publicly accessible, I couldn't get any response. Is it possible to get the locality, when the user gives a department name from the single API? – Sandhya Eashwar Sep 26 '19 at 04:43
  • Tell me the what the log says,you can see the execution logs by clicking "view execution logs" link at bottom of Dialogflow fulfillment window. – Ali Hasnain Sep 26 '19 at 07:06
  • Error: Request failed with status code 405 at createError (/srv/node_modules/axios/lib/core/createError.js:16:15) at settle (/srv/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/srv/node_modules/axios/lib/adapters/http.js:237:11) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickDomainCallback (internal/process/next_tick.js:219:9) – Sandhya Eashwar Sep 26 '19 at 11:29
  • Unhandled rejection – Sandhya Eashwar Sep 26 '19 at 11:34
  • Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail – Sandhya Eashwar Sep 26 '19 at 11:35