Overview
This node converts and validates text formatted in standard Markdown or HTML into Telegram's specific MarkdownV2 format. It supports three main operations:
- Convert to Telegram MarkdownV2: Transforms common Markdown syntax (and optionally HTML tags) into the Telegram MarkdownV2 format, which is required for rich text formatting in Telegram messages.
- Escape Text for Telegram: Escapes special characters that could break Telegram MarkdownV2 formatting, ensuring safe display of plain text.
- Validate Telegram MarkdownV2: Checks if a given text string is properly formatted according to Telegram MarkdownV2 rules, identifying errors, warnings, and suggestions.
Practical Use Cases
- Preparing user-generated content or bot messages with rich formatting compatible with Telegram.
- Sanitizing input text to prevent formatting errors or injection issues in Telegram messages.
- Validating existing Telegram MarkdownV2 content before sending to avoid message failures or rendering problems.
Properties
| Name | Meaning |
|---|---|
| Input Text | The markdown or plain text input to be processed by the node. |
| Conversion Options | Collection of options controlling conversion behavior: |
| - Preserve Line Breaks | Whether to keep line breaks (\n) in the output text. Defaults to true. |
| - Convert HTML Tags | Whether to convert HTML tags (like <b>, <i>, <u>) into Telegram MarkdownV2 equivalents. Defaults to true. |
| - Strict Mode | If enabled, the conversion fails on unsupported markdown features. Defaults to false. |
| - Auto Escape Special Characters | Automatically escapes special characters that might break Telegram formatting. Defaults to true. |
| Operation | Description |
|---|---|
| Convert to Telegram MarkdownV2 | Converts standard Markdown (and optionally HTML) to Telegram MarkdownV2 format. |
| Escape Text for Telegram | Escapes special characters in plain text for safe usage in Telegram MarkdownV2. |
| Validate Telegram MarkdownV2 | Validates if the input text conforms to Telegram MarkdownV2 formatting rules. |
Output
The node outputs JSON objects containing fields depending on the selected operation:
Convert to Telegram MarkdownV2
{ "originalText": "<input text>", "telegramMarkdown": "<converted Telegram MarkdownV2 text>", "operation": "convertToTelegramMd", "processedBy": "TechFlecks Telegram Markdown Parser" }Escape Text for Telegram
{ "originalText": "<input text>", "escapedText": "<text with escaped special characters>", "operation": "escapeForTelegram", "processedBy": "TechFlecks Telegram Markdown Parser" }Validate Telegram MarkdownV2
{ "originalText": "<input text>", "isValid": true|false, "errors": [<list of error messages>], "warnings": [<list of warning messages>], "suggestions": [<list of suggestions>], "operation": "validateTelegramMd", "processedBy": "TechFlecks Telegram Markdown Parser" }
No binary data output is produced by this node.
Dependencies
- No external API calls or services are required; all processing is done internally.
- No special environment variables or credentials are needed.
- The node depends on the
n8n-workflowpackage for error handling but otherwise is self-contained.
Troubleshooting
Common Issues
- Unmatched formatting markers: Errors like "Unmatched bold formatting" occur if Markdown symbols (
*,_, etc.) are not properly paired or escaped. - Unsupported nested formatting: Nested different formatting types (e.g., bold inside italic) may cause warnings and render incorrectly in Telegram.
- Invalid URLs in links: Links must start with
http://,https://, ortg://to be valid in Telegram MarkdownV2. - Special characters breaking formatting: Forgetting to escape special characters can cause Telegram to reject or misrender messages.
Error Messages and Resolutions
"Unknown operation: <operation>": The specified operation is not supported. Choose one of the defined operations."Unmatched <format> formatting": Ensure all formatting markers are properly paired or escaped."Found unescaped special characters": Use the "Escape Text for Telegram" operation to automatically escape these characters."Potentially invalid URL format": Verify that URLs in links use supported schemes (http,https,tg).
Enabling Auto Escape Special Characters helps prevent many common formatting errors.