0

I am trying to build a chatbot using dialogflow, I am trying to call an event after a time period like in the below code:

function createLink(agent) {
    setTimeout(cnf, 3000);
    agent.add(`Please complete payment by clicking (https://www.aa.bb)`);
}

function cnf(agent) { 
   console.log('In cnf');
   agent.setFollowupEvent('cnf_event');
}

The logs shows that cnf function got executed but dialogflow never execute the cnf_event

What's happening here and how can I do this

Any help, thanks in advance!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Arpit
  • 521
  • 2
  • 8
  • 22

1 Answers1

0

You need to pass agent within your set-timeout function,

function createLink(agent) {
    setTimeout((agent) => {
        cnf(agent)
    }, 3000);
   console.log(`Please complete payment by clicking (https://www.aa.bb)`);
}

function cnf(agent) { 
   console.log('In cnf');
   agent.setFollowupEvent('cnf_event');
}
Nikhil Savaliya
  • 2,138
  • 4
  • 24
  • 45