How to use your Telegram User ID when building Claude Code or Claude Agent-powered Telegram bots for access control.
Message @userid_checkbot for your User ID. Then message @BotFather, send /newbot, and save the API token it returns. Store both as environment variables.
Wire Telegram messages to Claude via the Anthropic API. Before processing any message, check message.from.id against your ALLOWED_USERS list to block unauthorized access.
Deploy to your platform (Workers, Railway, etc.), set your webhook URL, and test from both a whitelisted and non-whitelisted account.
Get your numeric Telegram User ID in seconds. Free, instant, no setup.
Open Bot & Check My ID