Posted on Leave a comment

Display Herocard in BotFramework

As the botframework evovles, many things are changing in the apis. I wanted to create a Herocard for a bot and the previously existed method wasn’t working, so i find the new way that one can reply herocards in the user. The main function needed is the

context.MakeMessage()

 

Full C# example

 List <CardAction> list = new List<CardAction>();
            list.Add(new CardAction {Title="help", Type=ActionTypes.ImBack, Value="help" });
            list.Add(new CardAction {Title = "commands", Type = ActionTypes.ImBack, Value = "commands" });
            HeroCard hero = new HeroCard();
            hero.Title = "Hero title";
            hero.Text = "Hero text";
            hero.Buttons = list;

            var msg = context.MakeMessage();
            msg.Attachments.Add(hero.ToAttachment());
            await context.PostAsync(msg);

 

The result will look like that

 

This github repo is very useful as it includes many botframework samples.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.