0

My question is simple as I done in SDK v3.

I would like to send message to user after 2 min of his idle with bot. Hence I have used setTimeOut() to send message. if user enters any message with in 2 min then I need to clear above setTimeOut using clearTimeOut();

in v#4, Dialogcontext not working within the setTimeOut() and when I print the value of Dialogcontext is "undefined".

Please find below code snippet in v4.

  const results = await dialogContext.continueDialog();
        console.log('---active dialog status....',results);

   if( dialogContext.context._activity.value===engconstant.getstarted){
      if (results.status === DialogTurnStatus.empty) {
       console.log('before timeinterval starts');
             await    getstartedinterval(dialogContext);   
      } 

  }

below code shows getStartedinterval function.

async function getstartedinterval(dialogContext)
{


  timeoutobj= setTimeout(function (dialogContext) {
      console.log('--- inside setTimeout----',dialogContext);// displaying as undefined 
      notificationMsgGetStarted(dialogContext); 
  },constant.timeinterval);


}

How can I resolve this?

James Z
  • 12,209
  • 10
  • 24
  • 44
Anil
  • 69
  • 7
  • Possible duplicate of [Cannot get conversationState property value inside a setTimeOut](https://stackoverflow.com/questions/55816124/cannot-get-conversationstate-property-value-inside-a-settimeout) – tdurnford Sep 12 '19 at 14:58
  • @tdurnford, I saw that post but how can I clear /stop proactive message when user enter input. – Anil Sep 12 '19 at 15:01
  • There is no way to clear the timeout unfortunately. Basically we are using the `responded` attribute as a boolean value in the conversation state to track if the user has responded to the bot. You need to check the `responded` value in the proactive message before replying to the user. – tdurnford Sep 12 '19 at 15:05
  • @tdurnford , could you please suggest me how can I send the proactive message after 2 min of clicking on GetStarted button in facebook. I look forward for your suggestion. – Anil Sep 15 '19 at 22:24
  • Probably best to ask another question on StackOverflow. It’s likely too much code for the comments – tdurnford Sep 15 '19 at 22:41
  • @tdurnford , as suggested, created new question https://stackoverflow.com/q/57949060/11724264 please suggest. – Anil Sep 16 '19 at 00:04

0 Answers0