I am using the bot framework v4 SDK for webchat. I have used suggested actions for the choice prompt. By default, the suggested actions are aligned horizontally. Is there a way in which that can be made vertical?
I have tried the style options for the choice prompt as hero card and list.B ut in both the cases the choices will remain on the chat window and will not disappear. So the only option I had, was to use suggested actions. I could not find a way to make the suggested actions to appear vertically.
PromptOptions choicePromptOptions = new PromptOptions
{
Choices = choices,
Prompt = MessageFactory.Text("Please choose :"),
RetryPrompt = null,
Style = ListStyle.SuggestedAction
};
Is there any other way to make the choices disappear other than suggested actions ?
Unfortunately, this is not possible with suggested actions. Suggested actions, by design, are meant to consume as little real estate as possible due to their temporary existence. Hence, the horizontal display.
If you are wanting a horizontal display, then I would suggest you use a hero card. However, it will remain part of the web chat transcript and not disappear once a selection or other activity occurs.
Here is sample code borrowed from the referenced doc:
private static async Task DisplayOptionsAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
var card = new HeroCard
{
Text = "You can upload an image or select one of the following choices",
Buttons = new List<CardAction>
{
new CardAction(ActionTypes.ImBack, title: "1. Green", value: "1"),
new CardAction(ActionTypes.ImBack, title: "2. Blue", value: "2"),
new CardAction(ActionTypes.ImBack, title: "3. Red", value: "3"),
},
};
var reply = MessageFactory.Attachment(card.ToAttachment());
await turnContext.SendActivityAsync(reply, cancellationToken);
}