Example #1
0
        private Task HandleSystemMessage(ITurnContext context)
        {
            var activity = context.Activity;

            switch (activity.Type)
            {
            case ActivityTypes.ConversationUpdate:
                if (activity.IsFirstTime())
                {
                    context.SendActivities(new[] {
                        MessageFactory.Attachment(new HeroCard()
                        {
                            Title  = $"Welcome {activity.MembersAdded.FirstOrDefault()?.Name}!",
                            Images = new List <CardImage>()
                            {
                                new CardImage()
                                {
                                    Alt = "eShop Logo", Url = $"{host}/images/brand.png"
                                }
                            }
                        }.ToAttachment()),
                        MessageFactory.Text("Howdy! - I am eShopAI-Bot."),
                        MessageFactory.Text("I can show you the eShopAI Catalog, add items to your shopping cart, place a new order and explore your order's status."),
                        MessageFactory.Text("Just type whatever you want to do, for example: *show me the product catalog*")
                    }
                                           );
                }
                break;

            default:
                break;
            }

            return(Task.CompletedTask);
        }
        public static async Task ReplyWithGreeting(ITurnContext context)
        {
            Activity replyToConversation = MessageFactory.Carousel(new List <Attachment>()) as Activity;

            replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;

            List <CardImage> cardImages = new List <CardImage>
            {
                new CardImage(url: "http://4.bp.blogspot.com/_-jGkZ83iwuQ/S9TcnNcdoyI/AAAAAAAAAcw/COgFyJoV3e8/S180/Main+Menu+Icon.jpg")
            };

            List <CardAction> cardButtons = new List <CardAction>();

            CardAction sendGameButton = new CardAction()
            {
                Value = $"games",
                Type  = "imBack",
                Title = "Shall we play a Game?"
            };

            CardAction canelGrannyButton = new CardAction()
            {
                Value = $"granny",
                Type  = "imBack",
                Title = "Granny Bot"
            };

            cardButtons.Add(sendGameButton);
            cardButtons.Add(canelGrannyButton);

            HeroCard plCard = new HeroCard()
            {
                Title   = "Please Select an Item",
                Images  = cardImages,
                Buttons = cardButtons,
            };
            Attachment plAttachment = plCard.ToAttachment();

            replyToConversation.Attachments.Add(plAttachment);

            var activities = new IActivity[] { MessageFactory.Text("Hello, NDC!!! from James!"), replyToConversation };

            await context.SendActivities(activities);
        }
        public static async Task ReplyWithGreeting(ITurnContext context)
        {
            await context.SendActivity($"Welcome to the Games Section");

            await context.SendActivity($"Here is a list of games");

            Activity replyToConversation = MessageFactory.Carousel(new List <Attachment>()) as Activity;

            replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;

            List <CardImage> cardImages = new List <CardImage>
            {
                new CardImage(url: "http://icons.iconarchive.com/icons/mazenl77/I-like-buttons-3a/512/Cute-Ball-Games-icon.png")
            };

            List <CardAction> cardButtons = new List <CardAction>();

            CardAction guessNumberButton = new CardAction()
            {
                Value = $"guessing game",
                Type  = "imBack",
                Title = "Play a Guess a Number game"
            };

            cardButtons.Add(guessNumberButton);

            HeroCard plCard = new HeroCard()
            {
                Title   = "Please Select a Game",
                Images  = cardImages,
                Buttons = cardButtons,
            };
            Attachment plAttachment = plCard.ToAttachment();

            replyToConversation.Attachments.Add(plAttachment);

            var activities = new IActivity[] { MessageFactory.Text("Welcome to the Games Section."), replyToConversation };

            await context.SendActivities(activities);
        }