Use this method to send answers to an inline query

POST /answerInlineQuery

Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.

Body Required

  • inline_query_id string Required

    Unique identifier for the answered query

  • results array[object] Required

    Any of:
  • cache_time integer

    The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.

    Default value is 300.

  • is_personal boolean

    Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query

  • next_offset string

    Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.

  • switch_pm_text string

    If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter

  • switch_pm_parameter string

    Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.

    Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.

Responses

  • default
    Hide response attributes Show response attributes object
    • ok boolean Required

      Default value is false.

    • error_code integer Required
    • description string Required
    • parameters object

      Contains information about why a request was unsuccessful.

      Hide parameters attributes Show parameters attributes object
      • migrate_to_chat_id integer

        Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.

      • retry_after integer

        Optional. In case of exceeding flood control, the number of seconds left to wait before the request can be repeated

  • 200
    Hide response attributes Show response attributes object
    • ok boolean Required

      Default value is true.

    • result boolean Required

      Default value is true.

POST /answerInlineQuery
curl \
 -X POST https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/answerInlineQuery \
 -H "Content-Type: application/json" \
 -d '{"inline_query_id":"string","results":[{"type":"string","id":"string","audio_file_id":"string","caption":"string","parse_mode":"string","caption_entities":[{"type":"mention","offset":42,"length":42,"url":"string","user":{"id":42,"is_bot":true,"first_name":"string","last_name":"string","username":"string","language_code":"string","can_join_groups":true,"can_read_all_group_messages":true,"supports_inline_queries":true},"language":"string"}],"reply_markup":{"":[[{}]]},"input_message_content":{"message_text":"string","parse_mode":"string","entities":[{"type":"mention","offset":42,"length":42,"url":"string","user":{"id":42,"is_bot":true,"first_name":"string","last_name":"string","username":"string","language_code":"string","can_join_groups":true,"can_read_all_group_messages":true,"supports_inline_queries":true},"language":"string"}],"disable_web_page_preview":true}}],"cache_time":300,"is_personal":true,"next_offset":"string","switch_pm_text":"string","switch_pm_parameter":"string"}'
Request example
{
  "inline_query_id": "string",
  "results": [
    {
      "type": "string",
      "id": "string",
      "audio_file_id": "string",
      "caption": "string",
      "parse_mode": "string",
      "caption_entities": [
        {
          "type": "mention",
          "offset": 42,
          "length": 42,
          "url": "string",
          "user": {
            "id": 42,
            "is_bot": true,
            "first_name": "string",
            "last_name": "string",
            "username": "string",
            "language_code": "string",
            "can_join_groups": true,
            "can_read_all_group_messages": true,
            "supports_inline_queries": true
          },
          "language": "string"
        }
      ],
      "reply_markup": {
        "": [
          [
            {}
          ]
        ]
      },
      "input_message_content": {
        "message_text": "string",
        "parse_mode": "string",
        "entities": [
          {
            "type": "mention",
            "offset": 42,
            "length": 42,
            "url": "string",
            "user": {
              "id": 42,
              "is_bot": true,
              "first_name": "string",
              "last_name": "string",
              "username": "string",
              "language_code": "string",
              "can_join_groups": true,
              "can_read_all_group_messages": true,
              "supports_inline_queries": true
            },
            "language": "string"
          }
        ],
        "disable_web_page_preview": true
      }
    }
  ],
  "cache_time": 300,
  "is_personal": true,
  "next_offset": "string",
  "switch_pm_text": "string",
  "switch_pm_parameter": "string"
}
Request examples
{
  "inline_query_id": "string",
  "results": [
    {
      "type": "string",
      "id": "string",
      "audio_file_id": "string",
      "caption": "string",
      "parse_mode": "string",
      "caption_entities": [
        {
          "type": "mention",
          "offset": 42,
          "length": 42,
          "url": "string",
          "user": {
            "id": 42,
            "is_bot": true,
            "first_name": "string",
            "last_name": "string",
            "username": "string",
            "language_code": "string",
            "can_join_groups": true,
            "can_read_all_group_messages": true,
            "supports_inline_queries": true
          },
          "language": "string"
        }
      ],
      "reply_markup": {
        "": [
          [
            {}
          ]
        ]
      },
      "input_message_content": {
        "message_text": "string",
        "parse_mode": "string",
        "entities": [
          {
            "type": "mention",
            "offset": 42,
            "length": 42,
            "url": "string",
            "user": {
              "id": 42,
              "is_bot": true,
              "first_name": "string",
              "last_name": "string",
              "username": "string",
              "language_code": "string",
              "can_join_groups": true,
              "can_read_all_group_messages": true,
              "supports_inline_queries": true
            },
            "language": "string"
          }
        ],
        "disable_web_page_preview": true
      }
    }
  ],
  "cache_time": 300,
  "is_personal": true,
  "next_offset": "string",
  "switch_pm_text": "string",
  "switch_pm_parameter": "string"
}
Response examples (default)
{
  "ok": false,
  "error_code": 42,
  "description": "string",
  "parameters": {
    "migrate_to_chat_id": 42,
    "retry_after": 42
  }
}
Response examples (default)
{
  "ok": false,
  "error_code": 42,
  "description": "string",
  "parameters": {
    "migrate_to_chat_id": 42,
    "retry_after": 42
  }
}
Response examples (200)
{
  "ok": true,
  "result": true
}
Response examples (200)
{
  "ok": true,
  "result": true
}