Reset conversation
Hi, I am building a bot application. I want my bot to be able to reset the conversation whenever a particular time delay is exceeded. Suppose, the bot prompts the user to give his or her name, and waits for another method in which the name will be received. If more than 5 mins is spent on waiting, then the bot says sorry i did not get your input. you have to start your conversation again or something like that.
public async Task Name(IDialogContext context)
{
await context.PostAsync("Enter your name:");
context.Wait(NameReceived);
}
public async Task NameReceived(IDialogContext context, `IAwaitable<IMessageActivity>` activity)
{
var name = await activity;
...
...
}
So, I want the bot to be able to handle the delay features. Please help me with this one..
Please take a look at this stack overflow question/answer. It should get you started in the right direction.
Sorry, I did not get what I needed. I wanted to know whether there are any ways to wait for a particular time after I invoke the method context.Wait().
@saikatbh94 context.Wait(methodname) is a continuation delegate, not an async/await type thread barrier. If you want to timeout the conversation, you would need to write code to do that. I've provided an example of this type of conversation timeout here: https://github.com/EricDahlvang/EndConversationTest/blob/master/EndConversationTest/ConversationTimeout.cs Note: this example will only work for a single user, since the class itself is static. It is a proof of concept. An actual implementation would be more complex.