Skip to main content
Inline queries allow users to interact with your bot from any chat by typing @your_bot query in the message input field. This is perfect for creating search bots, content aggregators, and interactive utilities.

Enabling Inline Mode

First, enable inline mode for your bot:
  1. Talk to @BotFather
  2. Send /mybots and select your bot
  3. Go to Bot SettingsInline Mode
  4. Enable inline mode and optionally set a placeholder

Basic Usage

Result Types

grammY supports all Telegram inline result types:

Adding Keyboards

Attach inline keyboards to inline results:

Search Example

Pagination

Handle large result sets with pagination:

Chosen Inline Results

Track which results users actually choose:
You must enable chosen inline result feedback in BotFather for this to work. Send /setinlinefeedback to @BotFather.

Answer Options

Best Practices

Quick Responses

Answer inline queries within 1 second. Cache results when possible.

Limit Results

Return at most 50 results per query. Use pagination for more.

Cache Intelligently

Set appropriate cache_time based on how often your content changes.

Handle Empty Queries

Provide useful default results when the query is empty.

Advanced Example: Image Search Bot

Common Issues

Make sure:
  • Inline mode is enabled in BotFather
  • You’re answering the query within 30 seconds
  • Result IDs are unique
  • Required fields are provided for each result type
Keyboards on inline results only appear when the user sends the result. They don’t show in the inline query list.
  • Cache API responses
  • Use pagination to limit results
  • Consider using answerInlineQuery options to cache results on Telegram’s servers
  • Optimize database queries

See Also