Telegram output issue

Error code 404
Description : unauthorized

![image|375x500](upload:// eg)

Hi @vazxavier91,
Could you provide more details on what code you were running and what all steps you have completed? Also, if possible attach the screenshot of the terminal.

I have attached snaps

Hi @vazxavier91,

There is a typo error in your code. It should be sendMessage not the sendMessages

url = "" + conf.telegram_bot_id + "/sendMessage"

Error code: 400

Hi @vazxavier91,

Check this thread Error 404 Not Found for Telegram chat bot

Also, you first need to send a message to the bot before the bot can send messages to you.

1 Like

I replaced chat Id with Channel link , before I mentioned id which I have got it from botFather.


Now it seems that you have received the message.

Do let me know in case you need any other information.

Thanks, @rahul.singh1

1 Like

import requests # for making HTTP requests
import json # library for handling JSON data
import time # module for sleep operation

from boltiot import Bolt # importing Bolt from boltiot module
import conf # config file

mybolt = Bolt(conf.bolt_api_key, conf.device_id)

def get_sensor_value_from_pin(pin):
“”“Returns the sensor value. Returns -999 if request fails”""
response = mybolt.analogRead(pin)
data = json.loads(response)
if data[“success”] != 1:
print(“Request not successfull”)
print(“This is the response->”, data)
return -999
sensor_value = int(data[“value”])
return sensor_value
except Exception as e:
print(“Something went wrong when returning the sensor value”)
return -999

def send_telegram_message(message):
“”“Sends message via Telegram”""
url = “” + conf.telegram_bot_id + “/sendMessage”
data = {
“chat_id”: conf.telegram_chat_id,
“text”: message
response = requests.request(
print(“This is the Telegram URL”)
print(“This is the Telegram response”)
telegram_data = json.loads(response.text)
return telegram_data[“ok”]
except Exception as e:
print(“An error occurred in sending the alert message via Telegram”)
return False

while True:
# Step 1
sensor_value = get_sensor_value_from_pin(“A0”)
print(“The current sensor value is:”, sensor_value)

# Step 2
if sensor_value == -999:
    print("Request was unsuccessfull. Skipping.")

# Step 3
if sensor_value >= conf.threshold:
    print("Sensor value has exceeded threshold")
    message = "Alert! Sensor value has exceeded " + str(conf.threshold) + \
              ". The current value is " + str(sensor_value)
    telegram_status = send_telegram_message(message)
    print("This is the Telegram status:", telegram_status)

# Step 4

Sometimes these telegram bots are not responding according to our will. For more knowledge check this telegram website.

Hi @vikramjkataria and @productsindia25,

Check this thread Telegram : {"ok":false,"error_code":404,"description":"Not Found"}

Hi sir,

Sir, I’m unable to get msg in telegram sir

Tq sir!!
I got the output!

1 Like

Hi @shalpreethkrish6699,

It will be great if you can share the details about how did you resolve the issue. It will help others also.

Do let me know in case you need any other information.

Sir, I was unable to get the output for telegram problem sir. So I searched the issue in bolt forum. I read the solution given from various people about issue. The issue was about telegram bot id. I gave the bot id carefully but still i didn’t get output. Atlast i changed the telegram bot id with the help of “bot father.” Finally I got the output with another telegram bot id.

Thank You Sir.

1 Like