Telegram Error 400 : chat id is empty

Below is the screenshot of the output error. I am unable to understand why does it say chat id is empty. I’ve rechecked everything. The channel id is there in the conf.py file and it is correct as well. What do I do to rectify this?

@aditya198018d Share your python code so it will be easier to understand the main problem.

Below are the screenshots of the respective code. Ignore the indenttion error stated in the last screenshot. It has been resolved.

Hi @aditya198018d , it seems that you have not entered the chat id properly. Note that the chat id is not the name of your channel but its invite link which you will find in the channel info.
It will be something like this:

t.me/XXXXX

When you put it in the conf file don’t type t.me/
So check if you have entered the info link and not the channel name. Hope this helps!

Hi @kshitishjgadre.
Yes, I have filled the Chat id in the conf.py file and I have triple checked that it is same as the invitation link starting with @.

@aditya198018d Check 4th line of your code. mybolt=Bolt(conf.API_KEY,conf.DEVICE_ID).
You have written only device_id, but it is conf.device_id .
And also check case of device_id whether it is lowercase or uppercase.
I think this might solve your problem.
I hope this helps you.
Thanku.

@chetashri2001 Sorry but these screenshots were taken for the previous issue I was facing regarding the indentation errors-“Indentation error in Telegram alert system”. I have made necessary corrections.

Let’s take things the logical way. conf.device_id was responsible for fetching data from the bolt device, which is being done flawlessly.
Now comes the part for sending the message to telegram. Here is the code failing to do so, as can be seen in the first image posted on the thread.
This is what I’m unable to get. Even when the chat id is filled correct an error for the same shows up.

The rest of the code hasn’t been touched as the previous issue was solved without doing anything to it. So it can be referred for further references. Please let me know if you get something.
And thank you so much for your efforts :pray:t2::pray:t2:

@aditya198018d
Untitled|690x391 .
I got your error, same happened with me too.
In step3, message=“Alert!..…” in that line remove backslash \ from that line.
And add continue at last of step 2.
I am adding my code’s screenshot here, check it.

The problem has been fixed today. Actually I had made a small change in the code. Considering that the data is a dictionary I thought I could replace the name “chat_id” with “channel_id” as it would be more appropriate. I was considering that Telegram would consider the first entry to be same even if we change its name. Although, now I got to know this is rather not the case. In this case I guess Telegram was unable to catch the channel_id for the above mentioned reason.
I am currently unable to send the screenshot after since I updated the workstation. Will update you with the screenshot shortly.
Thank you so much to everyone for your efforts :pray:t2::pray:t2::pray:t2:

1 Like

Great bro! :raised_hands:

1 Like

I would like to know what the backslash does here as @chetashri2001 mentioned.

This is what I’ve found. Here, backslash is used with another character for the various purposes. But in our code we have just used one backslash and nothing else.

This is the screenshot of the output.

Hey @aditya198018d , we have used two different strings in step 3.
The purpose of using backslash without any other character is to join two different lines. So, we have joined the strings by using it. For more information refer to this link

1 Like

@kshitishjgadre Thanks man for bringing this.

1 Like

How do you find the best quality care, the best results through a suitable location and that’s too at affordable charges? I & D hospital solution private limited give wonderful Hospital Partnership opportunities for the interested business associates.