Bot API: inline mode

SENSEVER

The official Sensever channel: guides and API documentation for Chat, Requests, Flow, Studio, bots and messaging channels.

4 mnt baca

Bot API: inline mode

Inline mode lets people use a bot in any chat, even one the bot is not in. A person types @shop_bot margherita in the input field, sees the bot's results right above the field, picks one — and the message goes to the chat on the person's behalf, marked "via @shop_bot".

Enabling

The bot owner enables inline mode: the "Actions" → "Inline mode" menu, where you set a placeholder the person sees while the bot prepares its answer (for example, "Searching the menu…"). In the owner API: PATCH /v1/chat/bots/{id} with "inline_placeholder": "Searching the menu…" (up to 64 characters); null turns the mode off.

GET /v1/chat/bot/me does not show whether the mode is on; in the Telegram-compatible getMe, this is the supports_inline_queries field.

What the person sees

  1. In the input field of any chat where they can write, the person types @shop_bot and a query (up to 256 characters). The query goes to the bot half a second after the last keystroke.

  2. While the bot is answering, the bot's placeholder is shown above the field. The client waits up to 8 seconds for an answer, then shows "The bot did not answer."

  3. Results are shown as a list: title and description. An empty list shows "Nothing found".

  4. The person picks a result, and its text goes to the chat as the person's message marked "via @shop_bot".

Inline mode is not available in the website widget.

inline_query

The bot receives an inline_query update:

{
  "version": 2,
  "update_id": "64",
  "type": "inline_query",
  "occurred_at": "2026-09-24T18:10:00+00:00",
  "bot_id": "812",
  "inline_query": {
    "id": "5f0e2b1c-3d4a-4b6c-8e9f-0a1b2c3d4e5f",
    "from": {"kind": "user", "ref": "p.1104", "display_name": "Anna", "avatar_url": null},
    "query": "margherita",
    "chat_type": "supergroup"
  }
}

chat_type is where the query was typed: private (direct chat), supergroup (group) or channel. The conversation itself is not disclosed to the bot.

answerInlineQuery

POST /v1/chat/bot/inline-queries/{id}/answer
{
  "results": [
    {
      "type": "article",
      "id": "margherita",
      "title": "Margherita",
      "description": "$12 · 30 cm",
      "input_message_content": {"message_text": "Margherita pizza — <b>$12</b>", "parse_mode": "HTML"}
    }
  ]
}

Parameter

Type

Required

Description

results

Array of InlineQueryResultArticle

Yes

Up to 50 results; an empty list means "nothing found"

cache_time

Integer

No

Accepted for compatibility and ignored: results are not cached

Response: 204 No Content. You can answer once, within 15 minutes, but the person waits no longer than 8 seconds. Errors: 409 inline_query_already_answered_or_expired; 404 not_found — no such query, or it is not for this bot; 422 validation_failed — invalid results.

InlineQueryResultArticle

Field

Type

Required

Description

type

String

No

Only article (default)

id

String

Yes

Result identifier, 1–64 bytes, unique within the answer

title

String

Yes

Title, up to 256 characters

description

String

No

Second line, up to 512 characters

input_message_content

Object

Yes

What to send: message_text (1–4096 characters) and an optional parse_mode

parse_mode is HTML, MarkdownV2 or Markdown, as in Telegram: the markup is converted to Sensever markup when you answer. Without parse_mode, the text is taken as is, and Sensever markup applies (**bold** and others). Telegram underline is dropped: Sensever has no underline.

chosen_inline_result

When the person picks a result, a message from the person with payload.via_bot goes to the chat:

{"via_bot": {"ref": "p.812", "username": "shop_bot"}}

Only the server sets this marker: you cannot send a message with via_bot manually or change the marker by editing.

The bot receives a chosen_inline_result update with the fields result_id, from and query. Unlike Telegram, these updates always arrive, without a separate setting; you can turn them off with allowed_updates.

Differences from Telegram

  • Results are text articles only (article): no photos, videos, thumbnail images or buttons under a result.

  • No pagination (next_offset) and no button to switch to a direct chat with the bot (button, switch_pm_text).

  • The sent message is a regular message from the person: it has no inline_message_id, and the bot cannot edit it later.

  • The bot does not see which conversation the query was typed in and cannot write there unless it is a member.

Komentar

Penulis