every thing is fine in my code and it is able to get the reading. to whether bot is working or not I altered the code to send message through the bot in telegram channel . But i am facing an error code saying that
Error:-
{“OK”:false,“error_code”:404,“description”:“Not found”}
So , I did some research on the error code and tried to fix it, but its not working
“I HAVE PINNED THE IMAGE”

Make sure that your contents in the config file for this program is correct.
The telegram url should come in the format: https://api.telegram.org/api_key_of_bot/sendMessage
the variable telegram_bot_id from the config.py file should be of the format “botXXXX” where “XXXX” is the API key you must have received from telegram’s botfather chat after creating your bot. My bot_api_key was of the form 1234567:abcdefghijklmnop. So in config file; telegeram_bot_id = “bot1234567:abcdefghijklmnop” and similarly for other variables in the config file.
For the complete format of the config.py file:
“”“Configurations for telegram_alert.py”“”
bolt_api_key = “XXXX” # This is your Bolt Cloud API Key
device_id = “XXXX” # This is the device ID and will be similar to BOLTXXXX where XXXX is some numbers
telegram_chat_id = “@XXXX” # This is the channel ID of the created Telegram channel. Paste after @
telegram_bot_id = “botXXXX” # This is the bot ID of the created Telegram Bot. Paste after bot
threshold = 250 # Threshold beyond which the alert should be sent
After your config file is corrected. Make sure that the first statement in the send_telegram_message function, the format is the same as this: url = “https://api.telegram.org/” + conf.telegram_bot_id + “/sendMessage”
1 Like
I tried the above solution but the problem is same…
Share the telegram_alert.py code
have you made sure that your telegram channel is public and you were able to create a link of your own?
try opening that url which gets printed in your terminal through your browser. If the same error_code: 404 appears then there is some typo for sure in your telegram_bot_id. if any other error code like 400 or 403 then there’s no type in it.
after applying the changes the error changed
{“ok”:false,“error”:400,“description”:"bad request:chat not found

is your telegram_chat_id variable value in config.py is of the format @telegram_link?
Note: do not include “t.me/” in the value, take whatever is after that “/” and paste it in place of telegram_link.
for eg. if your invite link is “t.me / mytelegramlink” then the value of telegram_chat_id = “@mytelegramlink”
2 Likes
Thank you @amalmanikandan21 , Your solution solved my problem