Build inline results and games
What it is
Inline mode lets people type `@your_bot` and a query in any chat and send one of your results. Games are HTML5 pages your bot sends as a message with a Play button and the chat's high scores.
How to do it
- In @BotFather: /setinline with a placeholder, /setinlinegeo to ask for… In @BotFather: /setinline with a placeholder, /setinlinegeo to ask for location, /setinlinefeedback to get `chosen_inline_result`.
- Answer each `inline_query` with `answerInlineQuery`: up to 50 results of 20… Answer each `inline_query` with `answerInlineQuery`: up to 50 results of 20 types. `next_offset` pages further; `button` leads to your chat (`start_parameter`) or a Mini App (`web_app`).
- Games: /newgame in @BotFather with a description, an image and an optional GIF;… Games: /newgame in @BotFather with a description, an image and an optional GIF; accept the terms and set up the game's short name.
- Send the game with `sendGame` (`game_short_name`) or as an `InlineQueryResultGame`.
- A Play tap brings a `callback_query` with `game_short_name`; call… A Play tap brings a `callback_query` with `game_short_name`; call `answerCallbackQuery` with the game's `url` for this player.
- Post scores with `setGameScore`; `getGameHighScores` returns the player, two neighbors on each side and the top three.
Watch out
- `query` is up to 256 characters, `next_offset` up to 64 bytes. Results are cached 300 seconds by default and shared with anyone sending the same query unless `is_personal`.
- Feedback can flood a popular bot: Telegram suggests taking 1/10, 1/100 or 1/1000 of chosen results.
- The first button in the first row must launch the game (`callback_game`); the game `url` works only from it.
- Games can't be sent to channels.
- `setGameScore` fails if the score isn't higher, unless `force`.
With Gem
Gem doesn't build inline results or Bot API games for your bot. Nearby: /newapp in @gembot builds a small Mini App from your description, with its own link `t.me/gembot?startapp=<slug>`, storage, leaderboards and multiplayer rooms.
Sources
- https://core.telegram.org/bots/api#inline-mode
- https://core.telegram.org/bots/inline
- https://core.telegram.org/bots/api#games
- https://core.telegram.org/bots/features#html5-games