Vlad Tagunkov
Vlad Tagunkov

Reputation: 359

Implementation question to call external API with reply more then 5 sec

I use Dialogflow chatbot with voice recognition. My goal is manage external device via Dialogflow. External device can change the state in time range from 30 sec to 30 minutes.

Device state have to be taken in consideration by chatbot via fulfillments. According the documentation it is possible to do that via request-response method and time is 5 second. In ideal case I assume to make bidirectional communication via socket but it is not possible in Dialogflow.Could you please advise me the solution or point me other chat engine with voice supporting that functionality? I read that Dialogflow CX supports sessions up to 30 minutes but it is not a waiting time.

Upvotes: 0

Views: 109

Answers (1)

Raul Saucedo
Raul Saucedo

Reputation: 1780

You can extend the 5-second Intent limit up to 15 seconds by setting up multiple follow-up events. Currently, you can set up only 3 follow-up events one after another. You can extend the timeout up to 15 seconds.

Here, you can see more documentation about custom events.

Here's an example of how you can do it in the fulfillment center:

function function1(agent){
      //This function handles your intent fulfillment
      //you can initialize your db query here.
      //When data is found, store it in a separate table for quick search
    
      //get current date
      var currentTime = new Date().getTime(); 
      
      while (currentTime + 4500 >= new Date().getTime()) {
        /*waits for 4.5 seconds
          You can check every second if data is available in the database
          if not, call the next follow up event and do the 
          same while loop in the next follow-up event 
          (up to 3 follow up events)
        */
        
         /* 
         if(date.found){
            agent.add('your data here');//Returns response to user
         }
          */
      } 
      
      //add a follow-up event
      agent.setFollowupEvent('customEvent1'); 
     
      //add a default response (in case there's a problem with the follow-up event)
      agent.add("This is function1");
  }
 
  let intentMap = new Map();
  intentMap.set('Your intent name here', function1);;
  agent.handleRequest(intentMap);

Here, you can see more documentation about Webhook service and Fulfillment.

Upvotes: 1

Related Questions