asynchronousdialogflow-essendasynchronousrequestrequest-timed-out

How to manage the 5 seconds response timeout limit in Dialogflow / Api.ai?


I am using Dialogflow to create an agent / bot which responds to different types of user queries with action items like "I need to get a letter from the HR for address proof". This needs the bot to fetch some information from the company's database and generate a document / letter by populating that retrieved information in a templated letter file provided by the Human Resource. The logic to do this action is already written in a python file. The database integration is done using Webhooks.

The problem is that this complete process of interpreting the user's request, opening the database and retrieving the required information takes more than 5 seconds, which happens to be the response timeout limit for Dialogflow agents. I have done some research on this and found out that we cannot increase this limit but we can keep the session alive through asynchronous calls. I am not able to find the right resource which provides the answer.

So, my questions are-

Can we make asynchronous calls in dialogflow?

If yes, then how do we send asynchronous data through json to Dailogflow agent?

Is there any other way to tackle this 5 seconds response timeout limit?

Thanks in advance!


Solution

  • I have just checked the Actions on Google documentation and the Fulfillment documentation pages, and indeed there is a 5-second timeout limit.

    This may not be the nicest of the solutions and may not fit your case, but considering the given the strict 5-second window (we want to ensure a dynamic conversation without risking the user waiting for too long)

    You start the computation with your first intent asynchronously and go back to the user and tell them to request the results in a few seconds, in the meantime when the computation is completed. It will be saved in a private space for the user, at which point the user will trigger a second intent that will request the results that in the meantime will have been pre-computed, so you can just fetch and return them.