Configure Telegram Bot
Official group: ShotMail, verification bot @ShotMailVerifyBot
Note
The default worker.dev domain certificate for worker is not supported by Telegram. Please use a custom domain when configuring Telegram Bot.
NOTE
If you want to use Telegram Bot, please bind KV first
If you don't need Telegram Bot, you can skip this step
If you want Telegram to have stronger email parsing capabilities, refer to Configure worker to use wasm for email parsing
Telegram Bot Configuration
Please first create a Telegram Bot, obtain the token, then execute the following command to add the token to secrets
NOTE
If you find it troublesome, you can also put it in plain text under [vars] in wrangler.toml, but this is not recommended
If you deployed via UI, you can add it under Variables and Secrets in the Cloudflare UI interface
# Switch to worker directory
cd worker
pnpm wrangler secret put TELEGRAM_BOT_TOKENBot
- Can set whitelist users
- Click
Initializeto complete the configuration. - Click
View Statusto check the current configuration status.

Language Switching
NOTE
This feature is available since v1.2.0
Telegram Bot supports Chinese and English switching. Users can set their language preference via the /lang command.
Enable Language Switching
You need to configure TG_ALLOW_USER_LANG = true in worker variables to enable this feature.
Usage
/lang zh- Switch to Chinese/lang en- Switch to English/lang- View current language setting
Language preferences are saved to KV, and each user can set their preference independently.
Per-User Mail Push
Telegram Bot supports per-user push notifications. After a user binds an address, emails received at that address are automatically pushed to the corresponding user.
User Workflow
- Find your deployed Bot in Telegram
- Use
/new [name@domain]to create a new address, or/bind <credential>to bind an existing address - Once bound, you will automatically receive push notifications when the address receives mail
- Use
/addressto view your bound addresses - Use
/unbind <address>to unbind an address
TIP
Each user can bind up to TG_MAX_ADDRESS (default 5) addresses
Global Push
Admins can enable global mail push in the admin panel under Settings -> Telegram, pushing all emails to a specified list of Telegram user IDs.
enableGlobalMailPush: Enable global pushglobalMailPushList: List of Telegram user IDs to receive global push
NOTE
Global push and per-user push can work simultaneously. If an address is bound to a user who is also in the global push list, they will receive two notifications.
Attachment Push
NOTE
This feature is available since v1.5.0
Set ENABLE_TG_PUSH_ATTACHMENT = true to enable sending email attachments via Telegram push.
- Single file size limit is 50MB (Telegram Bot API limit), oversized attachments are skipped
- Multiple attachments are sent in batches via
sendMediaGroup, up to 6 per batch - The first attachment includes the sender and subject as caption
Group Human Verification
When enabled, users requesting to join a group where the bot is an administrator first receive a math question in a private chat with the bot. Correct answers approve the join request automatically; running out of attempts or timing out declines it. This effectively blocks advertising bots.
Setup Steps
- Create the bot and configure
TELEGRAM_BOT_TOKENas described above, and bind a custom domain to the Worker (webhooks do not supportworkers.devdomains). - In the admin
Settings->Telegrampage, fill inWebhook Domain(the bound custom domain), save, then clickInit. - Add the bot to the group as an administrator with at least the
Invite userspermission (Restrict membersandDelete messagesare also recommended). - Enable
Approve new membersin the group settings (join request mode). - Back in the admin Telegram page, enable
Group Human Verificationand adjustVerification Timeout,Max Verification Attempts, and the welcome message as needed. Changes take effect after saving.
Notes
- Questions are random arithmetic problems (addition, subtraction, multiplication) answered with buttons; the language follows the requester's Telegram language (Chinese/English).
- Timed-out requests are declined automatically on the next join request or by the scheduled task (every 30 minutes).
- Members added manually by administrators do not go through join requests and are not affected.
- Webhook requests are verified with a
secret_tokenderived from the bot token; no extra configuration is needed.
Group Ad Cleanup
When enabled, ad messages from regular members in groups where the bot is an administrator are deleted automatically. It pairs well with Group Human Verification: verification stops ad bots from joining, and ad cleanup removes any ads that still get through.
Setup Steps
- Make the bot a group administrator with the
Delete messagespermission. - Turn off the bot's Group Privacy in BotFather (
/setprivacy, pick the bot, thenTurn off) so the bot can see every group message. - In the admin Telegram page, enable
Group Ad Cleanup(on by default) and adjustDelete External Telegram Links,New-Member Link Restriction, andAd Keywordsas needed. Changes take effect after saving.
Deletion Rules
A regular member's message is deleted when it matches any rule (administrator and owner messages are never touched):
- Contains an external Telegram group/channel link (links to this group and to the bot itself are allowed); this rule can be turned off.
- Matches an ad keyword (defaults cover common Chinese ad phrases such as part-time-job and traffic-driving scams; edit the list freely — matching ignores whitespace and zero-width characters).
- Is forwarded from a channel and contains a link.
- Posts a link within the new-member restriction window (24 hours by default, 0 = off), based on the join time recorded by the bot.
Edited messages are checked against the same rules.
Mini App
Can be deployed via command line or UI interface
UI Deployment
For other steps, refer to Frontend and Backend Separation Deployment in UI Deployment
NOTE
Download the zip from here, telegram-frontend.zip
Modify the index-xxx.js file in the zip, where xx is a random string
Search for https://temp-email-api.xxx.xxx, replace it with your worker domain, then deploy the new zip file
Command Line Deployment
cd frontend
pnpm install
cp .env.example .env.prod
# Edit .env.prod and set VITE_IS_TELEGRAM=true
# --project-name can create a separate pages for mini app, you can also share one pages, but may encounter js loading issues
pnpm run deploy:telegram --project-name=<your_project_name>WARNING
Windows users: The inline VITE_IS_TELEGRAM=true environment variable in npm scripts does not work on Windows. Please set VITE_IS_TELEGRAM=true in your .env.prod file manually, then use the regular build command instead:
pnpm run build- After deployment, please fill in the web URL in the
Settings->Telegram Mini ApppageTelegram Mini App URLin the admin backend. - Please execute
/setmenubuttonin@BotFather, then enter your web address to set theOpen Appbutton in the lower left corner. - Please execute
/newappin@BotFatherto create a new app and register the mini app.