Skip to content
Run your own telegram bot inside the web browser! (just a toy.)
JavaScript CSS HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


telegram-html-bot is a Telegram bot that runs in web browsers. Simply apply a bot TOKEN from @botfather, fill it in the TOKEN box, and click on "Start Polling", then you are all set! Try send something to bot.

When a message is received, the JSON structure of message will be show on the box above. You can play it with your own code. To do this, write your code in the "Write you own code" block, the code should be written in Javascript. After you finish writing your code, click on "Update Code" to make it active.


A Message object named message will be pass to your code, you can see it's structure on the box above, or Telegram bot API document.

Here is a list of methods that are commonly used:

  • setTarget(int target): Set target chat id that message should goes to.
  • setContent(String content): Set the content of message.
  • sendMessage(): Send the message.

And there are some other methods available:

  • setParseMode(String mode): Set how should the message be parse on client side, HTML, Markdown, or empty for plain text.
  • setUrlPreview(boolean preview): Set if client should fetch a preview of URL.
  • setNotification(boolean sendNotify): Set if a push notification should be send to target.

If you wants to use other APIs, you can do it by:

  • setApi(String apiName): Set a API method to use.
  • setPayload(String param): Set POST parameters.

Here's an example of bot code:

send = true;
switch(message["text"]) {
    case "/start": 
		setContent("Hi! I am a bot running in browser!"); 
    case "/whoami": 
        msg_str = (message["chat"]["type"] == "private") ?
	    	message["chat"]["first_name"] : "in a group!";
        setContent("You are " + msg_str); 
    case "fuck": 
        if(message["chat"]["type"] != "private") {
            send = false;
        } else setContent("That's bad.");
    default: send = false;
if (send) {

When bot gets /start, it replies with "Hi!". When bot gets /whoami, bot replies user's first name if the message are received from private chat, otherwise replies "You are in a group!". When a f-word is received from group, bot will leave that group, or replies "That's bad." if it comes from private chat.


There are 9 panels on the page: A bot configuration panel for bot settings, sending message, etc., a code panel for writing bot code, a custom API panel for making custom requests to API, a send/get file panel for sending file and getting file from/to chat, Last request and last respond panel for viewing raw respond json and request parameters, bot session panel for saving a bot in browser’s local storage, as file, or as plain text, and a run code panel for executing code.

A name can be given when saving a session to browser’s local storage, so you can store multiple codes, or bots in browser.


A running html bot A running html bot on small device

:( Low CSS skill, low Javascript skill.


telegram-html-bot uses code from these open source projects:

You can’t perform that action at this time.