I have a bot made in framework v4 using c#. I am using LUIS
to get out from the bot. When ever user type exit in my bot, the bot will start the entire conversational from beginning. But in my case all the stack present above the bot are not ending as CancelAllDialogsAsync(true, null, null, cancellationToken) method is not accessible in onturnasync method where I have integrated exit feature using LUIS
.Here the code for exit feature with LUIS
. Is their any way to write cancelalldialogasync method along with 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);
}
}