Use button for input

APPLIES TO: SDK v4

Buttons enhance the conversational experience by letting the user answer a question or select the desired button, rather than having to type a response with a keyboard. Unlike buttons that appear within rich cards (which remain visible and accessible to the user even after being selected), buttons that appear within the suggested actions pane will disappear after the user makes a selection. This prevents the user from selecting stale buttons within a conversation and simplifies bot development since you won't need to account for that scenario.

Note

The Bot Framework JavaScript, C#, and Python SDKs will continue to be supported, however, the Java SDK is being retired with final long-term support ending in November 2023.

Existing bots built with the Java SDK will continue to function.

For new bot building, consider using Microsoft Copilot Studio and read about choosing the right copilot solution.

For more information, see The future of bot building.

Suggest action using button

Suggested actions enable your bot to present buttons. You can create a list of suggested actions (also known as quick replies) that will be shown to the user for a single turn of the conversation.

Here's an example from the Suggested actions sample.

JavaScript
/**
 * Send suggested actions to the user.
 * @param {TurnContext} turnContext A TurnContext instance containing all the data needed for processing this conversation turn.
 */
async sendSuggestedActions(turnContext) {
    const cardActions = [
        {
            type: ActionTypes.PostBack,
            title: 'Red',
            value: 'Red',
            image: 'https://via.placeholder.com/20/FF0000?text=R',
            imageAltText: 'R'
        },
        {
            type: ActionTypes.PostBack,
            title: 'Yellow',
            value: 'Yellow',
            image: 'https://via.placeholder.com/20/FFFF00?text=Y',
            imageAltText: 'Y'
        },
        {
            type: ActionTypes.PostBack,
            title: 'Blue',
            value: 'Blue',
            image: 'https://via.placeholder.com/20/0000FF?text=B',
            imageAltText: 'B'
        }
    ];

    var reply = MessageFactory.suggestedActions(cardActions, 'What is the best color?');
    await turnContext.sendActivity(reply);
}

Additional resources

You can access the complete source code for the Suggested actions sample in C#, JavaScript, Java and Python.

Next steps