What is the correct way to render options list as buttons in choice prompt?

限于喜欢 提交于 2020-01-24 21:33:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!