问题
I am trying to present options to the user to chose from in the form of buttons, like this:
builder.Prompts.choice( session, "Do you want to raise a ticket for this problem?", "Yes|No",
{
maxRetries: 3,
retryPrompt: 'Sorry, that is not a valid input'
},
{
listStyle: builder.ListStyle.button
}
);
However, the web chat channel shows this like so:
Obviously there is something wrong in the way it is done, but I'm not sure what. How do I correctly use choice prompts with buttons ?
回答1:
You need to restructure you prompt options to look like the below example. In your code, you separated the options out into two parameters. The method, as a result, is only seeing your first set of options and is defaulting to a simple list. Make this change and it will render correctly.
builder.Prompts.choice(session, "Do you want to raise a ticket for this problem?", "Yes|No",
{
maxRetries: 3,
retryPrompt: 'Sorry, that is not a valid input',
listStyle: builder.ListStyle.button
}
);
来源:https://stackoverflow.com/questions/53163672/what-is-the-correct-way-to-render-options-list-as-buttons-in-choice-prompt