public static async Task <FormPrompt> Prompt <T>(IDialogContext context, FormPrompt prompt, T state, IField <T> field) where T : class { var lang = context.ConversationData.GetValueOrDefault("lang", "en"); var preamble = context.MakeMessage(); var promptMessage = context.MakeMessage(); if (prompt.GenerateMessages(preamble, promptMessage)) { await context.PostAsync(preamble); } if (lang != "en") { //promptMessage.Text = await TranslatorService.Translate(promptMessage.Text, "en", lang); //foreach (var card in promptMessage.Attachments.Select(x => x.Content).OfType<HeroCard>()) //{ // card.Text = await TranslatorService.Translate(card.Text, "en", lang); // foreach (var button in card.Buttons) // { // button.Title = await TranslatorService.Translate(button.Title, "en", lang); // button.Value = await TranslatorService.Translate((string)button.Value, "en", lang); // } //} } await context.PostAsync(promptMessage); return(prompt); }
public void Reset() { LastPrompt = new FormPrompt(); Next = null; Step = 0; History = new Stack <int>(); Phases = new StepPhase[Phases.Length]; StepState = null; FieldInputs = null; }
public void Reset() { LastPrompt = new FormPrompt(); Next = null; Step = 0; History = new Stack<int>(); Phases = new StepPhase[Phases.Length]; StepState = null; FieldInputs = null; ProcessInputs = false; }
private static async Task <FormPrompt> MyPrompter(IDialogContext context, FormPrompt prompt, RideReservation state, IField <RideReservation> field) { var preamble = context.MakeMessage(); var promptMessage = context.MakeMessage(); if (prompt.GenerateMessages(preamble, promptMessage)) { await context.PostAsync(preamble); } if (field.Name.ToLower().StartsWith("confirmation")) { await GenerateHeroCardConfirmMessage(promptMessage, state); } await context.PostAsync(promptMessage); return(prompt); }
/// <summary> /// Here is the method we're using for the PromptAsyncDelegate. /// </summary> private static async Task <FormPrompt> PromptAsync(IDialogContext context, FormPrompt prompt, FAQConversation state, IField <FAQConversation> field) { var preamble = context.MakeMessage(); var promptMessage = context.MakeMessage(); if (prompt.GenerateMessages(preamble, promptMessage)) { await context.PostAsync(preamble); } // Here is where we've made a change to the default prompter. if (state.LastMessage != TRY_AGAIN) { await context.PostAsync(promptMessage); } state.LastMessage = promptMessage.Text; return(prompt); }
private static async Task <FormPrompt> PromptAsync(IDialogContext context, FormPrompt prompt, MainReq state, IField <MainReq> field) { var preamble = context.MakeMessage(); var promptMessage = context.MakeMessage(); if (prompt.GenerateMessages(preamble, promptMessage)) { await context.PostAsync(preamble); } // Here is where we've made a change to the default prompter. if (promptMessage.Text == NOT_UNDERSTOOD) { // Access the message the user typed with context.Activity await context.PostAsync($"Do what you want with the message: {context.Activity.AsMessageActivity()?.Text}"); } else { await context.PostAsync(promptMessage); } return(prompt); }
internal abstract Task <FormPrompt> Prompt(IDialogContext context, FormPrompt prompt, T state, IField <T> field);
internal override async Task <FormPrompt> Prompt(DialogContext context, FormPrompt prompt, T state, IField <T> field) { return(prompt == null ? prompt : await _prompter(context, prompt, state, field)); }
internal abstract Task <FormPrompt> Prompt(IDialogContext context, FormPrompt prompt);
internal override async Task <FormPrompt> Prompt(IDialogContext context, FormPrompt prompt) { return(prompt == null ? prompt : await _prompter(context, prompt)); }