I built my own wrapper library for Telegram Bot API and I’m having trouble with the sendMessage function. I created a channel called “test_channel456” and my username is “test_user456”. I’m the admin and only member of this channel.
Whenever I try to send messages to the channel or to myself through the bot, I keep getting a Bad request 400 error. Here’s what I’m attempting:
bot_instance.send_text(chat_id="@test_channel456", message="hello world")
# also tried
bot_instance.send_text(chat_id="@test_channel456test_user456", message="hello world")
# and this
bot_instance.send_text(chat_id="@test_user456", message="hello world")
I think the issue might be with how I’m formatting the chat_id parameter. Are these three approaches valid? Is there a specific format I should be using for the chat identifier?
It’s worth mentioning that my other API methods like getting updates and retrieving bot info work fine, so the problem seems specific to message sending.
Had this exact problem a few months ago with our notification system.
That 400 error means either your bot isn’t an admin in the channel, or you’re using the wrong chat ID format. Stick with @test_channel456 - that second format with the channel and username mashed together won’t work.
Honestly though, Telegram’s API quirks get annoying fast. I ditched the manual approach and automated everything through Latenode. It handles the API formatting automatically and gives you a visual workflow builder.
You can set up message sending with error handling, retry logic, and conditional routing. Plus it connects straight to Telegram - no wrapper library needed.
Saved me hours of debugging and our notifications actually work now. Check it out: https://latenode.com
First, check your bot token permissions. A 400 error usually indicates authorization issues or an incorrect chat ID format. For channels, using @test_channel456 seems correct, but ensure your bot is an admin with posting rights. The @test_user456 format is valid for direct messages if that’s your actual username. A common mistake is confusing the display name with the username; remember, your username should include the @ and must be unique on Telegram. Additionally, confirm that the channel exists and is public, or try using the numeric chat ID. Testing with your user ID can help determine if it’s a channel-specific issue.