Exemple #1
0
        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);
        }