I have bot made using framework v4 using c#. I have integrated luis in it for exit feature, in my bot when ever user type exit it will take you out from the conversation and the entire bot will start from beinging. I my case bot is able to exit but not able to start from beinging. I thought i can use CancelallDialogAsync method but i am not able make it accessible in onturnasync method where i have written code for exit feature.
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
var activity = turnContext.Activity;
// var activity = turnContext.Activity;
var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);
// Top intent tell us which cognitive service to use.
var topIntent = recognizerResult.GetTopScoringIntent();
var attachments = new List<Attachment>();
var reply = MessageFactory.Attachment(attachments);
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
// First, we use the dispatch model to determine which cognitive service (LUIS or QnA) to use.
if (string.IsNullOrWhiteSpace(activity.Text) && activity.Value != null)
{
activity.Text = JsonConvert.SerializeObject(activity.Value);
}
if (turnContext.Activity.Text == "Yes")
{
await turnContext.SendActivityAsync($"Good bye. I will be here if you need me. ", cancellationToken: cancellationToken);
await turnContext.SendActivityAsync($"Say Hi to wake me up.", cancellationToken: cancellationToken);
}
else if (topIntent.intent == "OrderStatusintent")
{
reply.Attachments.Add(Cards.GetHeroCard6().ToAttachment());
await turnContext.SendActivityAsync(reply, cancellationToken);
}
else if (topIntent.intent == "Exitintent")
{
await turnContext.SendActivityAsync($"Good bye. Say Hi if you need more help.", cancellationToken: cancellationToken);
}
else if (activity.ChannelId != "webchat")
{
await base.OnTurnAsync(turnContext, cancellationToken);
}
await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
await UserState.SaveChangesAsync(turnContext, false, cancellationToken);
}