Telegram error code 400

Please help me. I’m nit receiving telegram msg. Error is occurring. Tried so much. Creat new bot account also. Still not rectified.

Hi @sanketbagde38,

Can you share the below screenshot for your telegram channel ?

Hi @sanketbagde38
In your file

Telegram_Chat_id should be the only @temp_alert_read, not @temp_alert_read_bot. Check this and try.

Let me know it helped or not.

Yes i tried. But same error


Hi @sanketbagde38
Check your code with this, and let me know.

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
1 Like

This error is occure because of telegram chat id remove “@temp_alert_read_bot” instead of type only
@temp_alert_read” and rerun code i think that is the same chat id you will find in the information of your telegram channel.

Hi @sanketbagde38 ,

I think you are entering the bot username inside chat id that is incorrect. Also, can you show me the permanent link as you can see in my screenshot. You can get it by clicking on the channel name.

Sir i didnt get the page may be in ios while creating the channel, that page was shown. but i get the permanent link

Yes i tried. Still not working.

Not working.

Hi @aniketzepale4,

Text after is your chat id.

For example:

then you chat id would be

telegram_chat_id = "@temp_reading"

Also admin should be member of this channel.

Do let me know in case you need further assistance.

Thank you everyone :pray:t3: @rahul.singh1 @phaniraghavendra661 @aniketzepale4
I got my output

Assuming that ios telegram is not allowing.
I make an account in android. And it work’s.

1 Like

“”“Configurations for”""
bolt_api_key = “XXXX”
device_id = “BOLTXXXX”
telegram_chat_id = “@temp_alert_read” # Try this as your chat id
telegram_bot_id = “botXXXX”
threshold = 250

Your telegram_chat_id has an extra word bot. Try using the code explained above.