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 location, /setinlinefeedback to get
chosen_inline_result. - Answer each
inline_querywithanswerInlineQuery: up to 50 results of 20 types.next_offsetpages further;buttonleads to your chat (start_parameter) or a Mini App (web_app). - 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 anInlineQueryResultGame. - A Play tap brings a
callback_querywithgame_short_name; callanswerCallbackQuerywith the game'surlfor this player. - Post scores with
setGameScore;getGameHighScoresreturns the player, two neighbors on each side and the top three.
Watch out
queryis up to 256 characters,next_offsetup to 64 bytes. Results are cached 300 seconds by default and shared with anyone sending the same query unlessis_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 gameurlworks only from it. - Games can't be sent to channels.
setGameScorefails if the score isn't higher, unlessforce.
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