0
votes

I am working on custom event integration which will call one by one three event as I am using third party API which is taking more then 11 sec, I need a functionality where user will receive message from first intent saying "Please wait", meanwhile our 2nd and 3rd intent will wait for the API response, as soon as we get the response from our API we will return it to Dialogflow Agent.

In the below code I want to send message(Please wait) from the Demo intent then the other two custom event will call intent(followOne, followUpTwo) this intent will be process for specific time, after that it will send one more message with actual API response.

async function Demo(agent){
// here we call our API and wait to get an response and will set that   response in Redis server
    await customsleep(1500);
    agent.add('Please wait');
    agent.setFollowupEvent('followUpOne');  
}
async function followOne(agent){    
    await customsleep(4500);
    agent.setFollowupEvent('followUpTwo');
}
async function followUpTwo(agent){  
    // in this intnet will get response from Redis server which we stored from intnet Demo, This response will return to the user
    await customsleep(4700);
    agent.add('here we go');
}

Is there anyway to implement this kind of functionality where we can send message(Please wait). Once we get the response from API we can return it to the Dialogflow Agent.

1

1 Answers

0
votes

To my knowledge you can't send any message while following up an event. (it will be ignore)

If you want to provide a message you should :
Step 1 :
- call the third party api
- send a message with a quick reply : "Please Wait" + qr: "Click here to display the answer"
Step 2 :
- check if the third party api has answered
- yes : return the answer
- no : follow up a waiting event