private async Task ProcessMessage(IDialogContext context, LuisResult result) { if (msg.Text != "!users" && msg.Text != "!stats") { await ConversationState.RegisterMessage(msg.From.Name, msg.Text); } var badSentimenCheck = ConversationState.Users.Where((u => u.Sentiment < 0.4 && u.Sentiment != 0)); if (badSentimenCheck.Any()) { ConversationState.TextAnalysisDocumentStore phrasesDoc = await ConversationState.GetPhrasesforConversation(); double score = 0; var k = 0; var i = 0; foreach (var doc in phrasesDoc.documents) { if (doc.score > score) { score = doc.score; k = i; } i++; } var reply = await BuildBingReply(phrasesDoc.documents[k].keyPhrases[0]); await context.PostAsync(reply); //await context.PostAsync(BuildReply( //sb => //{ // foreach (ConversationState.TextAnalysisDocument doc in phrasesDoc.documents) // { // foreach (string x in doc.keyPhrases) // { // sb.AppendLine($"Phrase: {x}"); // } // } // })); } if (msg.Text == "!users") { await context.PostAsync(BuildReply( sb => { ConversationState.Users.ForEach(x => sb.AppendLine(x.name)); })); } //Stats and graph, put into separate LUIS intent, but to be sure, we leave it also here else if (msg.Text == "!stats") { await context.PostAsync(BuildReply( sb => { foreach (var x in ConversationState.Users) { sb.AppendLine($"{x.name}: msgs={x.MessageCount}, sentiment={x.Sentiment}"); } })); } else if (msg.Text == "!graph") { IMessageActivity repl = await CreateGraphReply(context); await context.PostAsync(repl); } else { //await context.PostAsync(""); } context.Wait(MessageReceived); }