Issues in telegram section

Could any one help whether I have entered my chat and channel id correctly

It always shows output as error code 404.the output pic is here below

I want to know whether the error happened due to configuration or code part…

1 Like

@shivarajendran1999 Can you share your code and a screenshot of the chat ID on Telegram app?


@shivarajendran1999 Also, has the bot been added to the channel as an admin?

1 Like

Yes sir

Sir have I entered the bot and channel id correctly

1 Like

1 Like

def telegram_bot_sendtext(bot_message):
bot_token = ‘TELEGRAM API’
bot_chatID = ‘CHAT ID’
send_text = ‘’ + bot_token + ‘/sendMessage?chat_id=’ + bot_chatID + ‘&parse_mode=Markdown&text=’ + bot_message
response = requests.get(send_text)
return response.json()

please indent the lines properly before using it
and also change the function call statement inside while loop

use this function instead of the send_telegram_message function
it does not has try catch segment but it works
and you can always include try catch segment if you want

@shivarajendran1999 It seems there is something incorrect with your config.
You might have mistaken O for 0 or I for 1 etc. This error only occurs when the config is incorrect.


@shivarajendran1999 your chat id will be the permanent link of your telegram account and the channel id will be the http-Api token given on bot father chat section…
Let me know if this work

i am getting this output(error 401 and unauthorized). can anyone help.

@janavi.mohite Seems you have made an error in either your Chat ID or the Bot ID. Please check them again.

i have checked, but it is giving same error.

@janavi.mohite Please check if you have made any error by confusing O with 0 or I with 1 etc. This is another common mistake.

@janavi.mohite I was facing the same problem that is error code 401. This happens because our token is not generated properly and has space before “:” semi colon. This happens most of time because of different username or sometimes break in internet connection. I request you to make another new channel with different name and use the same name as bot username. for ex. if your permanent link is “prafful12” use “prafful12_bot” as a username and generate new token. Maybe this could help, as doing this I was able to successfully run the code.