private async Task OnSearchModeSelected(IDialogContext context, IAwaitable <string> result) { try { string selected = await result; string photo = await TranslatorHelper.TranslateSentenceAsync($"{Resources.Resource.Search_Photo}", Settings.SpecificLanguage); string namelastname = await TranslatorHelper.TranslateSentenceAsync($"{Resources.Resource.Search_NameLastname}", Settings.SpecificLanguage); if (selected.ToLower().Contains(photo.ToLower())) { string waiting = await TranslatorHelper.TranslateSentenceAsync($"{Resources.Resource.Search_WaitingForImage}", Settings.SpecificLanguage); await context.PostAsync(waiting); context.Wait(ImageReceivedAsync); } else if (selected.ToLower().Contains(namelastname.ToLower())) { var registrationFormDialog = FormDialog.FromForm(this.BuildSearchForm, FormOptions.PromptFieldsWithValues); await context.Forward(registrationFormDialog, AfterSearchAsync, context.Activity, CancellationToken.None); } } catch (TooManyAttemptsException) { context.Wait(this.MessageReceivedAsync); } }
public Task StartAsync(IDialogContext context) { var newForm = FormDialog.FromForm(this.BuildForm, FormOptions.PromptInStart); context.Call(newForm, this.CurryResumeAfterDialog); return(Task.CompletedTask); }
//internal static IDialog<BatterySelector> MakeRootDialog() //{ // return Chain.From(() => FormDialog.FromForm(BatterySelector.BuildForm)); //} internal static IDialog <BatterySelector> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(BatterySelector.BuildForm)) .Do(async(context, order) => { try { var completed = await order; // Actually process the sandwich order... await context.PostAsync("Processed your Battery Selection! Have a great day!"); } catch (FormCanceledException <BatterySelector> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last}--maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
internal static IDialog <TravelRequestForm> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(TravelRequestForm.BuildForm)) .Do(async(context, survey) => { try { var completed = await survey; await context.PostAsync("Thanks for your request !"); } catch (FormCanceledException <SurveyForm> e) { string reply; if (e.InnerException == null) { reply = "Vous n’avez pas complété l’enquête !"; } else { reply = "Erreur. Essayez plus tard !."; } await context.PostAsync(reply); } })); }
private async Task OnOptionSelected(IDialogContext context, IAwaitable <string> result) { try { string optionSelected = await result; switch (optionSelected) { case AddAttachmentOption: var AddAttachmentFormDialog = FormDialog.FromForm(BuildAddAttachmentForm, FormOptions.PromptInStart); context.Call(AddAttachmentFormDialog, ResumeAfterAddFormDialog); break; case DeleteAttachmentOption: var allAttachments = string.Format(ChatBotResources.DELETE_ATTACHMENT, string.Join(", ", GetMediaElementsNames())); await context.PostAsync(allAttachments); var DeleteAttachmentFormDialog = FormDialog.FromForm(BuildDeleteAttachmentForm, FormOptions.PromptInStart); context.Call(DeleteAttachmentFormDialog, ResumeAfterDeleteFormDialog); break; case CancelOption: await context.PostAsync($"Операция была отменена!"); context.Done <object>(null); break; } } catch (TooManyAttemptsException ex) { await context.PostAsync($"Упс, слишком много попыток!"); context.Done <object>(null); } }
public Task StartAsync(IDialogContext context) { var conferenceSearchParameters = FormDialog.FromForm(BuildForm, FormOptions.PromptInStart); context.Call(conferenceSearchParameters, ResumeAfterConferenceSearchAsync); return(Task.CompletedTask); }
public async Task ResumeAfterForm(IDialogContext context, IAwaitable <ProjectSelectionForm> result) { var message = await result; if (message.projectTypes.ToString().Equals("CryptoCurrency")) { var workingHourFormFlow = FormDialog.FromForm(CompletedRemainingHourForm.WorkingHourForm, FormOptions.PromptInStart); context.Call(workingHourFormFlow, ResumeAfterWorkingHourForm); } else if (message.projectTypes.ToString().Equals("AttendanceAndPayroll")) { var workingHourFormFlow = FormDialog.FromForm(CompletedRemainingHourForm.WorkingHourForm, FormOptions.PromptInStart); context.Call(workingHourFormFlow, ResumeAfterWorkingHourForm); } else if (message.projectTypes.ToString().Equals("FaceDetection")) { var workingHourFormFlow = FormDialog.FromForm(CompletedRemainingHourForm.WorkingHourForm, FormOptions.PromptInStart); context.Call(workingHourFormFlow, ResumeAfterWorkingHourForm); } else { var workingHourFormFlow = FormDialog.FromForm(CompletedRemainingHourForm.WorkingHourForm, FormOptions.PromptInStart); context.Call(workingHourFormFlow, ResumeAfterWorkingHourForm); } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> /// //internal static IDialog<ProfileForm> MakeRootDialog() //{ // return Chain.From(() => FormDialog.FromForm(ProfileForm.BuildForm)); //} internal static IDialog <ProfileForm> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(ProfileForm.BuildForm)) .Do(async(context, order) => { try { var completed = await order; // See if debug reached this and call our sendSCPI() method here await context.PostAsync(SCPI.BuildSCPI()); } catch (FormCanceledException <ProfileForm> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last} -- maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
internal static IDialog <KerioForm> MakeRoot() { return(Chain.From(() => FormDialog.FromForm(KerioForm.BuildForm)) .Do(async(context, meeting) => { try { var completed = await meeting; await context.PostAsync("OK!"); } catch (FormCanceledException <KerioForm> e) { string reply; if (e.InnerException == null) { reply = $"Mér mész el? :'("; } else { reply = "Ezt elrontottam.. :/"; } await context.PostAsync(reply); } })); //return FormDialog.FromForm(KerioForm.BuildForm); }
internal static IDialog <JObject> JsonRootDialog() { return(Chain.From(() => FormDialog.FromForm(Form.BuildJsonForm)) .Do(async(context, order) => { try { var fim = await order; var prop = fim.Properties(); foreach (var teste in prop) { await context.PostAsync($"As propriedades: {teste}"); //Retorna propriedade e valor await context.PostAsync(teste.Value.ToString()); // Retorna apenas o valor } //var item = fim.First; ////item.Values("FootLong"); await context.PostAsync("Estou no Do..."); } catch (FormCanceledException <JObject> e) { string resposta; if (e.InnerException == null) { resposta = $"Você saiu no {e.Last}, talvez queira terminar o pedido depois"; } else { resposta = "Desculpe, ocorreu algum problema interno. Por favor tente novamente"; } await context.PostAsync(resposta); } })); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <Message> Post([FromBody] Message message) { if (message.Type == "Message") { // return our reply to the user return(await Conversation.SendAsync(message, () => FormDialog.FromForm(WeatherParam.BuildForm) .ContinueWith <WeatherParam, string>(async(ctx, res) => { var WP = await res; var s = await WP.BuildResult(); await ctx.PostAsync(s); return new ChoiceDialog($"Do you want to subscribe to weather in {WP.Location}?", new string[] { "Yes", "No" }); }).Do(async(ctx, res) => { var r = await res; if (r.ToLower() == "yes") { await ctx.PostAsync("Subscribed"); } else { await ctx.PostAsync("Not subscribed"); } }))); } else { return(HandleSystemMessage(message)); } }
internal static IDialog <LuisBot.FormOrder.FormOrder> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(FormOrder.BuildForm)) .Do(async(context, FormOrder) => { try { var completed = await FormOrder; //actually process the sandwich order await context.PostAsync("Formular ausgefüllt!"); } catch (FormCanceledException <FormOrder> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last} -- maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
public static IDialog <Outcome> Build(string type = null) { var chain1 = type == null ? Chain.From(() => FormDialog.FromForm(InsuranceType.BuildForm, FormOptions.PromptInStart)) : Chain.Return(new InsuranceType { Name = type }); var chain2 = chain1 .ContinueWith(async(c, arg) => { var result = await arg; if (!string.Equals(result.Name, "Car", StringComparison.OrdinalIgnoreCase)) { return(Chain.Return((Car)null)); } return(FormDialog.FromForm(Car.BuildForm, FormOptions.PromptInStart)); }); var chain3 = chain2 .ContinueWith(async(c, arg) => { var result = await arg; if (result == null) { return(Chain.Return((Outcome)null)); } return(FormDialog.FromForm(Outcome.BuildForm, FormOptions.PromptInStart)); }); return(chain3); }
public static IDialog <JObject> MakeJsonRootDialog() { return(Chain.From(() => FormDialog.FromForm(BuildJsonForm)) .Do(async(context, order) => { try { var completed = await order; // Actually process the sandwich order... await context.PostAsync("До новых встреч!"); } catch (FormCanceledException <JObject> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last}--maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var message = await result as Activity; var options = "* Site Access \n" + "* Site Creation \n" + "* Site Quota Change \n" + "* External User Access \n" + "* Profile Updates \n" + "* User Guides/ KB Articles \n"; if (message.Text.ToLower().Equals("yes") || message.Text.ToLower().Equals("yep") || message.Text.ToLower().Equals("yup") || message.Text.ToLower().Equals("yeah") || message.Text.ToLower().Equals("y")) { await context.PostAsync("Sure, I can raise a ticket on Service Now, before that I need few inputs from you."); var ServiceNowFormDialog = FormDialog.FromForm(this.BuildServiceNowForm, FormOptions.PromptInStart); context.Call(ServiceNowFormDialog, this.ResumeServiceNowDialog); } else { await context.PostAsync(string.Format("Okay. Let us start over. I can help you with popular Support Requests such as: " + "\r\r" + options + "\r\r Please type any of the above keywords or any other query you may have.")); context.Done("service now exited with no"); } }
public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity) { var connector = new ConnectorClient(new Uri(activity.ServiceUrl)); if (activity.Type == ActivityTypes.ConversationUpdate) { if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id)) { var reply = activity.CreateReply(); reply.Text = "Olá, eu sou o **Dr. Bot**."; await connector.Conversations.ReplyToActivityAsync(reply); } } if (activity.Type == ActivityTypes.Message) { await Conversation.SendAsync(activity, () => { return(Chain.From( () => FormDialog.FromForm(FormFlowHAD.BuildHADForm) )); }); } else { await HandleSystemMessageAsync(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { await Conversation.SendAsync(activity, () => FormDialog.FromForm(WeatherParam.BuildForm) .ContinueWith <WeatherParam, string>(async(ctx, res) => { var WP = await res; var s = await WP.BuildResult(); await ctx.PostAsync(s); return(new ChoiceDialog($"Do you want to subscribe to weather in {WP.Location}?", new string[] { "Yes", "No" })); }).Do(async(ctx, res) => { var r = await res; if (r.ToLower() == "yes") { await ctx.PostAsync("Subscribed"); } else { await ctx.PostAsync("Not subscribed"); } })); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
internal static IDialog <MovieForm> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(MovieForm.BuildForm)) .Do(async(context, survey) => { try { var completed = await survey; await context.PostAsync("Merci pour votre participation !"); } catch (FormCanceledException <MovieForm> e) { string reply; if (e.InnerException == null) { reply = "Vous n’avez pas complété l’enquête !"; if (e.LastForm.LocationTheater == LocationTheaterOptions.Autre) { reply = "Désolé nous ne gérons pas encore toutes les localisations"; } } else { reply = "Erreur. Essayez plus tard !."; } await context.PostAsync(reply); } })); }
private async Task OnOptionSelected(IDialogContext context, IAwaitable <string> result) { try { Trace.TraceInformation("AppAuthDialog::OnOptionSelected"); string optionSelected = await result; UserProfile userInfo = context.ConversationData.GetValue <UserProfile>(UserSessionDataKey); userInfo.ActiveReservation = optionSelected; reservationChoice = optionSelected; context.ConversationData.SetValue <UserProfile>(UserSessionDataKey, userInfo); var cabanaFormDialog = FormDialog.FromForm(this.BuildCabanaForm, FormOptions.PromptInStart); context.Call(cabanaFormDialog, this.ResumeAfterCabanaFormDialog); } catch (TooManyAttemptsException ex) { string fullError = ex.ToString(); Trace.TraceError(fullError); await context.PostAsync($"Sorry, I don't understand."); context.Done(true); } }
internal static IDialog <CardToCardTransfer> MakeRoot() { return(Chain.From(() => FormDialog.FromForm(CardToCardFormBuilder.MakeForm)) .Do(async(context, order) => { try { var completed = await order; var alfaService = new AlfabankService(); string expDate = completed.ValidThruYear.ToString() + ((int)completed.ValidThruMonth).ToString("D2"); string confirmationUrl = await alfaService.TransferMoney(completed.SourceCardNumber, expDate, completed.CVV, completed.DestinationCardNumber, completed.Amount); await context.PostAsync($"Осталось только подтвердить платеж. Перейдите по адресу {confirmationUrl}"); } catch (FormCanceledException <CardToCardTransfer> e) { string reply; if (e.InnerException == null) { reply = $"Вы прервали операцию, попробуем позже!"; } else { reply = "Извините, произошла ошибка. Попробуйте позже."; } await context.PostAsync(reply); } })); }
public HotelsDialog() : base(nameof(HotelsDialog)) { var dialog = FormDialog.FromForm(this.BuildHotelsForm, FormOptions.PromptInStart); AddDialog(dialog); }
internal static IDialog <RoomDetails> MakeRootDialog() { // return Chain.From(() => FormDialog.FromForm(RoomDetails.BuildForm)); return(Chain.From(() => FormDialog.FromForm(RoomDetails.BuildForm)) .Do(async(context, order) => { try { var completed = await order; //add calcs here var output = completed.HeatPumpCalc(); // Post the answer await context.PostAsync("The type of heatpump you need is ... " + output); } catch (FormCanceledException <RoomDetails> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last} -- maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
internal static IDialog <Checklist> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(Checklist.BuildForm)) .Do(async(context, checklist) => { try { var completed = await checklist; // Actually process checklist... await context.PostAsync("Checklist verified !"); } catch (FormCanceledException <Checklist> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last}--maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
private async Task OnOptionSelected(IDialogContext context, IAwaitable <string> result) { try { string optionSelected = await result; switch (optionSelected) { case Flight1: { await context.PostAsync("You can get flight information by answer this question.."); var FlightFormDialog = FormDialog.FromForm <FlightQuery1>(FlightQuery1.BuildForm, FormOptions.PromptInStart); context.Call(FlightFormDialog, this.ResumeAfterOptionDialog); } break; case Flight2: { await context.PostAsync("You can get flight information by answer this question.."); var FlightFormDialog = FormDialog.FromForm <FlightQuery2>(FlightQuery2.BuildForm, FormOptions.PromptInStart); context.Call(FlightFormDialog, this.ResumeAfterOptionDialog2); } break; } } catch (TooManyAttemptsException ex) { await context.PostAsync($"Weeew! Terlalu banyak nyoba bos :(. Ojo khawatir, silakan coba lagi bos!"); } }
async Task ActionReceivedAsync(IDialogContext context, IAwaitable <string> result) { string action = await result; switch (action.ToLower()) { case "appointment": IDialog <AppointmentForm> appointmentDlg = FormDialog.FromForm(new AppointmentForm().BuildForm); await context.Forward(appointmentDlg, FormDialogResumedAsync, context.Activity as IMessageActivity); break; case "venue": IDialog <VenueForm> venueDlg = FormDialog.FromForm(new VenueForm().BuildForm); await context.Forward(venueDlg, FormDialogResumedAsync, context.Activity as IMessageActivity); break; case "schedule": break; case "help": await context.PostAsync(HelpMessage); context.Wait(MessageReceivedAsync); break; case "register": IDialog <RegisterForm> registerDlg = FormDialog.FromForm(new RegisterForm().BuildForm); await context.Forward(registerDlg, RegisterFormDialogResumedAsync, context.Activity as IMessageActivity); break; } }
private Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var formsDialog = FormDialog.FromForm(BuildBookingsForm, FormOptions.PromptInStart); context.Call(formsDialog, ResumeAfterBooking); return(Task.CompletedTask); }
public async Task ResumeAfterForm(IDialogContext context, IAwaitable <ProjectSelectionForm> result) { var message = await result; if (message.projectTypes.ToString().Equals("CryptoCurrency")) { var sprintFormFlow = FormDialog.FromForm(SprintDetailForm.SprintForm, FormOptions.PromptInStart); context.Call(sprintFormFlow, ResumeAfterSprint); } else if (message.projectTypes.ToString().Equals("FaceDetection")) { var sprintFormFlow = FormDialog.FromForm(SprintDetailForm.SprintForm, FormOptions.PromptInStart); context.Call(sprintFormFlow, ResumeAfterSprint); } else if (message.projectTypes.ToString().Equals("ProjectManagement")) { var sprintFormFlow = FormDialog.FromForm(SprintDetailForm.SprintForm, FormOptions.PromptInStart); context.Call(sprintFormFlow, ResumeAfterSprint); } else { var sprintFormFlow = FormDialog.FromForm(SprintDetailForm.SprintForm, FormOptions.PromptInStart); context.Call(sprintFormFlow, ResumeAfterSprint); } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> /// internal static IDialog <KYC> MakeRootDialog() { return(Chain.From(() => FormDialog.FromForm(KYC.BuildLocalizedForm)) .Do(async(context, state) => { try { var completed = await state; var ficaChecking = await new FicaService().FicaID(new Id_check() { country_code = "ZA", first_name = completed.Name, identity_number = completed.IdNumber, surname = completed.Surname }); string responseBody = await ficaChecking.Content.ReadAsStringAsync(); ficaChecking.Content = new StringContent(responseBody, Encoding.UTF8, "application/json"); await context.PostAsync(responseBody); } catch (FormCanceledException <KYC> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last}--maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }
public async Task StartAsync(IDialogContext context) { var form = FormDialog.FromForm <FlightSearchForm>(FlightSearchForm.Create , FormOptions.PromptInStart); context.Call(form, MessageReceivedAsync); }
internal static IDialog <object> MakeRoot() { return(Chain.From(() => FormDialog.FromForm(PlaceTemplate.BuildPlaceForm)) .Do(async(context, place) => { try { var completed = await place; // Actually process the sandwich order... await context.PostAsync("Thanks"); } catch (FormCanceledException <PlaceTemplate> e) { string reply; if (e.InnerException == null) { reply = $"You quit on {e.Last}--maybe you can finish next time!"; } else { reply = "Sorry, I've had a short circuit. Please try again."; } await context.PostAsync(reply); } })); }