Telegram "Send Message and Wait for Response" Node throws Error 400 (can't find end of the entity)

I’m building an invoice processing workflow in n8n Cloud and running into a 400 Bad Request error on the Telegram (Send Message and Wait for Response) node.

Whenever I include a dynamic Google Drive link (or certain variables) inside my message body, Telegram’s parser crashes with:

Bad Request: can't find end of the entity starting at byte offset...

  • If I remove the Google Drive URL from the text, the message goes through instantly.

How can I safely pass dynamic URLs and text variables into the Telegram Send Message and Wait for Response node without breaking its entity parser? Any tips would be greatly appreciated!

That error comes from Telegram’s Markdown parser, not from n8n itself. The message is sent with a Markdown parse mode, so any _, *, ` or [ inside your text is read as the start of a formatting entity. Google Drive links almost always contain an underscore (e.g. ...view?usp=drive_link, and many file IDs have _ too), so Telegram sees an “italic” that never closes → can't find end of the entity starting at byte offset X. The byte offset in the error points exactly at that character.

Two reliable fixes:

1. Escape the dynamic parts with an expression

In legacy Markdown you escape those characters with a backslash. In the Message field, wrap every variable that could contain them:

New invoice: {{ $json.fileName.replace(/([_*`\[])/g, '\\$1') }}
Link: {{ $json.webViewLink.replace(/([_*`\[])/g, '\\$1') }}

The backslashes are removed by Telegram, so the user sees the normal URL and it stays clickable. Do the same for file names, vendor names, etc. — invoice_2026_10.pdf will break it the same way.

2. Use a Markdown link instead of the raw URL

[Open invoice in Drive]({{ $json.webViewLink }})

Characters inside the ( ) of a link are not parsed as formatting, so the underscores are fine there, and the message looks cleaner. You still need to escape any other variables in the text (option 1).

Tip: if you reuse this in several nodes, add a Set/Edit Fields node before the Telegram node that creates the escaped fields once (safeName, safeLink), then reference those in the message.

To test quickly: hard-code the same Drive URL in the message — if it fails, then works after adding \ before each _, you’ve confirmed the cause.

2 Likes