A lightweight, serverless Telegram bot that extracts Premium Custom Emoji IDs and their usage codes from any message. Built entirely on Telegram Serverless — no external server, no VPS, no hosting costs.
When a user sends a message containing Telegram Premium Custom Emojis (or an emoji pack link like t.me/addemoji/...), the bot:
- Detects each custom emoji or fetches the entire sticker pack.
- Fetches metadata (the original emoji character) via
getCustomEmojiStickers - Returns a formatted list showing:
- The rendered Premium Emoji
- Its Emoji ID
- Ready-to-paste Button Code (
icon_custom_emoji_id) - Ready-to-paste Caption Code (
<tg-emoji>HTML tag)
- Provides inline copy buttons for each field
JSEmojiIDBot/
├── handlers/
│ └── message.js # Main message handler (all logic lives here)
├── schema.js # Database schema (users table)
├── package.json # Project config & scripts
└── README.md
Note: In Telegram Serverless, each file in
handlers/maps to a Telegram update type.message.jshandles all incoming messages.
| Layer | Tool |
|---|---|
| Runtime | Telegram Serverless (V8 Isolate) |
| API Wrapper | Built-in sdk/api |
| Database | Built-in sdk/db (SQLite + Drizzle-style ORM) |
| File Upload | Built-in InputFile from sdk |
| Language | Modern JavaScript (ES Modules) |
⚠️ No externalnpmpackages are supported on the Telegram Serverless platform. Everything must use the providedsdkmodules or pure JavaScript.
- Node.js v18+
- A Telegram Bot Token from @BotFather
- The
tgcloudCLI (installed automatically vianpx)
git clone https://github.com/JSOrganizations/JSEmojiIDBot.git
cd JSEmojiIDBot
npm installOpen your bot in BotFather → tap the bot → go to "Bot Settings" → "CLI Access". You'll see an Access Token in this format:
app1234567890:xxxxxxxxxxxxxxxxxxxxxx
⚠️ This is not the regular Bot API token (123:AAFxxx). It's a separate CLI-specific token generated by BotFather for the Serverless platform.
npx tgcloud loginPaste the CLI Access Token from BotFather when prompted. This links the project to your bot on the Serverless platform.
Open handlers/message.js and change the ADMIN_ID constant to your own Telegram User ID:
const ADMIN_ID = 6162684693; // ← Replace with your Telegram IDDon't know your ID? Send any message to the bot after deploying and check the console logs.
npm run deployOnly needed once (or whenever schema.js changes):
npx tgcloud migrateSend /start to your bot on Telegram. Then send a message containing any Premium Custom Emoji and the bot will respond with the extracted IDs.
Want to build a different bot from scratch using the same platform? Here's the quick-start:
npm create @tgcloud/bot@latest ./MyNewBot
cd MyNewBot
npm install
npx tgcloud loginCreate handlers/message.js:
import { api } from 'sdk';
export default async function (message) {
await api.sendMessage({
chat_id: message.chat.id,
text: `Hello, ${message.from?.first_name}!`,
});
}Define your schema in schema.js:
import { table, integer, text } from 'sdk/db';
export const items = table('items', {
id: integer('id').primaryKey(),
value: text('value').notNull(),
});Then use it in a handler:
import { db } from 'sdk';
import { sql } from 'sdk/db';
import { items } from 'schema';
const rows = await db.all(sql`SELECT * FROM items`);import { api, InputFile } from 'sdk';
const content = new TextEncoder().encode('Hello World');
const file = new InputFile(content, 'hello.txt', { type: 'text/plain' });
await api.sendDocument({ chat_id: chatId, document: file });npm run deploy # Push code changes
npx tgcloud migrate # Apply DB schema changes
npm run status # Check deployment status| Command | Description |
|---|---|
npm run deploy |
Push code to the Telegram Serverless cloud |
npm run status |
Check current deployment status |
npm run run |
Run the bot locally for testing |
npx tgcloud migrate |
Apply any pending database schema changes |
npx tgcloud migrate --yes |
Apply migrations without confirmation prompt |
These commands only work for the user whose ID matches ADMIN_ID in message.js:
| Command | Description |
|---|---|
/stats |
View total users, premium users, and top languages |
/export |
Download full user database as a users_export.json file |
// schema.js
users {
userId INTEGER PRIMARY KEY
firstName TEXT NOT NULL
username TEXT
languageCode TEXT
isPremium BOOLEAN DEFAULT false
lastActive INTEGER (timestamp)
createdAt INTEGER (timestamp)
}Every user who interacts with the bot is automatically saved (or updated) in this table.
This project is open source under the MIT License. Feel free to fork, modify, and build upon it!
A project by JSOrganizations