public async Task OnTurn(ITurnContext botContext) { var context = new MultiBotContext(botContext); bool handled = false; // no active topic if (context.ConversationState.ActiveTopic == null) { // use default context.ConversationState.ActiveTopic = new DefaultTopic(); handled = await context.ConversationState.ActiveTopic.StartTopic(context); } else { // we have an active topic handled = await context.ConversationState.ActiveTopic.ContinueTopic(context); } // if activeTopic's result is false and the activeTopic is NOT already the default topic if (handled == false && !(context.ConversationState.ActiveTopic is DefaultTopic)) { // USe DefaultTopic as the active topic context.ConversationState.ActiveTopic = new DefaultTopic(); handled = await context.ConversationState.ActiveTopic.ResumeTopic(context); } }
public Task <bool> ContinueTopic(MultiBotContext context) { switch (context.Activity.Type) { case ActivityTypes.Message: switch (context.RecognizedIntents.TopIntent?.Name) { case "demoCards": // switch to card demos context.ConversationState.ActiveTopic = new DemoCardsTopic(); return(context.ConversationState.ActiveTopic.StartTopic(context)); case "luisDemo": // switch to LUIS Demos context.ConversationState.ActiveTopic = new DemoLUISTopic(); return(context.ConversationState.ActiveTopic.StartTopic(context)); case "help": // show help DefaultResponses.ReplyWithHelp(context); return(Task.FromResult(true)); default: // show our confusion DefaultResponses.ReplyWithConfused(context); return(Task.FromResult(true)); } default: break; } return(Task.FromResult(true)); }
public Task <bool> StartTopic(MultiBotContext context) { switch (context.Activity.Type) { case ActivityTypes.ConversationUpdate: { // greet when added to conversation foreach (var newMember in context.Activity.MembersAdded) { if (newMember.Id != context.Activity.Recipient.Id) { DefaultResponses.ReplyWithGreeting(context); DefaultResponses.ReplyWithHelp(context); DefaultResponses.ReplyWithResumeTopic(context); this.Greeted = true; } } } break; case ActivityTypes.Message: // greet on first message if we haven't already if (!Greeted) { DefaultResponses.ReplyWithGreeting(context); this.Greeted = true; } return(this.ContinueTopic(context)); } return(Task.FromResult(true)); }
public Task <bool> StartTopic(MultiBotContext context) { switch (context.Activity.Type) { case ActivityTypes.Message: // greet on first message if we haven't already if (!Greeted) { DemoCardsResponses.ReplyWithGreeting(context); this.Greeted = true; } return(this.ContinueTopic(context)); } return(Task.FromResult(true)); }
public Task <bool> ContinueTopic(MultiBotContext context) { // for messages if (context.Activity.Type == ActivityTypes.Message) { switch (context.RecognizedIntents.TopIntent?.Name) { case "showCarousel": DemoCardsResponses.ReplyWithCarousel(context); return(Task.FromResult(true)); case "showAttachment": DemoCardsResponses.ReplyWithAttachment(context); return(Task.FromResult(true)); case "showHero": DemoCardsResponses.ReplyWithHero(context); return(Task.FromResult(true)); case "help": // show contextual help DemoCardsResponses.ReplyWithHelp(context); return(Task.FromResult(true)); case "mainMenu": // prompt to go to main menu // switch to the default topic context.ConversationState.ActiveTopic = new DefaultTopic(); return(context.ConversationState.ActiveTopic.StartTopic(context)); default: // show our confusion //DemoCardsResponses.ReplyWithConfused(context); return(Task.FromResult(true)); } } return(Task.FromResult(true)); }
public Task <bool> ContinueTopic(MultiBotContext context) { if (context.Activity.Type == ActivityTypes.Message) { switch (context.RecognizedIntents.TopIntent?.Name) { case "help": DemoLUISResonses.ReplyWithHelp(context); return(Task.FromResult(true)); case "mainMenu": // prompt to go to main menu // switch to the default topic context.ConversationState.ActiveTopic = new DefaultTopic(); return(context.ConversationState.ActiveTopic.StartTopic(context)); default: // send to luis DemoLUISResonses.ReplyWithLUISResult(context); return(Task.FromResult(true)); } } return(Task.FromResult(true)); }
public Task <bool> ResumeTopic(MultiBotContext context) { // just prompt the user to ask what they want to do DefaultResponses.ReplyWithResumeTopic(context); return(Task.FromResult(true)); }