Telegram error 400: Bad Request: message text is empty
Last verified against Telegram Bot API reference
Bad Request: message text is emptyWhat error 400 means
sendMessage (or editMessageText) was called with a text that is empty or, after entity parsing, contains nothing visible. The Bot API requires 1 to 4,096 characters after entities are parsed. An empty string, a string of only markup, or a null that your HTTP client serialized as an empty field all produce this.
Telegram counts characters after parsing, so <b></b> in HTML mode or ** in Markdown is empty even though the raw payload is not. Whitespace-only strings are also rejected.
The error is purely about your payload; nothing about the chat, token or rate limits is involved. It is most often a symptom of a template or an LLM response that came back blank.
What it looks like
{"ok":false,"error_code":400,"description":"Bad Request: message text is empty"}Why it happens
- A template variable was undefined and rendered to an empty string.
- A model or upstream API returned an empty or whitespace-only reply that was forwarded verbatim.
- The text was placed in the wrong parameter name (e.g.
messageinstead oftext) sotextarrived empty. - Markup-only content that parses to zero visible characters.
How to fix Telegram error 400
- 1Validate
text.strip()is non-empty before calling the API, and substitute a fallback message if it is not. - 2Check the exact parameter name your HTTP layer sends; dump the outgoing form or JSON body once.
- 3For edits, confirm you meant
editMessageTextand noteditMessageReplyMarkup(which does not take text). - 4Log the upstream response that produced the empty string and fix the source.
How to stop it recurring
Put a single outbound guard in front of every send that enforces 1 to 4,096 characters and rejects whitespace-only content with a clear internal error. For AI-generated content, treat an empty completion as a failure case with its own fallback copy rather than passing it through.
The valid range is 1-4,096 characters after entities parsing, documented under sendMessage and collected on the text limits table. The opposite failure, text over the ceiling, returns message is too long; a single length guard in your send helper covers both ends. Libraries raise their generic 400 class here (BadRequest / TelegramBadRequest), so alerting should key on the description.
Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.
Related codes
Error 400 - quick answers
What does Telegram error 400 mean?
sendMessage (or editMessageText ) was called with a text that is empty or, after entity parsing, contains nothing visible. The Bot API requires 1 to 4,096 characters after entities are parsed. An empty string, a string of only markup, or a null that your HTTP client serialized as an empty field all produce this.
How do I fix Telegram error 400?
1. Validate text.strip() is non-empty before calling the API, and substitute a fallback message if it is not. 2. Check the exact parameter name your HTTP layer sends; dump the outgoing form or JSON body once. 3. For edits, confirm you meant editMessageText and not editMessageReplyMarkup (which does not take text). 4. Log the upstream response that produced the empty string and fix the source.
Should I retry after error 400?
No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.
Stop debugging Telegram by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.