Only handle latest message
We have a C# Bot Builder bot that is sending 5 messages to the user with pauses in between. At the end of the 5th message, we use IDialogContext.Wait to receive the answer. Sometimes, during the 5 messages, a user would start typing in answers to IDialogs that do not expect an answer. The net effect is that by the time the 5th message comes and waits for an answer, the bot has built up a queue of messages from the user to answer to. Is there a way to ignore all messages from user except the last one?
ugly workaround: you can define a bool in your messagescontroller, where you are recieving the messages. Use it to turn your message-handling on and off. Then you can turn your handling on and off from your Dialog by setting the bool.
@fingejo this is my backup plan. was wondering if there is a better way to do this.
i had a similar problem, where unrelated user answer returned from context.wait. and i did this:
.... request = DateTime.UtcNow; context.Wait(CheckName); .....
public async virtual Task CheckName(IDialogContext context, IAwaitable
Thanks all. @hlipa99's approach is quite good for our use case and we've adopted it.
@srozga @hlipa99 How do you manage this when you scale your bot?
@ankitbko you could store the datetime in the conversation state.