Telegram bots API responds 403 Forbidden
Asked Answered
D

5

9

I'm fairly new to programming and I want to make a simple bot for telegram. After creating new bot using bot father and getting token, I made a simple HTTP post request to the below address:

https://api.telegram.org/bot{token}/METHOD_NAME

But for any method, I faced with a 403 error page. What's wrong?

Darcydarda answered 25/6, 2015 at 22:29 Comment(2)
Such an important question, and such naive mistakes and answers. I wonder what would be other causes besides "typos".Alyse
Ok, today (2021-04-17) I had my bots forbidden. After some research I realized that the old link api.tlgr.org is not working anymore. Now you need to use api.telegram.orgAlyse
C
7
https://api.telegram.org/bot{yourtoken}/get_me(or any method name)

Just like me you are forgetting bot between https://api.telegram.org/ and your token.

Cleocleobulus answered 26/6, 2015 at 7:41 Comment(0)
R
2

You should not replace bot string with your Bot's username, Just append given token at the end of /bot (e.g .../bot123456:ABC-D...) and your URL is ready.

Reptant answered 10/7, 2015 at 11:25 Comment(0)
S
1

replace keyword token with your string, which is provided by bot father. The telegram user who will interactive with bot, have to send /start command to bot. I think it is a kind of registering or allowing bot to work with user.

Sawfish answered 21/12, 2015 at 8:51 Comment(0)
G
0

This happens to my bot when posting to an specific chat_id. You should check:

  1. Whether this fails for any chat id or some specific chat id.

  2. If message destination is a chat_id under your control, check that you didn't tell your Telegram client to delete the chat with the bot.

  3. If message destination is a group chat_id, check the bot is a member of the group.

Issuing a "get_me" instead should never get you a 403, so my suggestion is to first check whether everything is sending you a 403 or only a specific chat_id is the problem. If you are writing some notification software and this happens to you, you should stop sending messages and either alert the user (via some settings page, not Telegram) or if you don't have such means other than Telegram to contact the user just delete it from your database.

Gad answered 23/4, 2022 at 13:21 Comment(0)
M
0

Another case is if you deploy a Telegram bot and use a DNS server via Cloudflare with a paid subscription. You can disable Super Bot Fight Mode on Cloudflare following this step:

  1. Go to your domain name
  2. Security > Bots
  3. Looking on the top-right of the Bots topic > Click Configure Super Bot Fight Mode
  4. On the Definitely automated topic > Select the Allow parameter

Bots on Cloudflare: https://developers.cloudflare.com/bots/

Maniemanifest answered 13/11, 2023 at 14:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.