Creating interactive buttons for Telegram bot interface

I’m working on building custom buttons for my Telegram bot but running into some issues. I want to create different types of buttons where some can request user contact info and others should open external websites.

Here’s my current code setup:

import json

button_config = json.dumps({
    "keyboard": [[
        {'text': 'Share Contact', 'request_contact': True},
        {'text': 'Visit Site', 'url': 'https://example.com'}
    ]]
})

The contact request button works perfectly fine, but the second button just shows as plain text instead of being clickable. What am I missing here? Any help would be great!

You’re mixing two different button types in one keyboard. The url parameter only works with inline keyboards, not regular reply keyboards.

You need inline keyboards for URL buttons:

import json

# Inline keyboard with URL button
inline_config = json.dumps({
    "inline_keyboard": [[
        {'text': 'Visit Site', 'url': 'https://example.com'}
    ]]
})

# Contact button goes in reply keyboard
contact_config = json.dumps({
    "keyboard": [[
        {'text': 'Share Contact', 'request_contact': True}
    ]]
})

Send these as separate messages or pick one keyboard type.

Honestly, managing different keyboard types and API calls gets messy fast. I’ve been using Latenode for Telegram bot automation - it handles all this button complexity automatically. Just drag and drop different button types without worrying about API differences.

Connects directly to Telegram’s API and lets you build complex bot flows visually. Way easier than debugging JSON configurations.

yeah, super common mistake. telegram’s api is weird about this - url buttons only work in inline keyboards, not regular ones. most people either send two separate messages or just redesign the whole flow to avoid mixing button types.

This happens because Telegram’s keyboard system has limitations. You can’t mix reply keyboards and inline keyboards in the same message - they’re built for different things. Your contact button needs a reply keyboard (since request_contact only works there), but URL buttons only work with inline keyboards. I usually send the contact request keyboard first, then follow up with an inline keyboard for the URL button after the user responds. You could also redesign your bot to use callback data with inline keyboards and handle contact sharing differently, but that means writing more backend code to process the contact info.

You’re mixing incompatible button types - Telegram doesn’t allow combining reply keyboards with inline keyboards in the same structure. Two ways to resolve this issue:

First, you could start with the reply keyboard to collect contact info and then switch to inline keyboards afterward, ensuring a smooth flow. Alternatively, consider using inline keyboards exclusively, which would involve ditching the contact request feature. This approach gives you more control but requires additional backend work for custom contact collection. Overall, it’s essential to design your conversation flow within the constraints of Telegram’s keyboard system.