private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <string> argument) { var dialog = new PromptDialog.PromptString("Please provide your description: ", "please try again", 2); Debug.WriteLine("0 "); context.Call(dialog, ResumeAfterPrompt); }
private async Task SingleAddressConfirmationFoodByPrice(IDialogContext context, IAwaitable <bool> result) { bool confirm = await result; string userAddress = null; if (confirm) { await context.PostAsync("Great thank you for confirming your location."); //GoogleLocationService locationService = new GoogleLocationService("AIzaSyCgv9wO_gY768dq28ZRf_YRykSsiUF2j2Q"); GoogleLocationService locationService = new GoogleLocationService(GoogleApiKey); MapPoint point = locationService.GetLatLongFromAddress(userAddress); double lat = point.Latitude; double lng = point.Longitude; IEnumerable <MealSearchResultV2> searchedMeals = null; await context.PostAsync($"I found {searchedMeals.Count()} meals near you:"); IMessageActivity resultMessage = GenerateCarousel(context, searchedMeals); await context.PostAsync(resultMessage); context.Wait(MessageReceived); } else { string zipCodeRequest = $"Okay, please provide me a more detailed location with a zip code so I can pin point your location."; PromptDialog.PromptString fdf = new PromptDialog.PromptString(zipCodeRequest, "Retry", 3); context.Call(fdf, OnSecondAddressTask); } }
private async Task OnStockitemNameReceivedAsync(IDialogContext context, IAwaitable <string> result) { var stockitemName = await result; // send typing message var typingMessage = context.MakeMessage(); typingMessage.Type = ActivityTypes.Typing; await context.PostAsync(typingMessage); await Task.Delay(3000); // get results var dataManager = new DataManager(); var stockItems = await dataManager.GetStockitemsAsync(stockitemName); if (stockItems.Count == 0) { var dialog = new PromptDialog.PromptString("Sorry, we didn't find this article. What is its name?", "Sorry. What product did you mean?", 3); context.Call(dialog, OnStockitemNameReceivedAsync); } else if (stockItems.Count == 1) { await SendOrderConfirmationAsync(context, stockItems.First()); } else { var dialog = new PromptDialog.PromptChoice <Stockitem>(stockItems, "Please select your product.", "Please select.", 3); context.Call(dialog, OnStockItemReceivedAsync); } }
private async Task MealNameAddressConfirmation(IDialogContext context, IAwaitable <bool> result) { bool confirm = await result; SearchMealNameRequest mealRequest = context.UserData.GetValue <SearchMealNameRequest>("searchMealRequest"); if (confirm) { await context.PostAsync("Great thank you for confirming your address."); double lat = 0; double lng = 0; _externalService.GeocodeLocation(mealRequest, out lat, out lng); mealRequest.Meals = _externalService.SearchMealsList(lat, lng, 20); IEnumerable <MealSearchResultV2> searchedMeals = mealRequest.Meals.Where(meals => meals.Title.Contains(mealRequest.MealName)); await ReturnMealSearchResults(context, searchedMeals); } else { string zipCodeRequest = $"Okay, please provide me a more detailed location with a zip code so I can pin point your location."; var fdf = new PromptDialog.PromptString(zipCodeRequest, "Retry", 3); //search food context.Call(fdf, OnSecondAddressTask); } }
private async Task ObterApplicationIdPromptResultAsync(IDialogContext context, IAwaitable <string> result) { var activity = context.Activity; var stateClient = activity.GetStateClient(); var userData = stateClient.BotState.GetUserData(activity.ChannelId, activity.From.Id); var targetSubscription = await result; userData.SetProperty("APPLICATIONID", targetSubscription); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); await context.PostAsync("*ApplicationId selecionada.*"); var securityKey = userData.GetProperty <string>("SECURITYKEY"); if (string.IsNullOrEmpty(securityKey)) { var dialog = new PromptDialog.PromptString("**Informe a secretKey**", "SecretKey inválido.", 3); context.Call(dialog, ObterSecretKeyPromptResultAsync); } else { context.Wait(MessageReceived); } }
public Task StartAsync(IDialogContext context) { var dialog = new PromptDialog.PromptString("What do you want to order?", "Please tell me the name of the product.", 3); context.Call(dialog, OnStockitemNameReceivedAsync); return(Task.CompletedTask); }
private async Task askQuestionAsync(IDialogContext context) { //prompt to get questions var askOption = new PromptOptions <string>( "Yes how can I help you today?", retry: "Try again", speak: "What questions do you have?", retrySpeak: "Speak clearly"); var prompt = new PromptDialog.PromptString(askOption); context.Call <string>(prompt, afterQuestionAsync); }
private async Task CuisineByPriceAddressConfirmation(IDialogContext context, IAwaitable <bool> result) { bool confirm = await result; SearchMealRequest searchMealRequest = context.UserData.GetValue <SearchMealRequest>("searchMealRequest"); if (confirm) { searchMealRequest.Location = searchMealRequest.AddressesArray[0]; await context.PostAsync("Great thank you for confirming your address."); GoogleLocationService locationService = new GoogleLocationService(GoogleApiKey); MapPoint point = locationService.GetLatLongFromAddress(searchMealRequest.Location); double lat = point.Latitude; double lng = point.Longitude; searchMealRequest.Meals = _externalService.SearchMealsByCuisineList(lat, lng, 100, searchMealRequest.CuisineId); //capture mathsign lessthan or greaer than 1:02am IEnumerable <MealSearchResultV2> searchedMeals = searchMealRequest.Meals.Where(meal => meal.Price <= searchMealRequest.Price); if (searchedMeals != null && searchedMeals.Count() > 0) { await context.PostAsync($"I found {searchedMeals.Count()} {searchMealRequest.Cuisine} meals near you:"); } else { var noMealsMessage = $"I couldn't find {searchMealRequest.Cuisine} food near {searchMealRequest.Location}. Try searching for another cuisine."; await context.PostAsync(noMealsMessage); //option to research cuisine since 0 came back } IMessageActivity resultMessage = GenerateCarousel(context, searchedMeals); await context.PostAsync(resultMessage); context.Wait(MessageReceived); } else { string zipCodeRequest = $"Okay, please provide me a more detailed location with a zip code so I can pin point your location."; //context.UserData.SetValue("cuisineByPrice", cuisineByPrice); context.UserData.Replace("cuisineByPrice", searchMealRequest); PromptDialog.PromptString zipCodePrompt = new PromptDialog.PromptString(zipCodeRequest, "Retry", 3); //search food context.Call(zipCodePrompt, OnSecondAddressTask); } }
private void HandleNoMatchedAddress(IDialogContext context, BaseRequest request, ResumeAfter <string> onNewAddress) { string anotherAddressMessage = $"Couldn't find an address that matches the location you provided. Please provide me a more detailed location with a zip code so I can pin point a location."; //context.UserData.SetValue("searchMealRequest", searchMealRequest); context.UserData.Replace(request.Key, request); PromptDialog.PromptString askForSecondAddressPrompt = new PromptDialog.PromptString(anotherAddressMessage, "Retry", 3); context.Call(askForSecondAddressPrompt, onNewAddress); }
private void PromptNewDetailedAddress(IDialogContext context, BaseRequest modelRequest, ResumeAfter <string> onNewEnteredAddress) { string zipCodeRequest = $"Okay, please provide me a more detailed location with a zip code so I can pin point your location."; /*context.UserData.SetValue("mealByDistance", modelRequest)*/ ; context.UserData.Replace(modelRequest.Key, modelRequest); PromptDialog.PromptString prompt = new PromptDialog.PromptString(zipCodeRequest, "Retry", 3); context.Call(prompt, onNewEnteredAddress); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var message = activity.Text?.ToLower() ?? string.Empty; this.query = new ScheduleQuery(); if (message.Contains("wann")) { var talkQuestion = new PromptDialog.PromptString("Welcher Vortrag?", "Entschuldigung. Welchen Vortrag meinen Sie?", 3); context.Call(talkQuestion, ResumeAfterTalkAsync); } }
public async Task LinqQuerySyntax_Throws_ClosureCaptureException() { var prompts = new[] { "p1", "p2" }; var query = new PromptDialog.PromptString(prompts[0], prompts[0], attempts: 1).Select(p => new PromptDialog.PromptString(prompts[1], prompts[1], attempts: 1)).Unwrap().PostToUser(); using (var container = Build(Options.None)) { var formatter = container.Resolve <IFormatter>(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, query); } } }
private async Task contactSupportAsync(IDialogContext context, IAwaitable <string> arguement) { // this will only be triggered if the sentiment is bad and users can to contact support // if it's via cortana channel, it will launch skype directly // else, it will just provide contact method string userResponse = await arguement; if (userResponse == "Yes") { if (this.channel == "cortana") { await SLADemo2.Dialog.updateDatabase.updateTables(lat, lon, feedback, sentiment, email, "closed"); var response = context.MakeMessage(); response.Text = "Thank you for contacting us, we are connecting you with customer service."; response.Speak = "Alright, let me help you contact the department."; await context.PostAsync(response); var message = context.MakeMessage() as IMessageActivity; message.ChannelData = JObject.FromObject(new { action = new { type = "LaunchUri", uri = "skype:live:emsdemo999?call" } }); await context.PostAsync(message); } else { await SLADemo2.Dialog.updateDatabase.updateTables(lat, lon, feedback, sentiment, email, "open"); await context.PostAsync("I can't launch the phone app now. You can reach us @ 12345678."); context.Wait(MessageReceived); } } else { if (this.channel == "cortana") { await context.SayAsync("Thank you. You can contact us at 12345678", "No worries, this is our support number."); } else { var askOption = new PromptOptions <string>( "Please provide us your email for further communication.", retry: "Try again", speak: "Please provide your email for further communication.", retrySpeak: "Speak clearly"); var prompt = new PromptDialog.PromptString(askOption); context.Call <string>(prompt, afterEmailAsync); } } }
private async Task ResourceGroupPromptResultAsync(IDialogContext context, IAwaitable <string> result) { var activity = context.Activity; var stateClient = activity.GetStateClient(); var userData = stateClient.BotState.GetUserData(activity.ChannelId, activity.From.Id); var targetResourceGroup = await result; userData.SetProperty("ACAO:CRIAR_AMBIENTE:RESOURCE_GROUP", targetResourceGroup); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); var dialog = new PromptDialog.PromptString("Qual o nome da aplicação?", "Nome do ambiente inválido.", 3); context.Call(dialog, CriarAmbientePromptResultAsync); }
private async Task provideFeedbackAsync(IDialogContext context, IAwaitable <string> arguement) { // get permission on giving feedback string userResponse = await arguement; if (userResponse == "Yes") { var askOption = new PromptOptions <string>( "What do you think about our new service?", retry: "Try again", speak: "How do feel with our service?", retrySpeak: "Speak clearly"); var prompt = new PromptDialog.PromptString(askOption); context.Call <string>(prompt, afterFeedbackAsync); } else { await context.PostAsync("No worries, hope you enjoy our service!", "Hop you enjoy our service!"); } }
public async Task ReportShippingProblems(IDialogContext context, LuisResult result) { ////string userID = context.UserData.Get<string>("userId"); //get the user description if (result.Entities.Count == 0) { //option 1: ///PromptDialog.Text(context, MessageReceivedAsync, "I need some more info", "please", 0); /// //option 2: Seem below line need to be called in an async method in order not to get await result into null!? var dialog = new PromptDialog.PromptString("Please provide your description: ", "please try again", 2); context.Call(dialog, ResumeAfterPrompt); } else { context.Wait(MessageReceived); } }
private string ObterSecretKey(IDialogContext context) { var activity = context.Activity; var stateClient = activity.GetStateClient(); var userData = stateClient.BotState.GetUserData(activity.ChannelId, activity.From.Id); var secretKeyTarget = userData.GetProperty <string>("SECRETKEY"); if (!string.IsNullOrEmpty(secretKeyTarget)) { return(secretKeyTarget); } var dialog = new PromptDialog.PromptString("Informe a secretKey", "SecretKey inválido.", 3); context.Call(dialog, ObterSecretKeyPromptResultAsync); return(null); }
private string ObterApplicationId(IDialogContext context) { var activity = context.Activity; var stateClient = activity.GetStateClient(); var userData = stateClient.BotState.GetUserData(activity.ChannelId, activity.From.Id); var applicationIdTarget = userData.GetProperty <string>("APPLICATIONID"); if (!string.IsNullOrEmpty(applicationIdTarget)) { return(applicationIdTarget); } var dialog = new PromptDialog.PromptString("Informe a applicationId", "ApplicationId inválido.", 3); context.Call(dialog, ObterApplicationIdPromptResultAsync); return(null); }
private string ObterSubscription(IDialogContext context) { var activity = context.Activity; var stateClient = activity.GetStateClient(); var userData = stateClient.BotState.GetUserData(activity.ChannelId, activity.From.Id); var subscriptionTarget = userData.GetProperty <string>("SUBSCRIPTION"); if (!string.IsNullOrEmpty(subscriptionTarget)) { return(subscriptionTarget); } var dialog = new PromptDialog.PromptString("**Informe a subscription**", "Subscription inválido.", 3); context.Call(dialog, ObterSubscriptionPromptResultAsync); return(null); }
public async Task LinqQuerySyntax_Throws_ClosureCaptureException() { var prompts = new[] { "p1", "p2" }; var query = new PromptDialog.PromptString(prompts[0], prompts[0], attempts: 1).Select(p => new PromptDialog.PromptString(prompts[1], prompts[1], attempts: 1)).Unwrap().PostToUser(); using (var container = Build(Options.None)) { var formatter = container.Resolve<IFormatter>(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, query); } } }