Esempio n. 1
0
        public async Task StartAsync(IDialogContext ctx)
        {
            //await ctx.PostAsync("What year dialog");

            if (response.entities.Count() == 0)
            {
                await ctx.PostAsync(string.Format("I'm sorry, I couldn't find any matches."));

                ctx.Done <object>(null);
            }

            foreach (var item in response.entities)
            {
                if (item.@type == "builtin.encyclopedia.film.film")
                {
                    entityName = item.entity;
                    movieList  = new List <MovieDetails>(await LookupMovieAsync(entityName));
                }
            }

            if (movieList.Count() > 1)
            {
                await ctx.PostAsync(string.Format("I found {0} results containing the term '{1}'. I'm guessing you probably meant this one...", movieList.Count(), entityName));
            }
            else
            {
                await ctx.PostAsync("I found the following movie.");
            }

            List <Attachment> attachmentList = new List <Attachment>();

            foreach (var item in movieList)
            {
                CardImage        image  = new CardImage(item.poster_path);
                List <CardImage> images = new List <CardImage>()
                {
                    image
                };

                var x = await LookupImdbAsync(item.id);

                ThumbnailCard h = new ThumbnailCard()
                {
                    Title    = item.title,
                    Subtitle = string.IsNullOrEmpty(item.release_date) ? "" : item.release_date.Substring(0, 4),
                    //Tap = new CardAction(ActionTypes.OpenUrl, "Visit in IMDB", value: string.Format("http://www.imdb.com/title/{0}", x)),
                    Text    = item.overview_short,
                    Images  = images,
                    Buttons = new List <CardAction>()
                    {
                        new CardAction(ActionTypes.OpenUrl, "Learn more", value: string.Format("http://www.imdb.com/title/{0}", x))
                    }
                };

                attachmentList.Add(h.ToAttachment());
            }

            var reply = ctx.MakeMessage();

            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments      = attachmentList;
            await ctx.PostAsync(reply);

            //ctx.Wait(MessageReceivedAsync);

            ctx.Done <object>(null);
        }
        private Attachment getRecommendDialog(int rcmdDlgId)
        {
            //MEDIA 데이터 추출
            Attachment returnAttachment = new Attachment();

            List <Recommend_DLG_MEDIA> SelectRecommend_DLG_MEDIA = db.SelectRecommend_DLG_MEDIA(rcmdDlgId);

            if (rcmdDlgId != 4)
            {
                for (int i = 0; i < SelectRecommend_DLG_MEDIA.Count; i++)
                {
                    //CardImage 입력
                    cardImage = new CardImage()
                    {
                        Url = SelectRecommend_DLG_MEDIA[i].media_url
                    };

                    if (SelectRecommend_DLG_MEDIA[i].btn_1_context.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[i].btn_1_context,
                            Type  = SelectRecommend_DLG_MEDIA[i].btn_1_type,
                            Title = SelectRecommend_DLG_MEDIA[i].btn_1_title
                        };
                        cardButtons.Add(plButton);
                    }

                    if (SelectRecommend_DLG_MEDIA[i].btn_2_context.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[i].btn_2_context,
                            Type  = SelectRecommend_DLG_MEDIA[i].btn_2_type,
                            Title = SelectRecommend_DLG_MEDIA[i].btn_2_title
                        };
                        cardButtons.Add(plButton);
                    }

                    if (SelectRecommend_DLG_MEDIA[i].btn_3_context.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[i].btn_3_context,
                            Type  = SelectRecommend_DLG_MEDIA[i].btn_3_type,
                            Title = SelectRecommend_DLG_MEDIA[i].btn_3_title
                        };
                        cardButtons.Add(plButton);
                    }

                    if (SelectRecommend_DLG_MEDIA[i].btn_4_context.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[i].btn_4_context,
                            Type  = SelectRecommend_DLG_MEDIA[i].btn_4_type,
                            Title = SelectRecommend_DLG_MEDIA[i].btn_4_title
                        };
                        cardButtons.Add(plButton);
                    }

                    if (SelectRecommend_DLG_MEDIA[i].btn_5_context.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[i].btn_5_context,
                            Type  = SelectRecommend_DLG_MEDIA[i].btn_5_type,
                            Title = SelectRecommend_DLG_MEDIA[i].btn_5_title
                        };
                        cardButtons.Add(plButton);
                    }

                    //message.Attachments.Add(GetHeroCard(SelectRecommend_DLG_MEDIA[i].card_title, "", SelectRecommend_DLG_MEDIA[i].card_text, cardImage, cardButtons));
                    returnAttachment = GetHeroCard(SelectRecommend_DLG_MEDIA[i].card_title, "", SelectRecommend_DLG_MEDIA[i].card_text, cardImage, cardButtons);
                }
            }
            else
            {
                string domainURL = "https://bottest.hyundai.com";

                List <RecommendList> RecommendList = db.SelectedRecommendList(use, important, gender, age);
                RecommendList        recommend     = new RecommendList();

                for (var i = 0; i < RecommendList.Count; i++)
                {
                    string main_color_view    = "";
                    string main_color_view_nm = "";

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_1))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_1 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM1 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_2))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_2 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM2 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_3))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_3 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM3 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_4))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_4 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM4 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_5))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_5 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM5 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_6))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_6 + "/00001.jpg" + "@";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM6 + "@";
                    }
                    ;

                    if (!string.IsNullOrEmpty(RecommendList[i].MAIN_COLOR_VIEW_7))
                    {
                        main_color_view    += domainURL + "/assets/images/price/360/" + RecommendList[i].MAIN_COLOR_VIEW_7 + "/00001.jpg";
                        main_color_view_nm += RecommendList[i].MAIN_COLOR_VIEW_NM7 + "@";
                    }
                    ;

                    main_color_view    = main_color_view.TrimEnd('@');
                    main_color_view_nm = main_color_view_nm.TrimEnd('@');

                    var subtitle = RecommendList[i].TRIM_DETAIL + "|" + "가격: " + RecommendList[i].TRIM_DETAIL_PRICE + "|" +
                                   main_color_view + "|" +
                                   RecommendList[i].OPTION_1_IMG_URL + "|" +
                                   RecommendList[i].OPTION_1 + "|" +
                                   RecommendList[i].OPTION_2_IMG_URL + "|" +
                                   RecommendList[i].OPTION_2 + "|" +
                                   RecommendList[i].OPTION_3_IMG_URL + "|" +
                                   RecommendList[i].OPTION_3 + "|" +
                                   RecommendList[i].OPTION_4_IMG_URL + "|" +
                                   RecommendList[i].OPTION_4 + "|" +
                                   RecommendList[i].OPTION_5_IMG_URL + "|" +
                                   RecommendList[i].OPTION_5 + "|" +
                                   main_color_view_nm;

                    if (SelectRecommend_DLG_MEDIA[0].btn_1_title.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[0].btn_1_context,
                            Type  = SelectRecommend_DLG_MEDIA[0].btn_1_type,
                            Title = SelectRecommend_DLG_MEDIA[0].btn_1_title
                        };
                        cardButtons.Add(plButton);
                    }

                    if (SelectRecommend_DLG_MEDIA[0].btn_2_title.Length != 0)
                    {
                        CardAction plButton = new CardAction()
                        {
                            Value = SelectRecommend_DLG_MEDIA[0].btn_2_context,
                            Type  = SelectRecommend_DLG_MEDIA[0].btn_2_type,
                            Title = SelectRecommend_DLG_MEDIA[0].btn_2_title
                        };
                        cardButtons.Add(plButton);
                    }
                    returnAttachment = GetHeroCard("trim", subtitle, "", cardImage, cardButtons);
                }
            }
            return(returnAttachment);
        }
Esempio n. 3
0
        public async Task AskFilm(IDialogContext context, LuisResult result)
        {
            string               replyMessage  = "";
            HttpClient           client        = new HttpClient();
            string               themoviedbUrl = "https://www.themoviedb.org/movie/";
            string               baseUri       = "https://api.themoviedb.org/3";
            string               imageUrl      = "https://image.tmdb.org/t/p/w600_and_h900_bestv2";
            string               apiKey        = "?api_key=e01be34ceffec7c3b4fc1c591884c2fc";
            EntityRecommendation rec;

            ResultModel.RootObject rootObject = new ResultModel.RootObject();

            if (result.TryFindEntity("Film", out rec))
            {
                string filmName = rec.Entity;
                replyMessage = $"Ok, let me think..";
                await context.PostAsync(replyMessage);

                Console.WriteLine(filmName);
                string searchQuery = await client.GetStringAsync(new Uri(
                                                                     baseUri
                                                                     + "/search/movie"
                                                                     + apiKey
                                                                     + "&query="
                                                                     + filmName
                                                                     ));

                rootObject = JsonConvert.DeserializeObject <ResultModel.RootObject>(searchQuery);
                if (rootObject.total_results > 0)
                {
                    int searchFilmId = rootObject.results[0].id;

                    string recommendationQuery = await client.GetStringAsync(new Uri(
                                                                                 baseUri
                                                                                 + $"/movie/{searchFilmId}/recommendations"
                                                                                 + apiKey
                                                                                 ));

                    rootObject = JsonConvert.DeserializeObject <ResultModel.RootObject>(recommendationQuery);
                    int cardsLength;
                    if (rootObject.total_results > MAX_DECK_SIZE)
                    {
                        cardsLength = MAX_DECK_SIZE;
                    }
                    else if (rootObject.total_results > 0 && rootObject.total_results < MAX_DECK_SIZE)
                    {
                        cardsLength = rootObject.total_results;
                    }
                    else
                    {
                        cardsLength = 0;
                    }

                    var reply = context.MakeMessage();
                    reply.AttachmentLayout = "carousel";
                    reply.Attachments      = new List <Attachment>();
                    for (int i = 0; i < cardsLength; i++)
                    {
                        List <CardImage>   cardImages  = new List <CardImage>();
                        List <CardAction>  cardButtons = new List <CardAction>();
                        ResultModel.Result resultFilm  = rootObject.results[i];
                        CardImage          ci          = new CardImage($"{imageUrl}{resultFilm.poster_path}");
                        cardImages.Add(ci);
                        CardAction ca = new CardAction()
                        {
                            Title = resultFilm.title,
                            Type  = "openUrl",
                            Value = $"{themoviedbUrl}{resultFilm.id}"
                        };
                        CardAction button = new CardAction()
                        {
                            Title = $"Add to watch list",
                            Type  = "postBack",
                            Value = "<ADD FILM>{"
                                    + $"id: {resultFilm.id},"
                                    + $"title: \"{resultFilm.title}\""
                                    + "}"
                        };
                        cardButtons.Add(button);
                        ThumbnailCard tc = new ThumbnailCard()
                        {
                            Title    = resultFilm.title,
                            Subtitle = resultFilm.overview,
                            Images   = cardImages,
                            Tap      = ca,
                            Buttons  = cardButtons
                        };
                        reply.Attachments.Add(tc.ToAttachment());
                    }

                    // send the cards
                    await context.PostAsync(reply);

                    context.Wait(MessageReceived);
                }
            }
            else   // No film entity detected
            {
                replyMessage = "Please name a film for me to work off";
            }

            await context.PostAsync(replyMessage);

            context.Wait(MessageReceived);
        }
Esempio n. 4
0
        public Activity GetHelp(IDialogContext context)
        {
            Activity replyToConversation;

            replyToConversation                  = ((Activity)context.Activity).CreateReply("En quoi puis-je t'aider? :)");
            replyToConversation.Recipient        = context.Activity.From;
            replyToConversation.Type             = "message";
            replyToConversation.AttachmentLayout = "carousel";
            replyToConversation.Attachments      = new List <Attachment>();

            List <string> pictures = new List <string>();

            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/FBMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/EventMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/YoutubeMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/TwitterMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/LinkedinMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/SiteMIC.jpg");

            for (int i = 0; i < pictures.Count(); i++)
            {
                if (pictures[i] == "")
                {
                    pictures[i] = $"{ ConfigurationManager.AppSettings["WebAppUrl"] }/Images/SiteMIC.jpg";
                }
            }

            List <string> btnAction = new List <string>();

            btnAction.Add(ConfigurationManager.AppSettings["FaceBookMIC"]);
            btnAction.Add(ConfigurationManager.AppSettings["MeetupMIC"]);
            btnAction.Add(ConfigurationManager.AppSettings["YoutubeMIC"]);
            btnAction.Add(ConfigurationManager.AppSettings["TwitterMIC"]);
            btnAction.Add(ConfigurationManager.AppSettings["LinkedinMIC"]);
            btnAction.Add(ConfigurationManager.AppSettings["SiteMIC"]);

            List <string> btnString = new List <string>();

            btnString.Add("Notre Facebook");
            btnString.Add("Notre Meetup");
            btnString.Add("Notre chaîne Youtube");
            btnString.Add("Notre Twitter");
            btnString.Add("Notre Linkedin");
            btnString.Add("Notre Site");

            for (int i = 0; i < btnAction.Count(); i++)
            {
                List <CardAction> cardsAction = new List <CardAction>();
                CardAction        action      = new CardAction()
                {
                    Value = btnAction[i].ToString(),
                    Type  = "openUrl",
                    Title = btnString[i]
                };
                cardsAction.Add(action);
                List <CardImage> cardsImage = new List <CardImage>();
                CardImage        img        = new CardImage(url: pictures[i]);
                cardsImage.Add(img);

                HeroCard tmp = new HeroCard()
                {
                    Images  = cardsImage,
                    Text    = btnString[i],
                    Buttons = cardsAction
                };
                Attachment plAttachment = tmp.ToAttachment();
                replyToConversation.Attachments.Add(plAttachment);
            }

            return(replyToConversation);
        }
Esempio n. 5
0
        public async Task FindSpeaker(IDialogContext context, LuisResult result)
        {
            var    reply    = context.MakeMessage();
            string topic    = "";
            string location = "";

            if (result.Entities.Count > 0)
            {
                var  ent      = new EntityRecommendation();
                bool hasTopic = result.TryFindEntity("topic", out ent);
                topic = (hasTopic ? ent.Entity : "");
                bool hasLocation = result.TryFindEntity("location", out ent);
                location = (hasLocation ? ent.Entity : "");


                await context.PostAsync("Searching with *topic* = **" + topic + "** and *location* = **" + location + "**");

                if (!hasLocation)
                {
                    await context.PostAsync("What state do you want a speaker in?");

                    var adaptive = new HeroCard();
                    List <CardAction> cardButtons = new List <CardAction>();
                    CardAction        p1Button    = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} New South Wales", Title = "New South Wales", Type = ActionTypes.PostBack
                    };
                    CardAction p2Button = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} Victoria", Title = "Victoria", Type = ActionTypes.PostBack
                    };
                    CardAction p3Button = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} Queensland", Title = "Queensland", Type = ActionTypes.PostBack
                    };
                    cardButtons.Add(p1Button);
                    cardButtons.Add(p2Button);
                    cardButtons.Add(p3Button);
                    adaptive.Buttons = cardButtons;
                    var attach = adaptive.ToAttachment();
                    reply.Attachments.Add(attach);

                    await context.PostAsync(reply);

                    context.Wait(this.MessageReceived);
                }
                else if (hasTopic && hasLocation)
                {
                    if (location.Equals("nsw") || location.Equals("sydney"))
                    {
                        location = "new south wales";
                    }
                    else if (location.Equals("qld") || location.Equals("brisbane"))
                    {
                        location = "queensland";
                    }
                    else if (location.Equals("vic") || location.Equals("melbourne"))
                    {
                        location = "victoria";
                    }

                    if (!(location.Equals("new south wales") || location.Equals("queensland") || location.Equals("victoria")))
                    {
                        hasLocation = false;
                    }

                    if (hasLocation)
                    {
                        var db = new DocumentDbSettings();
                        db.Connect();
                        List <Profile> profiles = db.SearchTopic(topic);

                        Random rnd = new Random();
                        IEnumerable <Profile> res = profiles.Where(p => p.tags.Any(m => m.Contains(topic))).Where(c => c.states.Any(m => m.Contains(location)));
                        var filteredProfiles      = res.ToList <Profile>().OrderBy(p => rnd.Next());

                        if (filteredProfiles.Count() > 0)
                        {
                            reply.Attachments.Clear();
                            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                            foreach (Profile p in filteredProfiles)
                            {
                                //Site and Email buttons on each card.
                                List <CardAction> buttons    = new List <CardAction>();
                                CardAction        siteButton = new CardAction("button")
                                {
                                    Value = $"{p.website}", Title = "Website", Type = ActionTypes.OpenUrl
                                };
                                CardAction emailButton = new CardAction("button")
                                {
                                    Value = $"mailto:{p.email}", Title = "Email", Type = ActionTypes.OpenUrl
                                };
                                buttons.Add(siteButton);
                                buttons.Add(emailButton);

                                var hero = new HeroCard();
                                hero.Subtitle = p.slogan;
                                hero.Title    = p.name;

                                var bioText = p.bio;
                                //var bioTrunc = TruncateText(bioText, 220);
                                //bioTrunc += "...";

                                hero.Text = bioText;
                                var image = new CardImage();
                                image.Url = "http://tebot2.azurewebsites.net" + p.picture;
                                hero.Images.Add(image);
                                hero.Buttons = buttons;
                                var heroAttach = hero.ToAttachment();
                                reply.Attachments.Add(heroAttach);
                            }

                            await context.PostAsync(reply);

                            context.Wait(this.MessageReceived);
                        }
                    }
                    else
                    {
                        await context.PostAsync("Please search for speakers in New South Wales, Queensland or Victoria");
                    }
                }
                else
                {
                    await context.PostAsync("Topic unable to be captured.");
                }
            }
            else
            {
                await context.PostAsync("Topic could not be found. Please try another topic.");
            }
        }
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            var rand = new Random();

            string[] defaultMessages = { "Estes são alguns resultados que encontrei:",
                                         "Aqui estão alguns dos principais resultados sobre isso:",
                                         "Eu gosto disso, fique à vontade para saber mais:" };
            var      reply = activity.CreateReply(defaultMessages[rand.Next(defaultMessages.Count())]);

            reply.Type             = ActivityTypes.Message;
            reply.TextFormat       = TextFormatTypes.Plain;
            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments      = new List <Attachment>();

            var item = loginUser;

            if (item != null)
            {
                var client = new FacebookClient();
                client.AccessToken = item.AccessTokenFacebook.AccessToken;
                client.Version     = "v2.10";
                client.AppId       = ConfigurationManager.AppSettings["appIdFacebook"];
                client.AppSecret   = ConfigurationManager.AppSettings["appSecretFacebook"];

                dynamic retorno = null;

                //Verifica se foi solicitado algum interesse via pergunta
                if (activity.Text != null)
                {
                    //Envia dados para Application Insights Analytics
                    TelemetryClient telemetry  = new TelemetryClient();
                    var             properties = new Dictionary <string, string> {
                        { "Question", activity.Text }, { "Dialog", "Interesses" }
                    };
                    if (activity.From != null)
                    {
                        properties.Add("Name", activity.From.Name);
                        properties.Add("Channel", activity.ChannelId);
                        properties.Add("IdChatbot", activity.From.Id);
                    }
                    telemetry.TrackEvent("BotQuestion", properties);
                    //

                    string[] words = activity.Text.Split(' ');
                    if (words.Length > 1)
                    {
                        //Call API LUIS (Language Understanding Intelligent Service)
                        var responseLUIS = await Luis.GetResponse(activity);

                        //Trata resposta (DEVE SER CRIADO EM UM OUTRO MÉTODO)
                        if (responseLUIS != null)
                        {
                            var intent = responseLUIS.topScoringIntent;

                            if (!string.IsNullOrEmpty(intent.intent) && intent.intent.ToUpper() != "NONE" && intent.score >= 0.30) //30%
                            {
                                activity.Text = intent.intent;
                            }
                        }
                    }

                    switch (activity.Text.ToUpper())
                    {
                    /*case "Amigos":
                     *  reply.AttachmentLayout = AttachmentLayoutTypes.List;
                     *
                     *  retorno = client.Get("me/friends?fields=name");
                     *
                     *  List<CardElement> cardElements = new List<CardElement>();
                     *
                     *  foreach (var friend in retorno.data)
                     *  {
                     *      cardElements.Add(new TextBlock { Text = friend.name, Size = TextSize.Small });
                     *  }
                     *
                     *  AdaptiveCard adaptiveCard = new AdaptiveCard()
                     *  {
                     *      Body = cardElements
                     *  };
                     *
                     *  reply.Attachments.Add(new Attachment { ContentType = "application/vnd.microsoft.card.adaptive", Content = adaptiveCard });
                     *
                     *  break;*/
                    case "ATLETAS":
                    case "ATHLETES":
                        reply.AttachmentLayout = AttachmentLayoutTypes.List;

                        retorno = client.Get("me?fields=favorite_athletes");

                        if (retorno.Count > 1)
                        {
                            foreach (var athlete in retorno.favorite_athletes)
                            {
                                HeroCard plCard = new HeroCard()
                                {
                                    Title = athlete.name
                                };

                                Attachment attachment = plCard.ToAttachment();
                                reply.Attachments.Add(attachment);
                            }
                        }

                        break;

                    case "ESPORTES":
                    case "SPORTS":
                        reply.AttachmentLayout = AttachmentLayoutTypes.List;

                        retorno = client.Get("me?fields=sports");

                        if (retorno.Count > 1)
                        {
                            foreach (var sport in retorno.sports)
                            {
                                HeroCard plCard = new HeroCard()
                                {
                                    Title = sport.name
                                };

                                Attachment attachment = plCard.ToAttachment();
                                reply.Attachments.Add(attachment);
                            }
                        }

                        break;

                    case "EVENTOS":
                    case "EVENTS":
                        retorno = client.Get("me/events?fields=name,cover,id");

                        foreach (var evento in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                cardImages.Add(new CardImage(url: evento.cover.source));
                            }
                            catch (Exception ex) { }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = "https://www.facebook.com/events/" + evento.id,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            HeroCard plCard = new HeroCard()
                            {
                                Title   = evento.name,
                                Images  = cardImages,
                                Buttons = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "FILMES":
                    case "MOVIES":
                        //FILMES JÁ ASSISTIDOS:
                        //retorno = client.Get("me/video.watches?fields=data");
                        retorno = client.Get("me/movies?fields=name,genre,about,description,link,cover");

                        foreach (var movie in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                cardImages.Add(new CardImage(url: movie.cover.source));
                            }
                            catch (Exception ex) { }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = movie.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            HeroCard plCard = new HeroCard()
                            {
                                Title    = movie.name,
                                Subtitle = movie.genre,
                                Text     = !string.IsNullOrEmpty(movie.description) ? movie.description : movie.about,
                                Images   = cardImages,
                                Buttons  = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "FOTOS":
                    case "PHOTOS":
                        retorno = client.Get("me/photos?fields=name,link,images");

                        foreach (var photo in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            cardImages.Add(new CardImage(url: photo.images[0].source));

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = photo.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            HeroCard plCard = new HeroCard()
                            {
                                Subtitle = photo.name,
                                Images   = cardImages,
                                Buttons  = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);

                            //ADAPTIVECARD : http://adaptivecards.io/explorer/#ActionOpenUrl

                            /*List<CardElement> cardElements = new List<CardElement>();
                             * cardElements.Add(new Image { Url = photo.picture.data.url, Size = ImageSize.Large, HorizontalAlignment = HorizontalAlignment.Center });
                             * cardElements.Add(new TextBlock { Text = photo.name, Size = TextSize.Small });
                             *
                             * List<ActionBase> cardActions = new List<ActionBase>();
                             * cardActions.Add(new OpenUrlAction { Url = photo.link, Title = "Mais Informações" });
                             *
                             * AdaptiveCard adaptiveCard = new AdaptiveCard()
                             * {
                             *  Body = cardElements,
                             *  Actions = cardActions
                             * };
                             *
                             * Attachment attachment = new Attachment();
                             * attachment.ContentType = "application/vnd.microsoft.card.adaptive";
                             * attachment.Content = adaptiveCard;*/
                        }

                        break;

                    case "GOSTOS":
                    case "LIKES":
                        reply.AttachmentLayout = AttachmentLayoutTypes.List;

                        retorno = client.Get("me/likes?fields=name,about,picture");

                        foreach (var like in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                cardImages.Add(new CardImage(url: like.picture.data.url));
                            }
                            catch (Exception ex) { }

                            ThumbnailCard plCard = new ThumbnailCard()
                            {
                                Title    = like.name,
                                Subtitle = like.about,
                                Images   = cardImages
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "JOGOS":
                    case "GAMES":
                        retorno = client.Get("me/games?fields=name,link,picture,description,category");

                        foreach (var game in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                cardImages.Add(new CardImage(url: game.picture.data.url));
                            }
                            catch (Exception ex) { }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = game.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            ThumbnailCard plCard = new ThumbnailCard()
                            {
                                Title    = game.name,
                                Subtitle = game.category,
                                Text     = game.description,
                                Images   = cardImages,
                                Buttons  = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "LIVROS":
                    case "BOOKS":
                        //LIVROS JÁ LIDOS:
                        //retorno = client.Get("me/books.reads?fields=data");
                        retorno = client.Get("me/books?fields=name,description,link,picture,about");

                        foreach (var book in retorno.data)
                        {
                            /*List<CardImage> cardImages = new List<CardImage>();
                             * cardImages.Add(new CardImage(url: book.picture.data.url));*/

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = book.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            HeroCard plCard = new HeroCard()
                            {
                                Title = book.name,
                                Text  = !string.IsNullOrEmpty(book.description) ? book.description : book.about,
                                //Images = cardImages,
                                Buttons = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "LUGARES":
                    case "PLACES":
                        retorno = client.Get("me/tagged_places?fields=name,place");

                        var apiKey = ConfigurationManager.AppSettings["BingMapsApiKey"];

                        List <Models.Location> locations = new List <Models.Location>();
                        foreach (var place in retorno.data)
                        {
                            if (place.place.location != null)
                            {
                                Models.Location location = new Models.Location();

                                Models.GeocodePoint geocodePoint = new Models.GeocodePoint();
                                geocodePoint.Coordinates = new List <double>();
                                geocodePoint.Coordinates.Add(place.place.location.latitude);     //latitude
                                geocodePoint.Coordinates.Add(place.place.location.longitude);    //longitude

                                location.Point = geocodePoint;
                                location.Name  = place.place.name;

                                try
                                {
                                    string endereco = "";
                                    if (!string.IsNullOrEmpty(place.place.location.street))
                                    {
                                        endereco = place.place.location.street;
                                    }

                                    if (!string.IsNullOrEmpty(place.place.location.city) && !string.IsNullOrEmpty(place.place.location.state))
                                    {
                                        if (string.IsNullOrEmpty(endereco))
                                        {
                                            endereco += place.place.location.city + "/" + place.place.location.state;
                                        }
                                        else
                                        {
                                            endereco += " - " + place.place.location.city + "/" + place.place.location.state;
                                        }
                                    }

                                    if (!string.IsNullOrEmpty(place.place.location.country))
                                    {
                                        if (string.IsNullOrEmpty(endereco))
                                        {
                                            endereco += place.place.location.country;
                                        }
                                        else
                                        {
                                            endereco += " - " + place.place.location.country;
                                        }
                                    }

                                    if (!string.IsNullOrEmpty(endereco))
                                    {
                                        location.Name += " (" + endereco + ")";
                                    }
                                }
                                catch (Exception ex) { }

                                locations.Add(location);
                            }
                        }

                        var cards = new List <HeroCard>();
                        int i     = 1;
                        foreach (var location in locations)
                        {
                            var heroCard = new HeroCard
                            {
                                Subtitle = location.Name
                            };

                            if (location.Point != null)
                            {
                                var image = new CardImage(
                                    url: new BingGeoSpatialService(apiKey).GetLocationMapImageUrl(location, i)
                                    );

                                heroCard.Images = new[] { image };

                                NumberFormatInfo nfi = new NumberFormatInfo();
                                nfi.NumberDecimalSeparator = ".";

                                var button = new CardAction(
                                    type: "openUrl",
                                    title: "Abrir no Google Maps",
                                    value: "https://maps.google.com/maps?ll=" + location.Point.Coordinates[0].ToString(nfi) + "," + location.Point.Coordinates[1].ToString(nfi)
                                    );

                                heroCard.Buttons = new[] { button };
                            }

                            cards.Add(heroCard);

                            i++;
                        }

                        foreach (var card in cards)
                        {
                            reply.Attachments.Add(card.ToAttachment());
                        }

                        break;

                    case "MÚSICAS":
                    case "MUSICAS":
                    case "MUSIC":
                        //MÚSICAS JÁ ESCUTADAS:
                        //retorno = client.Get("me/music.listens?fields=data");
                        retorno = client.Get("me/music?fields=name,about,link,picture,genre");

                        foreach (var music in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                cardImages.Add(new CardImage(url: music.picture.data.url));
                            }
                            catch (Exception ex) { }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = music.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            ThumbnailCard plCard = new ThumbnailCard()
                            {
                                Title    = music.name,
                                Subtitle = music.genre,
                                Text     = music.about,
                                Images   = cardImages,
                                Buttons  = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "TELEVISÃO":
                    case "TELEVISAO":
                    case "TELEVISION":
                        //PROGRAMAS DE TV JÁ ASSISTIDOS:
                        //retorno = client.Get("me/video.watches?fields=data");
                        retorno = client.Get("me/television?fields=name,genre,description,link,cover,about");

                        foreach (var tv in retorno.data)
                        {
                            List <CardImage> cardImages = new List <CardImage>();
                            try
                            {
                                if (tv.cover.Count > 0)
                                {
                                    cardImages.Add(new CardImage(url: tv.cover.source));
                                }
                            }
                            catch (Exception ex) { }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = tv.link,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            HeroCard plCard = new HeroCard()
                            {
                                Title    = tv.name,
                                Subtitle = tv.genre,
                                Text     = !string.IsNullOrEmpty(tv.description) ? tv.description : tv.about,
                                Images   = cardImages,
                                Buttons  = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;

                    case "TIMES":
                    case "TEAMS":
                        reply.AttachmentLayout = AttachmentLayoutTypes.List;

                        retorno = client.Get("me?fields=favorite_teams");

                        if (retorno.Count > 1)
                        {
                            foreach (var team in retorno.favorite_teams)
                            {
                                HeroCard plCard = new HeroCard()
                                {
                                    Title = team.name
                                };

                                Attachment attachment = plCard.ToAttachment();
                                reply.Attachments.Add(attachment);
                            }
                        }

                        break;

                    case "VÍDEOS":
                    case "VIDEOS":
                        retorno = client.Get("me/videos?fields=description,source,permalink_url,thumbnails");

                        foreach (var video in retorno.data)
                        {
                            ThumbnailUrl image = new ThumbnailUrl();
                            image.Url = video.thumbnails.data[0].uri;
                            foreach (var thumbnail in video.thumbnails.data)
                            {
                                if (thumbnail.is_preferred)
                                {
                                    image.Url = thumbnail.uri;
                                    break;
                                }
                            }

                            List <CardAction> cardButtons = new List <CardAction>();
                            cardButtons.Add(new CardAction()
                            {
                                Value = "https://www.facebook.com" + video.permalink_url,
                                Type  = "openUrl",
                                Title = "Mais Informações"
                            });

                            List <MediaUrl> mediaUrl = new List <MediaUrl>();
                            mediaUrl.Add(new MediaUrl(url: video.source));

                            VideoCard plCard = new VideoCard()
                            {
                                Title   = video.description,
                                Media   = mediaUrl,
                                Image   = image,
                                Buttons = cardButtons
                            };

                            Attachment attachment = plCard.ToAttachment();
                            reply.Attachments.Add(attachment);
                        }

                        break;
                    }
                }
            }

            if (reply.Attachments.Count == 0)
            {
                reply.Text = "Desculpe! Eu não encontrei nada sobre isso ou não estou capacitado para entender esse tipo de solicitação \U0001F61E";
            }

            await context.PostAsync(reply);

            context.Wait(this.MessageReceivedAsync);
        }
        public async Task StartAsync(IDialogContext context)
        {
            IMessageActivity message = context.MakeMessage();

            message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            message.Attachments      = new List <Attachment>();

            foreach (var model in options)
            {
                HeroCard card = new HeroCard
                {
                    Title    = model.Title,
                    Subtitle = model.Subtitle,
                    Text     = model.Text
                };

                CardImage image = new CardImage
                {
                    Url = model.ImageUrl
                };

                card.Buttons = new List <CardAction>
                {
                    new CardAction
                    {
                        Title = "América do Norte",
                        Value = "América do Norte",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "América Central",
                        Value = "América Central",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "América do Sul",
                        Value = "América do Sul",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "África",
                        Value = "África",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "Oriente Médio",
                        Value = "Oriente Médio",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "Europa",
                        Value = "Europa",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "Oceania",
                        Value = "Oceania",
                        Type  = "imBack"
                    },
                    new CardAction
                    {
                        Title = "Ásia",
                        Value = "Ásia",
                        Type  = "imBack"
                    }
                };
                card.Images = new List <CardImage> {
                    image
                };
                message.Attachments.Add(card.ToAttachment());
            }

            await context.PostAsync(message);

            context.Wait(MessageReceivedAsync);
        }
Esempio n. 8
0
        internal static ThumbnailCard GetThumbnailCard(string title, string subtitle, string text, CardImage cardImage,
                                                       IList <CardAction> buttons)
        {
            var thumbnailCard = new ThumbnailCard
            {
                Title    = title,
                Subtitle = subtitle,
                Text     = text,
                Buttons  = buttons
            };

            if (cardImage != null)
            {
                thumbnailCard.Images = new List <CardImage> {
                    cardImage
                }
            }
            ;
            return(thumbnailCard);
        }
Esempio n. 9
0
 private static IList <Attachment> GetAnimationCard(string title, string subtitle, CardImage url)
 {
     return(new List <Attachment>()
     {
         new HeroCard
         {
             Title = title,
             //Subtitle = subtitle,
             Images = new List <CardImage>()
             {
                 url
             },
             // Buttons = new List<CardAction>() { cardAction},
         }.ToAttachment()
     });
 }
Esempio n. 10
0
        internal static HeroCard GetHeroCard(string title, string subtitle, string text, CardImage cardImage,
                                             IList <CardAction> buttons)
        {
            var heroCard = new HeroCard
            {
                Title    = title,
                Subtitle = subtitle,
                Text     = text,
                Buttons  = buttons
            };

            if (cardImage != null)
            {
                heroCard.Images = new List <CardImage> {
                    cardImage
                }
            }
            ;
            return(heroCard);
        }
Esempio n. 11
0
 internal static ReceiptItem GetReceiptItem(string title, string subtitle,
                                            string price, string quantity, string text, CardImage cardImage)
 {
     return(new ReceiptItem
     {
         Title = title,
         Subtitle = subtitle,
         Price = price,
         Quantity = quantity,
         Text = text,
         Image = cardImage
     });
 }
Esempio n. 12
0
        private async Task ActivityReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;
            var reply    = activity.CreateReply();

            reply.Attachments = new List <Attachment>();

            if (activity.Text.StartsWith("hi"))
            {
                reply.Attachments.Add(new Attachment()
                {
                    ContentUrl  = "https://media.giphy.com/media/AaA2UnCqV3RAY/giphy.gif",
                    ContentType = "image/png",
                    Name        = "hi.png"
                });
            }
            else if (activity.Text.StartsWith("who are you"))
            {
                HeroCard hc = new HeroCard()
                {
                    Title    = "Who am I?",
                    Subtitle = "I'm the bot!"
                };
                List <CardImage> images = new List <CardImage>();
                CardImage        ci     = new CardImage("https://bot-metrics.com/assets/bm-bot-1bd9cec04cf3dd15a17ab8f9d391c3ef9a5fcad5c87bfae82c7bc3a6e774c243.png");
                images.Add(ci);
                hc.Images = images;
                reply.Attachments.Add(hc.ToAttachment());
            }
            else if (activity.Text.StartsWith("help"))
            {
                List <CardImage> images = new List <CardImage>();
                CardImage        ci     = new CardImage("http://intelligentlabs.co.uk/images/IntelligentLabs-White-Small.png");
                images.Add(ci);
                CardAction ca = new CardAction()
                {
                    Title = "Visit Support",
                    Type  = "openUrl",
                    Value = "http://www.intelligentlabs.co.uk"
                };
                ThumbnailCard tc = new ThumbnailCard()
                {
                    Title    = "Need help?",
                    Subtitle = "Go to our main site support.",
                    Images   = images,
                    Tap      = ca
                };
                reply.Attachments.Add(tc.ToAttachment());
            }
            else if (activity.Text.StartsWith("login"))
            {
                List <CardAction> buttons = new List <CardAction>();
                CardAction        ca      = new CardAction()
                {
                    Title = "Sign In",
                    Type  = "signin",
                    Value = "https://www.facebook.com/"
                };
                buttons.Add(ca);
                SigninCard card = new SigninCard()
                {
                    Text    = "You need to sign in to use this",
                    Buttons = buttons
                };
                reply.Attachments.Add(card.ToAttachment());
            }

            await context.PostAsync(reply);

            context.Wait(ActivityReceivedAsync);
        }
Esempio n. 13
0
        public static async void RemoveFilmAsync(Activity activity, ConnectorClient connector)
        {
            HttpClient client    = new HttpClient();
            string     film      = activity.Text.Substring(13);
            JObject    filmJson  = JObject.Parse(film);
            string     filmTitle = (string)filmJson["title"];
            int        filmId    = (int)filmJson["id"];
            Activity   reply     = activity.CreateReply($"Removing \"{filmTitle}\" from your watch list..");
            await connector.Conversations.SendToConversationAsync(reply);

            UserResult userResultModel = new UserResult
            {
                userId   = activity.From.Id,
                resultId = filmId
            };

            await connector.Conversations.SendToConversationAsync(reply);

            List <UserResult> userResultList = await AzureManager.AzureManagerInstance.GetUserResults();

            List <UserResult> searchResultList = userResultList
                                                 .Where(o => o.resultId == filmId)
                                                 .Where(o => o.userId.Equals(activity.From.Id))
                                                 .ToList();
            List <UserResult> personalizedList = userResultList
                                                 .Where(o => o.userId.Equals(activity.From.Id))
                                                 .ToList();

            if (searchResultList.Count > 0)
            {
                UserResult toBeDeleted = searchResultList[0];
                await AzureManager.AzureManagerInstance.DeleteUserResult(toBeDeleted);

                reply = activity.CreateReply($"Deleted {toBeDeleted.id}! Here is your to-watch list:");

                // Display to-watch list
                reply.AttachmentLayout = "carousel";
                reply.Attachments      = new List <Attachment>();
                foreach (UserResult userResult in personalizedList)
                {
                    string apiQuery = await client.GetStringAsync(new Uri(
                                                                      BASE_URI
                                                                      + $"/movie/{userResult.resultId}"
                                                                      + API_KEY
                                                                      ));

                    ResultModel.Result resultObject = JsonConvert.DeserializeObject <ResultModel.Result>(apiQuery);
                    List <CardImage>   cardImages   = new List <CardImage>();
                    List <CardAction>  cardButtons  = new List <CardAction>();
                    CardImage          ci           = new CardImage($"{IMAGE_URL}{resultObject.poster_path}");
                    cardImages.Add(ci);
                    CardAction ca = new CardAction()
                    {
                        Title = resultObject.title,
                        Type  = "openUrl",
                        Value = $"{THE_MOVIE_DB_URL}{resultObject.id}"
                    };
                    CardAction button = new CardAction()
                    {
                        Title = $"Watched it",
                        Type  = "postBack",
                        Value = "<REMOVE FILM>{"
                                + $"id: {resultObject.id},"
                                + $"title: \"{resultObject.title}\""
                                + "}"
                    };
                    cardButtons.Add(button);
                    ThumbnailCard tc = new ThumbnailCard()
                    {
                        Title    = resultObject.title,
                        Subtitle = resultObject.overview,
                        Images   = cardImages,
                        Tap      = ca,
                        Buttons  = cardButtons
                    };
                    reply.Attachments.Add(tc.ToAttachment());
                }
            }
            else
            {
                reply = activity.CreateReply("Oh no, something went wrong :(");
            }

            await connector.Conversations.SendToConversationAsync(reply);
        }
Esempio n. 14
0
 private void RefreshCard()
 {
     if (m_Card == null || m_Card.Special == GameCardSpecial.Null)
     {
         Image = null;
     }
     else
     {
         Image = m_Card.Special != GameCardSpecial.None ? CardImage.GetImage(m_Card.Special, 1) : CardImage.GetImage(m_Card.Kind, m_Card.Value, 1);
     }
 }
Esempio n. 15
0
        internal static IEnumerable <ReceiptItem> CreateReceiptItemSetWithOneItemThatHasSetProperties(string title = default(string), string subtitle = default(string), string text = default(string), CardImage image = default(CardImage), string price = default(string), string quantity = default(string), CardAction tap = default(CardAction))
        {
            var matchingItem = new ReceiptItem(title, subtitle, text, image, price, quantity, tap);
            var items        = CreateRandomReceiptItems();

            items.Add(matchingItem);
            return(items);
        }
Esempio n. 16
0
 private static IList <Attachment> GetHeroCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
 {
     return(new List <Attachment>()
     {
         new HeroCard
         {
             Title = title,
             Subtitle = subtitle,
             Text = text,
             Images = new List <CardImage>()
             {
                 cardImage
             },
             // Buttons = new List<CardAction>() { cardAction},
         }.ToAttachment()
     });
 }
Esempio n. 17
0
        private async Task HelpAsync(IDialogContext context, IAwaitable <string> result)
        {
            string opt   = await result;
            var    reply = context.MakeMessage();

            reply.Attachments = new List <Attachment>();

            switch (opt)
            {
            case "Hello":
                reply.Attachments.Add(new Attachment()
                {
                    ContentUrl  = "http://www.desicomments.com/dc3/13/395166/395166.jpg",
                    ContentType = "image/jpg",
                    Name        = "Hello.jpg"
                });

                break;

            case "How are you":
                HeroCard hc1 = new HeroCard()
                {
                    Title    = "I am fine",
                    Subtitle = "How are you?"
                };
                List <CardImage> image1 = new List <CardImage>();
                CardImage        ci1    = new CardImage("http://www.desicomments.com/wp-content/uploads/2017/01/Im-Fine-600x398.jpg");
                image1.Add(ci1);
                hc1.Images = image1;
                reply.Attachments.Add(hc1.ToAttachment());
                break;

            case "What is your name":
                HeroCard hc2 = new HeroCard()
                {
                    Title    = "My namre is Zalvis",
                    Subtitle = "I am a Bot"
                };
                List <CardImage> image2 = new List <CardImage>();
                CardImage        ci2    = new CardImage("http://www.desicomments.com/wp-content/uploads/2017/02/Vampire-Smiley-600x315.jpg");
                image2.Add(ci2);
                hc2.Images = image2;
                reply.Attachments.Add(hc2.ToAttachment());
                break;

            case "Blog":
                List <CardAction> cardButtons = new List <CardAction>();
                CardAction        hButton     = new CardAction()
                {
                    Value = "http://softwarelifevk.blogspot.in/2017/03/self-introduction.html",
                    Type  = "openUrl",
                    Title = "Blog Page"
                };
                cardButtons.Add(hButton);
                HeroCard hc3 = new HeroCard()
                {
                    Title    = "View My Blog",
                    Subtitle = "Let's go",
                    Buttons  = cardButtons
                };
                List <CardImage> image3 = new List <CardImage>();
                CardImage        ci3    = new CardImage("http://www.desicomments.com/wp-content/uploads/2017/02/Wile-E.-Coyote-Looking-Something-Image-600x777.jpg");
                image3.Add(ci3);
                hc3.Images = image3;


                /* Other Way of Attaching
                 * Attachment plAttachment = hc3.ToAttachment();
                 * reply.Attachments.Add(plAttachment);*/

                reply.Attachments.Add(hc3.ToAttachment());
                break;

            default:
                await context.PostAsync("Please only chose from the options given");

                break;
            }



            await context.PostAsync(reply);

            context.Wait(MessageReceived);
        }
        private static Attachment GetHeroCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction, CardAction cardAction2)
        {
            if (cardAction2 != null)
            {
                var heroCard = new HeroCard
                {
                    Title    = title,
                    Subtitle = subtitle,
                    Text     = text,
                    Images   = new List <CardImage>()
                    {
                        cardImage
                    },
                    Buttons = new List <CardAction>()
                    {
                        cardAction, cardAction2
                    },
                };

                return(heroCard.ToAttachment());
            }
            else
            {
                var heroCard = new HeroCard
                {
                    Title    = title,
                    Subtitle = subtitle,
                    Text     = text,
                    Images   = new List <CardImage>()
                    {
                        cardImage
                    },
                    Buttons = new List <CardAction>()
                    {
                        cardAction
                    },
                };

                return(heroCard.ToAttachment());
            }
        }
Esempio n. 19
0
        //지도 맵 추가
        public static Attachment GetHeroCard_Map(string title, string subtitle, string text, CardImage cardImage, /*CardAction cardAction*/ List <CardAction> buttons, string latitude, string longitude)
        {
            var heroCard = new UserHeroCard
            {
                Title    = title,
                Subtitle = subtitle,
                Text     = text,
                Images   = new List <CardImage>()
                {
                    cardImage
                },
                Buttons   = buttons,
                Latitude  = latitude,
                Longitude = longitude,
            };

            return(heroCard.ToAttachment());
        }
        private async Task ReponseCapeAsync(IDialogContext context, IAwaitable <bool> result)
        {
            _equipements.Cape = await result;


            await context.PostAsync("THE Question");

            #region Construction des cartes
            HeroCard heroCard1 = new HeroCard();
            heroCard1.Title    = "Par dessus le collant";
            heroCard1.Subtitle = "Modèle: SuperLoose 10.45 en Lycra";

            HeroCard heroCard2 = new HeroCard();
            heroCard2.Title    = "Sous le collant";
            heroCard2.Subtitle = "Modèle: MegaWinner 3000 en coton ultra résistant";
            #endregion

            #region Images
            heroCard1.Images = new List <CardImage>();
            CardImage cardImage = new CardImage()
            {
                Url = HttpContext.Current.Request.Url + "/../../images/img_1.png"
            };
            heroCard1.Images.Add(cardImage);

            heroCard2.Images = new List <CardImage>();
            cardImage        = new CardImage()
            {
                Url = HttpContext.Current.Request.Url + "/../../images/img_2.png"
            };
            heroCard2.Images.Add(cardImage);
            #endregion

            #region Bouton
            heroCard1.Buttons = new List <CardAction>();
            CardAction button = new CardAction()
            {
                Value = "looser",
                Type  = ActionTypes.PostBack,
                Title = "Acheter"
            };
            heroCard1.Buttons.Add(button);

            heroCard2.Buttons = new List <CardAction>();
            button            = new CardAction()
            {
                Value = "winner",
                Type  = ActionTypes.PostBack,
                Title = "Acheter"
            };
            heroCard2.Buttons.Add(button);
            #endregion

            #region On envoi le dialogue
            IMessageActivity reply = context.MakeMessage();
            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments.Add(heroCard1.ToAttachment());
            reply.Attachments.Add(heroCard2.ToAttachment());

            await context.PostAsync(reply);

            context.Wait(AfterCostumeAsync);
            #endregion ;
        }
Esempio n. 21
0
        public Activity CarouselPossibilitiesNotAllowed(IDialogContext context)
        {
            List <string> OurPossibilities = new List <string>();

            Activity replyToConversation;

            replyToConversation                  = ((Activity)context.Activity).CreateReply("Je suis capable de te renseigner sur pas mal de chose! :D Tu peux me demander:");
            replyToConversation.Recipient        = context.Activity.From;
            replyToConversation.Type             = "message";
            replyToConversation.AttachmentLayout = "carousel";
            replyToConversation.Attachments      = new List <Attachment>();

            List <string> pictures = new List <string>();

            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/EventMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/SiteMIC.jpg");

            for (int i = 0; i < pictures.Count(); i++)
            {
                if (pictures[i] == "")
                {
                    pictures[i] = $"{ ConfigurationManager.AppSettings["WebAppUrl"] }/Images/SITE MIC v4.jpg";
                }
            }

            List <string> btnAction = new List <string>();

            btnAction.Add("On fait un truc?");
            btnAction.Add("tu as des infos?");

            List <string> btnString = new List <string>();

            btnString.Add("La liste des évènements du MIC");
            btnString.Add("Des informations concernant ma maison, le MIC");

            List <string> titleString = new List <string>();

            btnString.Add("Nos événements");
            btnString.Add("Quelque information");

            for (int i = 0; i < btnAction.Count(); i++)
            {
                List <CardAction> cardsAction = new List <CardAction>();
                CardAction        action      = new CardAction()
                {
                    Value = btnAction[i].ToString(),
                    Type  = "postBack",
                    Title = btnString[i]
                };
                cardsAction.Add(action);
                List <CardImage> cardsImage = new List <CardImage>();
                CardImage        img        = new CardImage(url: pictures[i]);
                cardsImage.Add(img);

                HeroCard tmp = new HeroCard()
                {
                    Images  = cardsImage,
                    Title   = btnString[i],
                    Buttons = cardsAction
                };
                Attachment plAttachment = tmp.ToAttachment();
                replyToConversation.Attachments.Add(plAttachment);
            }

            return(replyToConversation);
        }
Esempio n. 22
0
 public static ICardImageAssertions That(this CardImage cardImage) => new CardImageAssertions(cardImage);
Esempio n. 23
0
        public Activity CarouselPossibilities(IDialogContext context)
        {
            List <string> OurPossibilities = new List <string>();

            Activity replyToConversation;

            replyToConversation                  = ((Activity)context.Activity).CreateReply("Je suis capable de te renseigner sur pas mal de chose! :D Tu peux me demander:");
            replyToConversation.Recipient        = context.Activity.From;
            replyToConversation.Type             = "message";
            replyToConversation.AttachmentLayout = "carousel";
            replyToConversation.Attachments      = new List <Attachment>();

            List <string> pictures = new List <string>();

            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/VisitTodayMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/MoyFreqMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/EventMIC.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/APropos.jpg");
            pictures.Add($"{ConfigurationManager.AppSettings["WebAppUrl"]}/Images/BestFriend.jpg");

            for (int i = 0; i < pictures.Count(); i++)
            {
                if (pictures[i] == "")
                {
                    pictures[i] = $"{ ConfigurationManager.AppSettings["WebAppUrl"] }/Images/SITE MIC v4.jpg";
                }
            }

            List <string> btnAction = new List <string>();

            btnAction.Add("Liste visite jour");
            btnAction.Add("Combien de personne viennent en moyenne au MIC?");
            btnAction.Add("On fait un truc?");
            btnAction.Add("tu as des infos?");
            btnAction.Add("Qui est ton meilleur ami?");

            List <string> btnString = new List <string>();

            btnString.Add("Visites du jour");
            btnString.Add("Moyenne de fréquentation");
            btnString.Add("Evénements");
            btnString.Add("Informations sur le MIC");
            btnString.Add("Meilleur ami");

            List <string> titleString = new List <string>();

            titleString.Add("La liste des visites du jour");
            titleString.Add("La moyenne de fréquentation du MIC");
            titleString.Add("Nos événements");
            titleString.Add("Quelques informations");
            titleString.Add("Mon meilleur ami");


            for (int i = 0; i < btnAction.Count(); i++)
            {
                List <CardAction> cardsAction = new List <CardAction>();
                CardAction        action      = new CardAction()
                {
                    Value = btnAction[i].ToString(),
                    Type  = "postBack",
                    Title = btnString[i]
                };
                cardsAction.Add(action);
                List <CardImage> cardsImage = new List <CardImage>();
                CardImage        img        = new CardImage(url: pictures[i]);
                cardsImage.Add(img);

                HeroCard tmp = new HeroCard()
                {
                    Images  = cardsImage,
                    Title   = titleString[i],
                    Buttons = cardsAction
                };
                Attachment plAttachment = tmp.ToAttachment();
                replyToConversation.Attachments.Add(plAttachment);
            }

            return(replyToConversation);
        }
Esempio n. 24
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {
            SkillResponse response = new SkillResponse();

            response.Response = new ResponseBody();
            response.Response.ShouldEndSession = false;

            // initialiize the variables we ultimately need for output, the response text and the card
            IOutputSpeech innerResponse = null;
            ICard         responseCard  = null;

            var log = context.Logger;

            log.LogLine($"CoolPlaces Skill Request Object:");
            log.LogLine(JsonConvert.SerializeObject(input));

            // Get what we need to get the zip code from the device
            string alexaDeviceID    = input.Context.System.Device.DeviceID;
            string alexaAPItoken    = input.Context.System.ApiAccessToken;
            string alexaAPIEndpoint = input.Context.System.ApiEndpoint;

            log.LogLine($"CoolPlaces Skill DeviceID:");
            log.LogLine(alexaDeviceID);
            log.LogLine($"CoolPlaces Skill APIAccessToken:");
            log.LogLine(alexaAPItoken);
            log.LogLine($"CoolPlaces Skill APIEndpoint:");
            log.LogLine(alexaAPIEndpoint);

            //alexa url info
            string ep1            = "/v1/devices/";
            string ep2            = "/settings/address/countryAndPostalCode";
            string alexaLookupURL = alexaAPIEndpoint + ep1 + alexaDeviceID + ep2;

            log.LogLine($"CoolPlaces Skill DeviceLocationEndpoint:");
            log.LogLine(alexaLookupURL);

            // this is where we get the location info from alexa.
            //if it errors out, we know we dont have the permissions yet
            string deviceLocationJSON = Utilities.GetDeviceLocationFromAlexa(alexaAPItoken, alexaLookupURL);

            log.LogLine($"CoolPlaces Skill devicelocation result:");
            log.LogLine(deviceLocationJSON);
            //https://developer.amazon.com/docs/custom-skills/device-address-api.html
            //https://developer.amazon.com/blogs/alexa/post/0c975fc7-17dd-4f5c-8343-a37024b66c99/alexa-skill-recipe-using-the-device-address-api-to-request-information
            string defaultZipCode = "45150";

            bool zipFound = false;

            string zipCode = "";

            //  look to see if the location request errored out, then we know we need to ask for permissions
            if (!deviceLocationJSON.Contains("error code:") && !deviceLocationJSON.Contains("error:"))
            {
                zipFound = true;

                // get the zipcode from the json
                log.LogLine($"CoolPlaces Skill devicelocation found!!!!:");
                log.LogLine(deviceLocationJSON);


                zipCode = Utilities.ExtractDeviceZipCodeFromJSON(log, deviceLocationJSON, defaultZipCode);;
                log.LogLine($"CoolPlaces Skill zipcode:");
                log.LogLine(zipCode);
            }
            else
            {
                // default the zip code
                zipCode = defaultZipCode;
                log.LogLine($"CoolPlaces Skill devicelocation not found :( ");
                log.LogLine(deviceLocationJSON);
            }


            // google variables
            string googleAPIKey = "&key=AIzaSyCM0J-Drb3xKzY96XecL7khAfs33zM4Uac";

            Utilities.PlaceType googlePlaceType = Utilities.PlaceType.bar;
            int googleMileRadiusForSearch       = 10;

            // fetch the location to use for the google search using the zipcode
            string loct = Utilities.GetLocationDataForZipFromGoogle(zipCode, googleAPIKey);
            string googleBaseLocationURLParam = "location=" + loct;

            // initialize the variables and fetch the cool places from google
            var allResources = Utilities.InitCoolPlaces(googleMileRadiusForSearch, googleBaseLocationURLParam, googlePlaceType, googleAPIKey);
            // grab a result from all of the results
            var resource = allResources.FirstOrDefault();

            string responseText = "";

            if (input.GetRequestType() == typeof(LaunchRequest))
            {
                log.LogLine($"CoolPlaces Default LaunchRequest made: 'Alexa, open Cool Places'");

                if (!zipFound)
                {
                    log.LogLine($"CoolPlaces : Need Permissions");

                    innerResponse = new PlainTextOutputSpeech();
                    responseText  = "I need your permission for your location to find cool places near you.  Please see your alexa app to grant me this permission.";
                    (innerResponse as PlainTextOutputSpeech).Text = responseText;

                    AskForPermissionsConsentCard permissionCard = new AskForPermissionsConsentCard();
                    permissionCard.Permissions.Add("read::alexa:device:all:address:country_and_postal_code");

                    responseCard = permissionCard;
                }
                else
                {
                    // everything is fine, so log where we landed
                    // we will create the response text and card at the end of this routine
                    log.LogLine($"CoolPlaces : Dont Need Permissions");
                    log.LogLine($"CoolPlaces LaunchRequest");
                }
            }
            else if (input.GetRequestType() == typeof(IntentRequest))
            {
                var intentRequest = (IntentRequest)input.Request;

                // create response text for intents other than the full cool place response, we will do that one at the end
                switch (intentRequest.Intent.Name)
                {
                case "AMAZON.CancelIntent":
                    log.LogLine($"CoolPlaces AMAZON.CancelIntent: send StopMessage");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.StopMessage;
                    response.Response.ShouldEndSession            = true;
                    break;

                case "AMAZON.StopIntent":
                    log.LogLine($"CoolPlaces AMAZON.StopIntent: send StopMessage");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.StopMessage;
                    response.Response.ShouldEndSession            = true;
                    break;

                case "AMAZON.HelpIntent":
                    log.LogLine($"CoolPlaces AMAZON.HelpIntent: send HelpMessage");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.HelpMessage;
                    break;

                case "AMAZON.FallbackIntent":
                    log.LogLine($"CoolPlaces AMAZON.FallbackIntent");
                    // Same as the help
                    //https://developer.amazon.com/docs/custom-skills/standard-built-in-intents.html#amazonfallbackintent-and-dialogdelegate
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.HelpMessage;
                    break;

                case "AMAZON.NavigateHomeIntent":
                    log.LogLine($"CoolPlaces AMAZON.NavigateHomeIntent");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.StopMessage;
                    response.Response.ShouldEndSession            = true;
                    break;

                case "GetCoolPlaceIntent":
                    // everything is fine, so log where we landed
                    // we will create the response text and card at the end of this routine
                    log.LogLine($"CoolPlaces GetCoolPlaceIntent sent: send cool place");
                    break;

                case "GetNewCoolPlaceIntent":
                    // everything is fine, so log where we landed
                    // we will create the response text and card at the end of this routine
                    log.LogLine($"CoolPlaces GetNewCoolPlaceIntent sent: send new cool place");
                    break;

                default:
                    log.LogLine($"CoolPlaces Unknown intent: " + intentRequest.Intent.Name);
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = resource.HelpReprompt;
                    break;
                }
            }

            // if we have no response to this point, then we need to get a cool place!!
            if (innerResponse == null)
            {
                log.LogLine($"CoolPlaces : form the response text and card for the cool place");

                CoolPlace    myCoolPlace    = null;
                StandardCard myStandardCard = null;
                CardImage    myCardImage    = null;

                // ****START
                // grab info from the API return values and format for alexa card
                myCoolPlace = Utilities.EmitCoolPlace(resource);

                innerResponse = new PlainTextOutputSpeech();
                responseText  = myCoolPlace.Name;
                (innerResponse as PlainTextOutputSpeech).Text = resource.GetCoolPlaceOpenMessage + responseText;

                //SimpleCard mySimpleCard = new SimpleCard();
                //responseCard = new AskForPermissionsConsentCard();
                //responseCard = new LinkAccountCard();
                myStandardCard            = new StandardCard();
                myCardImage               = new CardImage();
                myCardImage.SmallImageUrl = myCoolPlace.Photo.PhotoAPIURL(720, googleAPIKey);
                myCardImage.LargeImageUrl = myCoolPlace.Photo.PhotoAPIURL(1200, googleAPIKey);
                myStandardCard.Image      = myCardImage;

                myStandardCard.Content = myCoolPlace.Name + "\r\n" + myCoolPlace.Location + "\r\n Rating " + myCoolPlace.Rating + " out of 5" + "\r\n";
                myStandardCard.Title   = myCoolPlace.Name;
                responseCard           = myStandardCard;
                // ****END
            }

            /*
             * //accesstoken
             * //input.Context.System.User.AccessToken;
             * //input.Context.System.User.UserId;
             * User myUser = input.Context.System.User;
             * log.LogLine($"CoolPlaces Skill User Object:");
             * log.LogLine(JsonConvert.SerializeObject(myUser));
             */

            // take whatever card and/or response we have and send it to alexa
            response.Response.OutputSpeech = innerResponse;
            response.Response.Card         = responseCard;
            response.Version = "1.0";
            log.LogLine($"CoolPlaces Skill Response Object...");
            log.LogLine(JsonConvert.SerializeObject(response));
            return(response);
        }
        private static Attachment GetHeroCard(string title, string subtitle, string text, CardImage cardImage, /*CardAction cardAction*/ List <CardAction> buttons)
        {
            var heroCard = new HeroCard
            {
                Title    = title,
                Subtitle = subtitle,
                Text     = text,
                Images   = new List <CardImage>()
                {
                    cardImage
                },
                Buttons = buttons,
            };

            return(heroCard.ToAttachment());
        }
Esempio n. 26
0
        public SkillResponse flashBriefing()
        {
            String responseString = "These are the top three news posts on Reddit. ";

            var subredditTask = reddit.SearchSubreddits(SUBREDDIT_FOR_FLASHBRIEFING, 1).First();

            subredditTask.Wait();
            var sr = subredditTask.Result;

            log.LogLine($"WorldNews Subreddit: {sr}");

            var posts = sr.GetPosts(3).ToList <Post>();

            posts.Wait();


            log.LogLine("Posts (toString): " + posts.ToString());
            var i = 0;

            String[] postIntro = { "First Post", "Second Post", "Third Post" };

            List <Post> storedPosts = posts.Result;
            String      imageURL    = "";

            foreach (var post in storedPosts)
            {
                log.LogLine($"Post Title ({i}) | {postIntro[i]}: {post.Title}");
                responseString += $"{postIntro[i]}: {post.Title}. ";
                i++;

                String img = storedPosts[0].Thumbnail.ToString();
                if (img != null && img != "")
                {
                    imageURL = img;
                    break;
                }
            }
            responseString += "See the feed in your Alexa App for more Info.";
            log.LogLine("FullSkillResponse FlashBriefing: " + responseString);

            //CARD
            StandardCard card = new StandardCard();

            card.Title = "The Top 3 News from Reddit";

            String cardContent = $"{storedPosts[0].Title} " +
                                 $"(See more: {storedPosts[0].Url})\n\n" +
                                 $"{storedPosts[1].Title} (See more: {storedPosts[1].Url})\n\n" +
                                 $"{storedPosts[2].Title} (See more: {storedPosts[2].Url})";

            card.Content = cardContent;
            log.LogLine("FlashBriefingCard CardContent: " + cardContent);

            //IMAGE FOR CARD
            if (imageURL != "")
            {
                CardImage cardImage = new CardImage();
                log.LogLine("FlashBriefingCard CardImageURL: " + imageURL);
                cardImage.SmallImageUrl = imageURL;
                cardImage.LargeImageUrl = imageURL;
                card.Image = cardImage;
            }
            else
            {
                log.LogLine("FlashBriefingCard CardImageURL: No post had an image");
            }

            return(Function.MakeSkillResponseWithCard(responseString, true, card));
        }
Esempio n. 27
0
        private static Attachment GetHeroCard(string title, string price, string text, CardImage cardImage)
        {
            var cardAction1 = new CardAction()
            {
                Type = ActionTypes.ImBack, Title = "1", Value = $"1 {title} @ {price}"
            };
            var cardAction2 = new CardAction()
            {
                Type = ActionTypes.ImBack, Title = "2", Value = $"2 {title} @ {price}"
            };
            var cardAction3 = new CardAction()
            {
                Type = ActionTypes.ImBack, Title = "3", Value = $"3 {title} @ {price}"
            };

            var heroCard = new HeroCard
            {
                Title    = title,
                Subtitle = price,
                Text     = text,
                Images   = new List <CardImage>()
                {
                    cardImage
                },
                Buttons = new List <CardAction>()
                {
                    cardAction1, cardAction2, cardAction3
                },
            };

            return(heroCard.ToAttachment());
        }
Esempio n. 28
0
        internal static IEnumerable <ReceiptItem> CreateReceiptItemSetWithAllItemsWithSetProperties(string title = default(string), string subtitle = default(string), string text = default(string), CardImage image = default(CardImage), string price = default(string), string quantity = default(string), CardAction tap = default(CardAction))
        {
            var items = new List <ReceiptItem>();

            for (var i = 0; i < 5; i++)
            {
                var matchingItem = new ReceiptItem(title, subtitle, text, image, price, quantity, tap);
                items.Add(matchingItem);
            }
            return(items);
        }
Esempio n. 29
0
        private static Attachment GetThumbnailCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
        {
            var heroCard = new ThumbnailCard
            {
                Title    = title,
                Subtitle = subtitle,
                Text     = text,
                Images   = new List <CardImage>()
                {
                    cardImage
                },
                Buttons = new List <CardAction>()
                {
                    cardAction
                },
            };

            return(heroCard.ToAttachment());
        }
Esempio n. 30
0
        private IList <Attachment> CarouselCardCreation()
        {
            HeroCard myCard = new HeroCard
            {
                Title    = "Fondo de ahorro para el retiro",
                Subtitle = "Somos una de las Administradoras de Fondos de Ahorro para el Retiro más grandes de México"
            };

            List <CardImage>  imageList      = new List <CardImage>();
            List <CardAction> buttonsList    = new List <CardAction>();
            CardImage         characterImage = new CardImage("https://asistentesura9ad0.blob.core.windows.net/assetsbotsura/suraAfore.png");

            imageList.Add(characterImage);
            myCard.Images = imageList;

            CardAction moreInformationButton = new CardAction();

            moreInformationButton.Title = "Preguntas de Afore";
            moreInformationButton.Type  = ActionTypes.ImBack;
            moreInformationButton.Value = "afore";
            buttonsList.Add(moreInformationButton);
            myCard.Buttons = buttonsList;

            HeroCard myCard2 = new HeroCard
            {
                Title    = "Fondos de inversión",
                Subtitle = "Conoce las publicaciones que tenemos preparadas para ti y a continuar disfrutando de los beneficios de invertir con SURA"
            };

            List <CardImage>  image2List      = new List <CardImage>();
            List <CardAction> buttons2List    = new List <CardAction>();
            CardImage         character2Image = new CardImage("https://asistentesura9ad0.blob.core.windows.net/assetsbotsura/suraFondos.jpg");

            image2List.Add(character2Image);
            myCard2.Images = image2List;

            CardAction moreInformationButton2 = new CardAction();

            moreInformationButton2.Title = "Preguntas de Fondos de inversión";
            moreInformationButton2.Type  = ActionTypes.ImBack;
            moreInformationButton2.Value = "fondos";
            buttons2List.Add(moreInformationButton2);
            myCard2.Buttons = buttons2List;

            HeroCard myCard3 = new HeroCard
            {
                Title    = "Pensiones",
                Subtitle = "Conoce todo lo que necesites acerca de tu plan de pensión y todos los detalles relacionados"
            };

            List <CardImage>  image3List      = new List <CardImage>();
            List <CardAction> buttons3List    = new List <CardAction>();
            CardImage         character3Image = new CardImage("https://asistentesura9ad0.blob.core.windows.net/assetsbotsura/suraPensiones.png");

            image3List.Add(character3Image);
            myCard3.Images = image3List;

            CardAction moreInformationButton3 = new CardAction();

            moreInformationButton3.Title = "Más información";
            moreInformationButton3.Type  = ActionTypes.ImBack;
            moreInformationButton3.Value = "pensiones";
            buttons3List.Add(moreInformationButton3);
            myCard3.Buttons = buttons3List;

            List <Attachment> listAttachment = new List <Attachment>();

            listAttachment.Add(myCard.ToAttachment());
            listAttachment.Add(myCard2.ToAttachment());
            listAttachment.Add(myCard3.ToAttachment());
            return(listAttachment);
        }