@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:- Talk to @BotFather
- Send
/mybotsand select your bot - Go to Bot Settings → Inline Mode
- Enable inline mode and optionally set a placeholder
Basic Usage
Result Types
grammY supports all Telegram inline result types:- Article
- Photo
- Video
- GIF
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
Results not showing
Results not showing
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
Keyboard not appearing
Keyboard not appearing
Keyboards on inline results only appear when the user sends the result. They don’t show in the inline query list.
Slow response time
Slow response time
- Cache API responses
- Use pagination to limit results
- Consider using
answerInlineQueryoptions to cache results on Telegram’s servers - Optimize database queries