Use button for input

APPLIES TO: yesSDK v4 no SDK v3

You can enable your bot to present buttons that the user can tap to provide input. Buttons enhance user experience by enabling the user to answer a question or make a selection with a simple tap of a 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 tapped), buttons that appear within the suggested actions pane will disappear after the user makes a selection. This prevents the user from tapping stale buttons within a conversation and simplifies bot development (since you will not need to account for that scenario).

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:

The source code shown here is based on the suggest actions sample.

private static async Task SendSuggestedActionsAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
    var reply = turnContext.Activity.CreateReply("What is your favorite color?");
    reply.SuggestedActions = new SuggestedActions()
    {
        Actions = new List<CardAction>()
        {
            new CardAction() { Title = "Red", Type = ActionTypes.ImBack, Value = "Red" },
            new CardAction() { Title = "Yellow", Type = ActionTypes.ImBack, Value = "Yellow" },
            new CardAction() { Title = "Blue", Type = ActionTypes.ImBack, Value = "Blue" },
        },
    };
    await turnContext.SendActivityAsync(reply, cancellationToken);
}

Additional resources

You can access the complete source code shown here: the CSharp sample or JavaScript sample.

Next steps