Hello friends! Today we want to talk about the Telegram bot API and the interesting feature of InlineQuery. This feature allows users to easily receive information as inline suggestions directly from the bot. For instance, if a user searches for something, the bot can provide results instantly without requiring the user to send a new message.
InlineQuery is actually a type of interaction that occurs between a user and the bot through the search system in Telegram. Users can start the search by typing @bot_name in their chat, which immediately begins the query. Then, the bot can present results in list form, including texts, images, or any other type of content that the bot is capable of providing.
To implement this feature, you need an API Key and use HTTP methods to connect with the Telegram server. This method is crucial for interacting with users and delivering information promptly. Therefore, if you want to become familiar with the capabilities of the Telegram bot, be sure to read this article thoroughly.
Here, we aim to present sample codes that demonstrate the process of utilizing InlineQuery. By using various programming languages, you can easily interact with Telegram and leverage this special feature effectively.
Sample code using InlineQuery API
{
"inline_query_id": "some_unique_id",
"results": [
{
"type": "article",
"id": "1",
"title": "First Result",
"input_message_content": {
"message_text": "This is the first result!"
}
},
{
"type": "article",
"id": "2",
"title": "Second Result",
"input_message_content": {
"message_text": "This is the second result!"
}
}
]
}
Code Description
inline_query_id
: This field is a unique identifier used to identify requests for InlineQuery.results
: In this field, there is a list of defined search results that must be displayed to the user.type
: Specifies the type of result, which here is an "article".id
: Unique identifier for each result in the list.title
: The title of the message or result observed by the user later.input_message_content
: The content of the message that the user will receive by selecting this result.