有没有办法使建议的操作成为Botframework v4上的编号列表?

时间:2019-04-14 04:34:39

标签: c# botframework

我有显示按钮的建议操作。有没有办法使它像编号列表一样?然后用户只需要输入数字?

return await stepContext.PromptAsync(TextPromptId, new PromptOptions
{
    Prompt = new Activity
    {
        Type = ActivityTypes.Message,
        Text = $"Choose a question or type your own question.",
        SuggestedActions = new SuggestedActions()
        {                             
            Actions = new List<CardAction>()
            {
                new CardAction() { Title = "This is Sample Question 1", Type = ActionTypes.ImBack, Value = "This is Sample Question 1" },
                new CardAction() { Title = "This is Sample Question 2", Type = ActionTypes.ImBack, Value = "This is Sample Question 2" },
                new CardAction() { Title = "This is Sample Question 3", Type = ActionTypes.ImBack, Value = "This is Sample Question 3" },
        },
    },
});

1 个答案:

答案 0 :(得分:1)

我建议使用选择提示,并将ListStyle中的promptOptions设置为ListStyle.List

屏幕截图

enter image description here

代码段-C#SDK v4.5.0

private static async Task<DialogTurnResult> TransportStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
    // WaterfallStep always finishes with the end of the Waterfall or with another dialog; here it is a Prompt Dialog.
    // Running a prompt here means the next WaterfallStep will be run when the users response is received.
    return await stepContext.PromptAsync(nameof(ChoicePrompt),
        new PromptOptions
        {
            Prompt = MessageFactory.Text("Please enter your mode of transport."),
            Choices = ChoiceFactory.ToChoices(new List<string> { "Car", "Bus", "Bicycle" }),
            Style = ListStyle.List
        }, cancellationToken);
}

希望这会有所帮助!