<metaproperty="description"content="Bots can offer their users HTML5 games to play solo or to compete against each other in groups and one-on-one chats. Games…">
<metaproperty="og:description"content="Bots can offer their users HTML5 games to play solo or to compete against each other in groups and one-on-one chats. Games…">
<p>Bots can offer their users <strong>HTML5 games</strong> to play solo or to compete against each other in groups and one-on-one chats. Games are a new type of content on Telegram that your bot can send to users.</p>
<ahref="/file/811140035/2/cIULSr61vi4.78261/127282e0bbd66ce3a9"target="_blank"><imgsrc="/file/811140035/2/cIULSr61vi4.78261/127282e0bbd66ce3a9"title="Game in a chat"style="width: 295px; padding: 10px 10px;"></a></center><br>
<p>This introduction is meant for <strong>bot developers</strong>. <ahref="https://telegram.org/blog/games"><strong>Click here</strong></a>, in case you'd like something more user-friendly.
Check out the <ahref="https://telegram.me/gamebot"><strong>@gamebot</strong></a> and <ahref="https://telegram.me/gamee"><strong>@gamee</strong></a> bots for examples of what you can do using the new Gaming Platform.</p>
<p>To get started, send the <code>/newgame</code> command to <ahref="https://telegram.me/botfather">@BotFather</a>.You will be prompted for a description text and a photo. You can also upload an optional GIF animation that demostrates your game to the users to make messages with the game more attractive (check out <ahref="https://telegram.me/gamebot?game=Lumberjack">Lumberjack</a> or <ahref="https://telegram.me/gamebot?game=Corsairs">Corsairs</a> for examples).</p>
<p>Once the game is created, your bot can send it to chats as regular messages, or offer them via <ahref="/bots/inline">inline mode</a>. The game message will always have an <ahref="/bots/api#inlinekeyboardmarkup">inline</a><strong>Play button</strong>.</p>
<p>When this button is pressed, your bot gets a callback query that indicates the requested game. You provide the correct URL for this particular user and the app automatically opens the game in the in-app browser.</p>
<p>If you send the game message without any buttons, it will automatically have a 'Play <em>GameName</em>' button. You can manually add multiple buttons to your game message. Please note that the first button in the first row <strong>must always</strong> be the one that launches the game. You can add more buttons: e.g., for a description of the rules, or a button that links to the game's official community.</p>
<h3><aclass="anchor"href="#tracking-high-scores"id="tracking-high-scores"name="tracking-high-scores"><iclass="anchor-icon"></i></a>Tracking High Scores</h3>
<p>The message with your game will also display high scores for the current chat. When a new high score is set, a service message will be sent to the chat and the message with the current scoreboard will be updated. You can also request the necessary data for building in-game high score tables.</p>
<ahref="/file/811140022/1/m7-46hgmwbI.91190/ad7033bcb879270a69"target="_blank"><imgsrc="/file/811140022/1/m7-46hgmwbI.91190/ad7033bcb879270a69"title="In-game high scores for Lumberjack"style="width: 295px; padding: 0px 20px;"></a>
<ahref="/file/811140594/2/WS2fB3n2UGA.149087/270057ff677339717e"target="_blank"><imgsrc="/file/811140594/2/WS2fB3n2UGA.149087/270057ff677339717e"title="Message with the score in the chat"style="width: 295px; padding: 0px 20px;"></a><br><br>
<p><br><br></p></center></div>
<h3><aclass="anchor"href="#sharing-your-game-to-telegram-chats"id="sharing-your-game-to-telegram-chats"name="sharing-your-game-to-telegram-chats"><iclass="anchor-icon"></i></a>Sharing Your Game to Telegram Chats</h3>
<p>There are many way for users to spread your game virally if they like it. The interface will always have the standard system button for sharing the game in the top right corner:</p>
<p>You can also create an additional <strong>Share</strong> button inside your HTML page. Pressing this button will send the game to a desired chat along with the user's best score in the game.</p>
<p><ahref="/file/811140978/1/JoBvEad8JaM.148942/dcd741b65b446781b4"target="_blank"><imgsrc="/file/811140978/1/JoBvEad8JaM.148942/dcd741b65b446781b4"title="Shared game with 'just scored'"style="width: 295px; padding: 15px 20px;"></a></p>
<p>To add the sharing button, include <ahref="https://telegram.org/js/games.js">this script</a> at the end of the <code><body></code> tag on your page:</p>
<p>If your URL is using a fragment identifier, please note that Telegram Apps could add certain service parameters to the fragment id. The names for such parameters will start in <code>tg</code> (you can check the code that adds them <ahref="https://github.com/TelegramMessenger/GamingCommunication/blob/master/games.js#L54">here</a>). Use the <code>TelegramGameProxy.initParams</code> object if you need to read your own parameters from the fragment id.</p>
<h3><aclass="anchor"href="#creating-a-great-html5-experience"id="creating-a-great-html5-experience"name="creating-a-great-html5-experience"><iclass="anchor-icon"></i></a>Creating a Great HTML5 Experience</h3>
<p>Please make sure that your HTML5 page is responsive and works well on all Telegram apps and supported platforms. If you find it impossible to support certain conditions or platforms, don't leave your users hanging and at least provide a notification.</p>