Remote OpenClaw

Remote OpenClaw Blog

OpenClaw Telegram allowFrom: Control Who Can Message Your Bot

Published: ·Last Updated:
What changed

This post was reviewed and updated to reflect current deployment, security hardening, and operations guidance.

What should operators know about OpenClaw Telegram allowFrom: Control Who Can Message Your Bot?

Answer: The allowFrom configuration in OpenClaw's Telegram integration is an access control list that determines which users and groups can interact with your bot. By default, when you create a Telegram bot and connect it to OpenClaw, anyone who finds your bot's username can send it messages. Every message generates an API call to your AI model, which costs.

Updated: · Author: Zac Frulloni

Configure OpenClaw Telegram allowFrom to control who can message your bot. Whitelist user IDs, restrict group access, and understand the security implications of open vs restricted mode.

Marketplace

Free skills and AI personas for OpenClaw — deploy a pre-built agent in 15 minutes.

Browse the Marketplace →

Join the Community

Join 500+ OpenClaw operators sharing deployment guides, security configs, and workflow automations.

What Is allowFrom?

The allowFrom configuration in OpenClaw's Telegram integration is an access control list that determines which users and groups can interact with your bot. By default, when you create a Telegram bot and connect it to OpenClaw, anyone who finds your bot's username can send it messages. Every message generates an API call to your AI model, which costs money.

Without allowFrom, your bot is completely open. If someone discovers your bot username (which is public and searchable on Telegram), they can start a conversation and your OpenClaw instance will process every message, consuming your API credits. This is a security risk and a cost risk.

The allowFrom setting lets you specify exactly which Telegram user IDs and group chat IDs are permitted to send messages to your bot. Messages from any other source are silently dropped before they reach the AI model. No API call is made, no response is generated, no cost is incurred.

Think of it as a bouncer for your bot. Without it, everyone gets in. With it, only people on the list get in.

How to Find User and Group IDs

Telegram user IDs and group IDs are numeric identifiers. They are not the same as usernames. You need the numeric ID for the allowFrom configuration.

Finding your user ID:

  1. Open Telegram and search for @userinfobot
  2. Start a conversation and send any message
  3. The bot replies with your user ID (a positive number like 123456789)

Alternatively, you can find user IDs in OpenClaw's logs. Enable debug logging (OPENCLAW_LOG_LEVEL=debug), send a message to your bot, and check the logs:

docker logs openclaw --tail 50 | grep "user"

The log entry for each incoming message includes the sender's user ID.

Finding a group chat ID:

  1. Add your bot to the group
  2. Send a message in the group
  3. Check OpenClaw's debug logs — the group's chat ID is logged with every incoming group message
  4. Group IDs are negative numbers (like -1001234567890)

You can also use the @getmyid_bot Telegram bot — forward a message from a group to this bot, and it will tell you the group's chat ID.

Marketplace

Free skills and AI personas for OpenClaw — browse the marketplace.

Browse Marketplace →

Configuration

Set the allowFrom list as an environment variable in your docker-compose.yml:

OPENCLAW_TELEGRAM_ALLOW_FROM=123456789,987654321,-1001234567890

The value is a comma-separated list of user IDs and group IDs. No spaces around the commas. In this example:

  • 123456789 — a specific user can message the bot directly
  • 987654321 — another specific user
  • -1001234567890 — a group chat where the bot will respond

After adding the environment variable, restart OpenClaw:

docker compose down && docker compose up -d

Verify the configuration by checking the logs. On startup, OpenClaw logs the number of allowed entities:

[INFO] Telegram allowFrom configured: 2 users, 1 group

Test by sending a message from an allowed user (should get a response) and then from a different Telegram account (should get no response). The non-allowed message should appear in debug logs as "dropped by allowFrom filter."

Group Access Control

When you add a group ID to allowFrom, all members of that group can interact with the bot within that group. This is different from user-level access — you are granting access to the group, not to specific users within it.

Important implications:

  • New members: If someone joins the group after you configured allowFrom, they automatically gain access to the bot. The access is tied to the group, not the individual.
  • Group vs DM: Adding a group ID only allows interaction within that group. The individual members cannot message the bot directly unless their personal user IDs are also in the allowFrom list.
  • Multiple groups: Add multiple group IDs separated by commas. The bot will respond in all listed groups.

For maximum control, you can combine group and user restrictions. For example, allow the bot in a team group, but also allow your personal user ID for direct messages:

OPENCLAW_TELEGRAM_ALLOW_FROM=123456789,-1001234567890

This lets you DM the bot (user 123456789) and also use it in the team group (-1001234567890), but blocks everything else.

Open Mode vs Restricted Mode

Here is a clear comparison of running your bot with and without allowFrom:

AspectOpen Mode (no allowFrom)Restricted (allowFrom set)
Who can messageAnyone on TelegramOnly listed users/groups
API cost riskHigh — strangers use your creditsLow — only authorized users
Spam riskHigh — bots and spammers can reach youNone — unlisted senders are dropped
Data exposureStrangers see bot responsesOnly trusted users see responses
Use casePublic customer support botsPersonal, team, and business bots

When open mode is appropriate: You are running a customer support bot where unknown users need to initiate conversations. In this case, you want anyone to be able to message the bot. Combine open mode with rate limiting (OPENCLAW_TELEGRAM_RATE_LIMIT) and daily token limits to control costs.

When restricted mode is appropriate: Virtually every other scenario. Personal bots, team bots, business bots, testing bots — all should use allowFrom. The risk of leaving a bot open is almost never worth it for non-public bots.

A common mistake: operators set up their bot, test it with their own account, and forget to configure allowFrom before deploying to production. The bot works fine during testing because the operator is the only one messaging it. Weeks later, someone discovers the bot username, and the operator gets a surprise API bill. Always configure allowFrom as part of your initial deployment.

Advanced Access Patterns

Dynamic allowFrom with the API: OpenClaw's API supports updating the allow list without restarting the container. This is useful for bots where you need to add or remove users programmatically:

curl -X POST http://localhost:3008/api/channels/telegram/allow \
  -H "Authorization: Bearer your-gateway-token" \
  -H "Content-Type: application/json" \
  -d '{"add": ["111222333"], "remove": ["444555666"]}'

Changes take effect immediately. The allow list is persisted to disk, so it survives container restarts.

Separate allow lists per command: If your bot supports multiple commands (like /help, /report, /admin), you can configure different access levels for different commands. This is done through the agent's persona prompt rather than the environment variable. Include instructions like "only process /admin commands from user ID 123456789" in your persona.

Deny list (block specific users): OpenClaw also supports a deny list that blocks specific users while allowing everyone else. This is the inverse of allowFrom and is useful for public bots where you want to block specific abusive users:

OPENCLAW_TELEGRAM_DENY_FROM=999888777,666555444

If both ALLOW_FROM and DENY_FROM are set, ALLOW_FROM takes precedence. Only users on the allow list can interact, regardless of the deny list.

Frequently Asked Questions

What is allowFrom in OpenClaw Telegram?

allowFrom is an environment variable (OPENCLAW_TELEGRAM_ALLOW_FROM) that controls which Telegram users and groups can interact with your OpenClaw bot. When set, only the specified user IDs and group IDs can send messages to the bot. Messages from all other users are silently ignored.

How do I find my Telegram user ID for allowFrom?

Send a message to the Telegram bot @userinfobot — it will reply with your numeric user ID. Alternatively, enable debug logging in OpenClaw, send a message to your bot, and check the logs — the sender's user ID is logged with every incoming message.

Should I leave OpenClaw Telegram in open mode?

No, unless you specifically want a public bot. Open mode means anyone who discovers your bot's username can send it messages, consuming your API credits. For personal and business bots, always set allowFrom to restrict access to known users.

Can I allow entire Telegram groups in allowFrom?

Yes. Add the group's chat ID (a negative number like -1001234567890) to the OPENCLAW_TELEGRAM_ALLOW_FROM list. All members of that group will be able to interact with the bot within the group.