In-Message (Inline Text) Buttons

Telegram Bot API 10.3 introduced In-Message Buttons — styled buttons embedded directly inside the rich message card body, not below it.

FTMGram provides two ways to use them:

  1. RichMessageBuilder — easy fluent API (recommended)

  2. Raw HTML — full manual control

See also

For the full guide including stream_text, thinking, send_rich_message parameters, and real-world examples, see Rich Messages & Inline Buttons.

Quick Example — RichMessageBuilder

from ftmgram import Client
from ftmgram.helpers import RichMessageBuilder, Button

app = Client("my_bot", bot_token="TOKEN")

async def main():
    async with app:
        rich = (
            RichMessageBuilder()
            .title("🎯 Select Your Plan")
            .button_row(
                Button("Basic \$5", data="plan_basic", style="primary"),
                Button("Pro \$10", data="plan_pro", style="success"),
                Button("VIP \$25", data="plan_vip", style="danger"),
            )
            .build()
        )
        await app.send_rich_message(chat_id, rich)

app.run(main())

Button Styles

Style

Color

"primary"

Blue (default)

"secondary"

Grey

"success"

Green

"danger"

Red

Quick Example — Raw HTML

from ftmgram import Client
from ftmgram.types import InputRichMessage

app = Client("my_bot", bot_token="TOKEN")

async def main():
    async with app:
        html = """
        <b>Select your plan:</b>
        <tg-button-row align="center">
          <tg-button type="callback_data" style="primary" data="plan_basic">Basic ($5)</tg-button>
          <tg-button type="callback_data" style="success" data="plan_pro">Pro ($10)</tg-button>
          <tg-button type="callback_data" style="danger" data="plan_vip">VIP ($25)</tg-button>
        </tg-button-row>
        """
        await app.send_rich_message(123456789, InputRichMessage(html=html.strip()))

app.run(main())

Handling Button Callbacks

@app.on_callback_query(filters.regex(r"plan_(.+)"))
async def on_plan(client, callback_query):
    plan = callback_query.matches[0].group(1)
    await callback_query.answer(f"You selected: {plan.upper()}!", show_alert=True)

See also

Full documentation with all parameters, stream_text, thinking, InputRichMessage HTML tags reference → Rich Messages & Inline Buttons