I’m working on a Python Telegram bot and running into issues with the inline keyboard layout. When users click on a category button, I need to show them about 185 different choices to pick from using a custom keyboard.
The problem is that when I create a regular ReplyKeyboardMarkup with all these options, the buttons get really small and the text gets cut off. I tried using resize_keyboard=True but it doesn’t help much. With fewer buttons like “Movies” and “Music” everything looks fine, but with 185 buttons the text becomes unreadable like “Mo” and “Mu”.
Is there a way to create a scrollable menu or some kind of dropdown list in Telegram bots? I need users to be able to browse through all 185 options without the interface becoming messy. What’s the best approach for handling this many choices in a Telegram bot keyboard?
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['categories'])
def show_categories(msg):
options = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True)
# This creates too many buttons and looks terrible
for item in all_categories: # 185 items
options.add(telebot.types.KeyboardButton(item))
bot.send_message(msg.chat.id, "Pick a category:", reply_markup=options)
same problem here. split it into pages - 15-20 items each with inline buttons works great. use callback_data for next/prev buttons. you could also make categories searchable where users type the first few letters and get matching results. way better than making people scroll through 185 options.
Had the same issue building a restaurant bot with a huge menu. Here’s what actually worked: I set up a two-tier system with broad categories first (like ‘Food A-F’, ‘Food G-M’), then used inline keyboards with pagination inside each group. But here’s the thing - most users aren’t browsing randomly. They know what they want. So I added a /find command where they just type keywords. Someone types ‘/find pasta’ and boom - only pasta options show up as buttons. Cut down user frustration massively and people actually engaged more since they weren’t clicking through endless menus.
Telegram caps ReplyKeyboardMarkup at 100 buttons and InlineKeyboardMarkup at 8 buttons per row. Your 185 options blow past these limits, which explains the display problems. I’d go with pagination - break your categories into chunks of 20-30 items using InlineKeyboardMarkup. Add ‘Next’ and ‘Previous’ buttons and track each user’s current page with a dictionary or database. You could also add a search feature where users type part of the category name to filter results. Or try a hierarchical menu - group everything into 8-10 main sections with subcategories underneath. Makes it way less overwhelming for users.