I am trying to align my Actions vertically in my Adaptive card. So the buttons would be one on top of the other. Here is my code:
var card = new AdaptiveCard("1.0") { Height = AdaptiveHeight.Auto };
var body = new List<AdaptiveElement>();
var actionSet = new AdaptiveActionSet() { Type = AdaptiveActionSet.TypeName, Separator = true};
var title = new AdaptiveTextBlock()
{
Text = ConfusedStrings.TITLE,
Size = AdaptiveTextSize.Medium
};
body.Add(title);
body.Add(actionSet);
card.Body = body;
foreach(var intent in intentCurrentList)
{
actionSet.Actions.Add(new AdaptiveSubmitAction()
{
Title = intent.Value.ToString(),
Data = intent.Value.ToString()
});
}
var attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card,
};
return MessageFactory.Attachment(attachment, inputHint: InputHints.AcceptingInput);
UPDATE:
Adaptive Cards 1.2 are available to Teams now. The AdaptiveSubmitAction with a string doesn't work when you put a value in. You have to pass it the complete Json Object like in this doc using the ImBack type to https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions#adaptive-cards-with-imback-action :
public static IMessageActivity BuildIntentSelectionCardJustin(ITurnContext turnContext, dynamic data)
{
var intentRefList = GetIntentRefList();
var intentCurrentList = intentRefList.Where(kv => ((IList<DispatchLuis.Intent>)data).Any(di => di.ToString().Equals(kv.Key)) || (kv.Key == Intent.None.ToString()));
var adaptiveCard = new AdaptiveCard("1.2");
var body = new List<AdaptiveElement>();
foreach (var intent in intentCurrentList)
{
var actionSet = new AdaptiveActionSet();
dynamic dataObject = new JObject();
dataObject.msteams = new JObject();
dataObject.msteams.type = "imBack";
dataObject.msteams.value = intent.Value;
var actionSubmit = new AdaptiveSubmitAction()
{
Title = intent.Value,
Data = turnContext.Activity.ChannelId != "emulator" ? dataObject : intent.Value
};
actionSet.Actions.Add(actionSubmit);
body.Add(actionSet);
}
adaptiveCard.Body = body;
var attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = adaptiveCard,
};
return MessageFactory.Attachment(attachment, inputHint: InputHints.AcceptingInput);
}