TSocial TSocial
Open in Telegram
Better in TelegramOpen in Telegram

Telegram Inline Bots Explained: Results in Any Chat

· 4 min read · 18+ readers

Telegram Inline Bots Explained: Results in Any Chat: TSocial guide cover card

An inline bot icon bot works from the message box of any chat. A user types the bot's username followed by a query, such as @yourbot summer, and a list of results pops up. Tapping one sends it into the chat. Inline mode is how people share link icon links, files, quotes and cards without leaving a conversation. This guide explains how to turn it on and answer queries. Verify field names against the Bot code icon API reference.

When inline mode is useful

  • Sharing your links or latest post into any chat with one tap.
  • Search: products, articles, creators, GIFs, sounds.
  • Quick cards that carry a button to open your bot or Mini App icon (grid) Mini App.
  • Letting fans recommend you to friends without copying a URL.
Mock BotFather /mybots screen with a bot list and buttons for API Token, Edit Bot, Bot Settings, Payments and Transfer Ownership
/mybots opens a button menu for each bot. Labels can change over time. Generic illustration, not a real chat or user data.

Step 1: Turn it on

In BotFather send /setinline, choose the bot and send a short placeholder, for example Search guides. This text shows in the message box when the user starts typing the username. Without it, Telegram will not send you inline queries.

Optionally use /setinlinefeedback to receive chosen_inline_result updates telling you which result was selected. This is useful for statistics.

Step 2: Receive the query

You get an inline_query update:

{
  "update_id": 200,
  "inline_query": {
    "id": "4321",
    "from": { "id": 777, "first_name": "Sam" },
    "query": "summer",
    "offset": ""
  }
}

The query may be empty when the user has just typed the bot name. Decide whether to show defaults or nothing.

Step 3: Answer within a few seconds

Call answerInlineQuery with the query id and an array of results:

{
  "inline_query_id": "4321",
  "cache_time": 60,
  "results": [
    {
      "type": "article",
      "id": "guide-1",
      "title": "Telegram Stars guide",
      "description": "How creators use Stars",
      "input_message_content": { "message_text": "Telegram Stars guide: https://tsocial.me/guides/telegram-stars-explained" },
      "reply_markup": { "inline_keyboard": [[ { "text": "Read", "url": "https://tsocial.me/guides/telegram-stars-explained" } ]] }
    }
  ]
}
  • id must be unique within the answer and up to 64 bytes.
  • cache_time is how long Telegram may reuse the answer, in seconds. Use a larger value for stable content.
  • is_personal tells Telegram the results depend on the user, so it will not share the cache between users.
  • Telegram limits the number of results per answer, and supports paging with next_offset. Check the documentation for the number.

Result types

Besides article, there are types for photos, GIFs, videos, audio, documents, locations, contacts, venues and stickers. Each has a URL form and a cached form that uses a file_id. Pick the type that matches what you want to send, and check that the URLs are public and reachable by Telegram.

Switching to private chat

You can set button in answerInlineQuery with start_parameter, which shows a button at the top of the result list that takes the user to a private chat with the bot. This is helpful when the user must log in or finish a step before results can appear. See deep links and start parameters.

Performance tips

  • Answer quickly. Slow answers show a spinner and may time out.
  • Cache what you can.
  • Keep titles short and descriptions informative.
  • Do not run heavy searches on every keystroke. Debounce with caching.

Rules and etiquette

  • Do not send spam into chats through inline results.
  • Make results honest and relevant.
  • Respect safety icon privacy. Inline queries show what the user typed, so treat it as personal data.
  • If your results include adult-oriented content, check Telegram's terms. Keep public results safe for work.

A tiny search bot

async function onInline(q) {
  const found = GUIDES.filter((g) => g.title.toLowerCase().includes(q.query.toLowerCase())).slice(0, 10);
  await api("answerInlineQuery", {
    inline_query_id: q.id, cache_time: 300,
    results: found.map((g) => ({
      type: "article", id: g.slug, title: g.title, description: g.description,
      input_message_content: { message_text: `${g.title}\n${g.url}` },
    })),
  });
}

Quick checklist

  • Inline mode enabled with a placeholder in BotFather.
  • inline_query is included in allowed_updates.
  • Answers return within a few seconds.
  • Each result has a unique id under 64 bytes.
  • cache_time is set sensibly.
  • Results are honest, relevant and safe for work.
  • Queries are treated as personal data.
  • Chosen result feedback is enabled only if you use it.

Where inline mode shines

Inline mode works best when the result is something people already want to paste into a chat: a link, a short card, a reference. If you find yourself building a long conversation inside inline results, move that experience into a private chat with buttons and use inline mode only to hand people over.

Frequently asked questions

Can inline bots work in groups?

Yes, anyone can use inline mode in any chat, and the bot does not need to be a member.

Do I need a webhook?

Inline queries arrive like other updates, by polling or webhook.

Why do I get no queries?

Inline mode is off in BotFather, or allowed_updates excludes inline_query.

Can inline results open a Mini App?

Results can carry buttons, and some result features link to Mini Apps. See the Mini Apps documentation for current options.

Related guides

More in Build on Telegram

All topics: Build on Telegram · Guide index · Explore Telegram · About TSocial

Telegram Inline Bots Explained: Results in Any Chat | TSocial