Reputation: 3
I was trying to connect firebase Realtime database with dialogflow chatbot. And when the user ask chatbot to show Board Id, it will read data from database and show that data to the user.
I have tried this way:-
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const firebaseAdmin = require("firebase-admin");
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
firebaseAdmin.initializeApp({
credential:firebaseAdmin.credential.applicationDefault(),
databaseURL:"https://***************************.firebaseio.com",
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to akvo agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function getFromFirebase(agent){
return firebaseAdmin.database().ref('board_id').once("value").then((snapshot) => {
var boardid = snapshot.val();
agent.add(boardid);
});
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('board id', getFromFirebase);
agent.handleRequest(intentMap);
});
After deploying this code I got an error.
Error:- "Webhook call failed. Error: DEADLINE_EXCEEDED, State: URL_TIMEOUT, Reason: TIMEOUT_WEB".
I have done some research on this and found out that we can extend the 5-second timeout limit up to 15 seconds by calling up to 2 follow-up events of intents one after another in webhook. But I don't know how to do this.
Is there any way to tackle this 5 seconds response timeout limit?
Thanks in advance!
Upvotes: 0
Views: 282
Reputation: 43
Dialogflow is designed for continuous user interaction. There is a limit in place for webhooks that a response must occur within 5 seconds.
Sadly there is no good workaround for you to extend the time as far as I'm aware.
I highly recommend reading this up on the webhook service here.
Upvotes: 1