Introducing Livops 2.0! Promo codeCEOgives you 8,000 so‘m on your balance.What’s new

Telegram 403: Forbidden: bot is not a member of the channel chat — how to fix it

Telegram knows the channel, but your bot is not in it, so every send, edit or delete there fails with a 403. Usually the bot was never added (a public channel is found by its @username even so), it left with leaveChat, it was removed and then unbanned, or the token belongs to a different bot. Add the bot to the channel as an administrator that can post messages. The same error exists for supergroups and groups.

By Livops team, the people who build and run LivopsUpdated

The full error, as the Telegram Bot API returns it with error code 403[2]:

Forbidden: bot is not a member of the channel chat

The same check has two siblings, for a supergroup and for a basic group[2]:

Forbidden: bot is not a member of the supergroup chat
Forbidden: bot is not a member of the group chat

Each library wraps it in its own words:

Library What you see
aiogram 3 TelegramForbiddenError: Telegram server says - Forbidden: bot is not a member of the channel chat[4][5]
python-telegram-bot telegram.error.Forbidden: Forbidden: bot is not a member of the channel chat[6][7]
grammY GrammyError: Call to 'sendMessage' failed! (403: Forbidden: bot is not a member of the channel chat)[8]
Telegraf TelegramError: 403: Forbidden: bot is not a member of the channel chat[9]

python-telegram-bot strips an Error: or Bad Request: prefix from a description, not Forbidden: , so this message keeps it[6]. This page explains when the Bot API server gives this error, how it differs from chat not found and bot was kicked, the causes from the most common, and how to check the fix.

What does the error mean?

Before a method touches a chat, the Bot API server checks the bot’s own status in it. For a channel or a supergroup, the server’s rules are[2]:

  • If the bot is banned there, the answer is Forbidden: bot was kicked from the channel chat (or supergroup chat).
  • If the bot is not a member — its status is left, or it is restricted and not a member — and the method needs more access than the chat allows a stranger, the answer is Forbidden: bot is not a member of the channel chat (or supergroup chat).
  • Public or private decides what “more access” is. A channel or supergroup with a username is public: reading it, such as getChat, works without membership, and only methods that send, edit or delete need the bot inside. A private one needs membership even to be read.

For a basic group the server answers Forbidden: bot is not a member of the group chat when the group is still active and the bot has left it[2].

So the server found the chat; the bot just is not in it. The Bot API’s left status is a chat member who is not currently a member but may join, and kicked is one who was banned and cannot return[1].

How is it different from chat not found and kicked?

Description Code What happened What to do
Bad Request: chat not found 400 The server does not know the chat: a wrong id, or a private chat this bot was never in Fix the id or the token; see chat not found
Forbidden: bot is not a member of the channel chat 403 The chat is known, the bot’s status there is left Add the bot to the chat
Forbidden: bot was kicked from the channel chat 403 The bot is banned in the chat Ask an admin to add it back; see bot was kicked
Bad Request: need administrator rights in the channel chat 400 The bot is in the channel but may not post Make it an administrator that can post; see not enough rights

The last row comes from TDLib, under the Bot API server: in a channel, a chat member without the right to post gets Need administrator rights in the channel chat[3], which the server passes on as a 400 with Bad Request: in front[2]. Telegram says the numeric error_code may change in the future[1], so tell these apart by the description your library gives you, not by the number alone.

Causes, most common first

1. The bot was never added to the channel

The most common case, and the one that looks strangest: you send to @mychannel, Telegram clearly finds it, and still refuses. A public channel can be addressed by its @username[1], and the server resolves it for any bot; only the send needs the bot to be inside[2]. A private channel the bot was never in gives chat not found instead.

Fix: an administrator of the channel adds the bot as an administrator, with the right to post messages. can_post_messages is the administrator right to post in a channel, and it exists for channels only[1]. A bot cannot add itself: the Bot API has no method for joining a chat[1].

2. The bot left the chat

leaveChat makes a bot leave a group, supergroup or channel[1]. A cleanup script, an admin command in your own bot, or a test that called it once leaves the bot’s status at left, and sends there fail with this 403[2]. Add the bot again.

3. It was removed, then unbanned

When a bot is removed and banned, sends give bot was kicked[2]. If an admin then unbans it, it is not back in the chat: an unbanned user does not return automatically, and unbanChatMember by default guarantees that the user is not a member afterwards[1]. The error turns from kicked into not a member. Add the bot again.

4. A different bot’s token

Membership is per bot. The channel has @shop_bot as an administrator, and the code sends with the token of @shop_test_bot: the channel is public, so the test bot resolves it, and it is not a member. This is common when staging and production use different bots. Check which bot the token belongs to:

curl -s "https://api.telegram.org/bot$BOT_TOKEN/getMe"

getMe returns the bot’s username and id; that bot must be the one in the channel’s administrator list.

5. A supergroup or group the bot is not in

The same causes give the siblings: bot is not a member of the supergroup chat for a supergroup, bot is not a member of the group chat for a basic group the bot has left[2]. In a group or supergroup an ordinary member may send if the group’s default permissions allow it[1], so the bot does not have to be an administrator there; adding it as a member is enough to clear this error.

How to check the fix

Find the bot’s id with getMe above, then ask Telegram for the bot’s own status in the channel:

curl -s "https://api.telegram.org/bot$BOT_TOKEN/getChatMember?chat_id=@mychannel&user_id=$BOT_ID"

getChatMember returns a ChatMember[1]. You want "status":"administrator" with "can_post_messages":true. Then send one message with the exact chat id and token the app uses:

curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
  --data-urlencode "chat_id=@mychannel" \
  --data-urlencode "text=test"

"ok":true means the bot is in and may post. For a private channel, use its numeric id, which starts with -100, in place of @mychannel.

Learn about it before the next send. Telegram sends the bot a my_chat_member update when the bot’s own status in a chat changes[1]. Handle it to record when the bot is added to a channel, and when it becomes left or kicked, so a broadcast skips those chats instead of meeting the 403. A full example is in bot was kicked from the group chat.

On Livops

Livops does not add your bot to chats or retry its sends; the fixes above are in Telegram and in your code. What to check on the Livops side:

  • The token and the channel are variables. Put BOT_TOKEN and the target, such as CHAT_ID=@mychannel or -1001234567890, under Variables, without quotes. New values take effect on the next deploy; restart the service to apply them now. Mark the token as a secret, and its value is never shown again, only its name.
  • Staging copies the variables. A new environment such as staging gets copies of production’s services and variables. Give it its own test bot’s token so the two do not share one bot, and then add the test bot to a test channel too: with production’s CHAT_ID, the test bot meets exactly cause 4. See Environments.
  • Logs. Log the chat id and the bot’s username next to each failed send; the project’s Logs page and livops logs <service> -f show them. The assistant sees variable names, never their values, so it cannot tell you which bot a token belongs to; getMe can.
  • Scheduled posts as a cron job. A cron service runs a command on a schedule, for example a script that posts to the channel every morning. It should only send: if it also called getUpdates while the bot polls, Telegram would answer with a Conflict error. See Cron and workers.

A bot, worker or cron job costs 19 credits a month (19,000 so’m); see Pricing.

Questions

How do I add my bot to a channel?

An administrator of the channel adds it: in the channel's settings, add the bot as an administrator and leave the right to post messages switched on. A bot cannot join by itself, because the Bot API has no method for joining a chat.

Why can my bot read a public channel with getChat but not post to it?

For a public channel or supergroup, the Bot API server asks for membership only when a method writes, edits or deletes. Reading its info by @username works without it. Sending needs the bot to be in the channel, and in a channel only an administrator with the right to post may send.

What is the difference between not a member and bot was kicked?

Kicked means the bot is banned in that chat: an administrator removed it and it cannot come back until someone unbans or re-adds it. Not a member means its status is left: it was never added, it left with leaveChat, or it was unbanned but not added back. Both are 403s.

How is it different from chat not found?

Chat not found is a 400: the server does not know the chat at all, for example a private channel the bot was never in, or a wrong id. Not a member is a 403: the server found the chat and the bot is not in it, which happens most with public channels found by @username.

The bot is a member but sending still fails. Why?

Then the error is a different one. In a channel, a bot that is in it but cannot post gets Bad Request: need administrator rights in the channel chat. Make it an administrator with the right to post messages.

Should my code retry the send?

No. Nothing changes until someone adds the bot to the chat, so a retry gets the same 403. Log it, stop sending to that chat, and resume when the bot gets a my_chat_member update saying it was added.

Sources

  1. Telegram Bot API — Making requests, sendMessage, getChat, getChatMember, leaveChat, unbanChatMember, ChatMember, ChatAdministratorRights, Update (core.telegram.org). Checked .
  2. Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
  3. TDLib source — td/telegram/DialogManager.cpp (raw.githubusercontent.com). Checked .
  4. aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
  5. aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
  6. python-telegram-bot source — telegram/error.py (raw.githubusercontent.com). Checked .
  7. python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
  8. grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .
  9. Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .

Put your project online today

Connect GitHub or drop a folder. No card is asked for.

Deploy your bot

Got a question? — @livops_uz