public async Task EnterEmail(IDialogContext context, IAwaitable <object> result) { var message = await result as Activity; string UserID = message.Text; using (HttpClient httpClient = new HttpClient()) { LuisResponse Data = new LuisResponse(); try { var responseInString = await httpClient.GetStringAsync(@"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/daac86e9-b94a-4897-9f5e-3dea98dc3cde?staging=true&verbose=true&timezoneOffset=-360&subscription-key=60c884e98ad84389b452b71ed84894b4&q=" + System.Uri.EscapeDataString(UserID)); Data = JsonConvert.DeserializeObject <LuisResponse>(responseInString); //choice = null; var intent = Data.topScoringIntent.intent; string IntentName = intent; var score = Data.topScoringIntent.score; Data.entities.OrderBy(o => o.startIndex); //string UserName; if (IntentName == "UserInfo" && score > 0.8) { UserData.UserID = Data.entities[0].entity.ToString(); UserData.UserName = SQLManager.GetName(UserData.UserID); if (UserData.UserName.Equals("")) { await context.PostAsync("Enter a valid email"); } else { await context.PostAsync($"hi {UserData.UserName},How can I help you?"); context.Wait(StaticQuestion); } } else { await context.PostAsync("UserName not found"); } } catch (Exception e) { SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString()); //await context.PostAsync("Name Exception"); } } }
//private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result) //{ // RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(2); // PromptDialog.Text(context, this.EnterDepartment, RootDialog.BotResponse); //} public async Task EnterDepartment(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; string departmentchoice = activity.Text; try { using (HttpClient httpClient = new HttpClient()) { LuisResponse Data = new LuisResponse(); var responseInString = await httpClient.GetStringAsync(@"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/daac86e9-b94a-4897-9f5e-3dea98dc3cde?staging=true&verbose=true&timezoneOffset=-360&subscription-key=60c884e98ad84389b452b71ed84894b4&q=" + System.Uri.EscapeDataString(departmentchoice)); Data = JsonConvert.DeserializeObject <LuisResponse>(responseInString); var intent = Data.topScoringIntent.intent; string IntentName = intent; var score = Data.topScoringIntent.score; if (IntentName == "DepartmentIntent" && score > 0.8) { UserData.Department = Data.entities[0].entity.ToString(); RootDialog.UserResponse = UserData.Department; SQLManager.GetName(UserData.UserID); if (UserData.Department == departmentchoice) { RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(5); await context.PostAsync(RootDialog.BotResponse); SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse); context.Wait(EnterContactName); } else { RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(6); await context.PostAsync(RootDialog.BotResponse); SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse); context.Wait(EnterDepartment); } } else { RootDialog.BotResponse = SQLManager.GetVisitorBadgeQuestions(7); await context.PostAsync(RootDialog.BotResponse); SQLManager.GetConversationData(UserData.UserID, RootDialog.UserResponse, RootDialog.BotResponse); context.Wait(EnterDepartment); } } } catch (Exception e) { SQLManager.StoreExceptionData(e.GetType().ToString(), e.Message, e.StackTrace, e.Data.ToString()); //throw e; } }