How to create inline keyboard buttons in Telegram bot using JSON

I’m working on a Telegram bot and need help with creating inline keyboard buttons. I want to display custom buttons that users can click to interact with my bot. Can someone show me the proper JSON structure for implementing inline keyboards? I’ve been trying to figure out the correct format but keep running into issues. Here’s what I’m attempting to use:

{
    "chat_id": "987654321",
    "text": "Please choose an option:",
    "reply_markup": {
        "inline_keyboard": [[
            {
                "text": "Option 1",
                "callback_data": "btn_option1"
            },
            {
                "text": "Option 2", 
                "callback_data": "btn_option2"
            }
        ]]
    }
}

Is this the right approach for adding clickable buttons to my bot messages?

looks good, but you’ll need to handle callback queries when users click those buttons. Set up a webhook or polling to catch the callback_data. if you’re using python-telegram-bot library, the syntax is different - use InlineKeyboardMarkup and InlineKeyboardButton objects instead of raw JSON. heads up in case your code doesn’t work as expected.

Your JSON looks right. The main gotcha is making sure chat_id is formatted correctly - string or integer depending on what you’re using. That double array structure [] is key - outer array = rows, inner arrays = button columns. I kept screwing this up when I started. Watch out for the 64-byte limit on callback_data - keep those values short. Send it to sendMessage with Content-Type: application/json header. One thing that got me: group chat IDs are negative numbers. Test with a DM first to make sure the buttons actually render.

Your structure looks right for the Telegram Bot API. I hit the same issues when I started with inline keyboards - turns out I wasn’t using POST properly. Send that JSON to /bot<token>/sendMessage with a POST request. The button layout caught me too. Each inner array makes a row, so buttons in the same array sit side by side. Want them stacked? Split them like [[button1], [button2]]. Also check your bot token has message permissions for that chat - inline keyboards won’t show without them.