botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[.Net SDK, Question] Send message after inactivity

Open luisnatividade opened this issue 8 years ago • 6 comments

Bot Info

  • SDK Platform: .NET
  • Active Channels: Web Chat
  • Deployment Environment: Azure Bot Service

Issue Description

Send message after X second of inactivity of user.

I want to send a message "I'm still here" to the user when he is inactive (don't sends message) in 60 seconds. I tried with the proactive messages but I could not set a timer that restarts (or stop) when user sends a message.

Any idea?

Thanks in advance.

luisnatividade avatar Feb 01 '18 14:02 luisnatividade

Looking into this for you.

JasonSowers avatar Feb 01 '18 23:02 JasonSowers

Any update on this. Does anyone have the solution for it. if so could you please post it.

Kothakapu avatar Feb 05 '18 13:02 Kothakapu

@Kothakapu I have a solution. I don't think it's the best approach possible but until now is the only one that works for me.

I have a logfile with all the user messages sent to the bot. In each one I have a 'timestamp'. In the beginning of the Dialog I start a proactive message process that every 5 seconds checks the logfile and compares the last message time with actual date. If the difference of seconds between the 2 dates is grater than 60 the proactive message is sent to the user, otherwise the thread sleeps 5 seconds, and checks again.

@JasonSowers I'm still having an issue with this. If the user sends a message to the chatbot in the moment that the chat is sending the proactive message, the user receives the message "Sorry, my bot code is having an issue". This happens probably because the user is sending a message to my main Dialog but the proactive message starts a new Dialog (since I have to receive an answer to the proactive message I send). Is there anyway to avoid this?

Thanks in advance.

luisnatividade avatar Feb 07 '18 10:02 luisnatividade

@luisnatividade were you able to resolve this, or did you still need help? Many people solve the timer issue by using another application/api that hosts the timer for the bot.

JasonSowers avatar Jun 25 '18 14:06 JasonSowers

@luisnatividade , I tried to use this library https://github.com/User1m/botbuilder-timeout but it has an issue which I fighting to get resolved. The fix provided isnt working. I would try it once. Issue:-

https://github.com/Microsoft/BotBuilder/issues/4608#event-1637804723

rjgmail88 avatar Jun 25 '18 15:06 rjgmail88

Hi @luisnatividade,

Please review the answer provided on here as a possible solution.

stevkan avatar Jun 26 '18 22:06 stevkan