public async Task Positive(IDialogContext context, LuisResult result) { //Register Message if (msg.Text != "!users" && msg.Text != "!stats") { await ConversationState.RegisterMessage(msg.From.Name, msg.Text); } dynamic res = await BingSearch.CallBingImageSearch(result.Query); Activity replyToConversation = msg.CreateReply(); replyToConversation.Type = "message"; replyToConversation.Attachments = new List <Attachment>(); List <CardImage> cardImages = new List <CardImage>(); var imgUrl = res.contentUrl.ToString(); cardImages.Add(new CardImage(imgUrl.ToString(), "img", null)); List <CardAction> cardButtons = new List <CardAction>(); CardAction plButton = new CardAction() { Value = res.contentUrl, Type = "openUrl", Title = "" }; cardButtons.Add(plButton); ThumbnailCard plCard = new ThumbnailCard() { Title = "", Subtitle = "", Images = cardImages }; Attachment plAttachment = plCard.ToAttachment(); replyToConversation.Attachments.Add(plAttachment); await context.PostAsync(replyToConversation); context.Wait(MessageReceived); }
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); }