A bot works with a fixed greeting but fails when a customer supplies a product code. Another delivers the answer while showing every formatting marker literally. Before changing the answering model, inspect how the outgoing message is constructed.
This guide covers ordinary text messages in menus, FAQs, task tools, and query results. Its order-style notices are fictional examples, not payment verification or an implemented order integration. Correct business content and correct presentation need separate checks.
Start with the sentence the user should receive
Suppose a notice must preserve the product code A_B, a quantity comparison, and an ampersand in a comment. These are data. Removing their punctuation to make bold text work would change the result.
Keep two clear layers: the complete intended text, and which spans should become emphasis, code, or links. Write the plain-text expectation first, then verify that formatting preserves it.
Treat user-supplied values as display data by default. A star or tag in a comment should not become part of your template. If users are intentionally allowed to submit styled content, give that input its own supported-format policy and failure behavior.
Choose one construction path
The grammY ParseMode reference describes Markdown-style formatting, HTML-style formatting, and explicit text entities. These are different representations; changing the mode name does not convert an arbitrary string between them.
For a small tool, plain text with line breaks, numbering, and complete addresses may be sufficient. Add styling through one explicit path:
- A parse mode. The template owns the markup. Dynamic values need treatment appropriate to the selected mode and their position. Telegram HTML supports a defined set of tags; MarkdownV2 has different escaping rules for ordinary text, code, and link destinations. Website HTML and arbitrary Markdown are not ready-to-send inputs.
- Text entities. Keep markup out of the body and separately describe each span's type, offset, and length. Positions must remain accurate when the text changes.
Ask the builder which path it uses and check every send and edit entry point against that choice. Processing an already processed field again can introduce visible backslashes or encoded text.
Why emphasis can shift after an emoji
Telegram's official message-entity documentation specifies UTF-16 code units for entity offsets and lengths. For the sample 📦 Done, bolding only Done requires offset 3 and length 4: the box occupies two units and the space one.
Visible character counts are therefore a poor implementation specification. Include Chinese text, supplementary-plane characters, combining marks, and composite emoji in the acceptance set. Display width is not an entity coordinate system either.
The python-telegram-bot MessageEntity reference provides conversion and shifting helpers. Those are capabilities of that Python library, not proof that your hosting platform includes it. Different implementations must still satisfy the same positioning rule.
You can test this without programming: require only Done to be bold, replace the opening emoji, then add a Chinese prefix. Emphasis should remain on the intended word without losing text.
Rebuild formatting after changes
Replacing a status label or adding a timestamp can move every later span. When using explicit entities, a useful design is to regenerate the full text and its entities from current data rather than patch old offsets with guessed adjustments.
The grammY parse-mode plugin guide demonstrates declarative composition that manages entity positions. The useful design idea is to build text and styling together. It is not an instruction to install the package in BotFatherV2.
If a long reply needs several messages, plan complete paragraphs or business blocks first, then rebuild formatting for each actual outgoing text. Do not cut mechanically inside markup, a code span, or an emoji. Entity positions for the second message belong to that message's body, not the original combined document. Verify length limits for the chosen method and current SDK; text messages, captions, and other message types should not share an assumed limit.
If content must be shortened, disclose the truncation and provide the agreed complete-reading route. Do not invent a “read full answer” destination that does not exist.
A formatting rejection is not every sending failure
A proposed fallback policy should distinguish a definite formatting rejection, an unknown network outcome, and a reply that was partly delivered across several messages. Only consider resending the same text without styling when the failed message is known to have been rejected for formatting. An arbitrary exception should not trigger retransmission of the entire reply.
If plain-text fallback is used, make it visible to maintainers and retain limited diagnostic evidence such as template version, failure category, and sending stage. Do not permanently log private conversations or tokens just to debug styling. Readable fallback is useful, but it is not a passed formatting check.
This is a design recommendation, not an automatic Telegram retry guarantee. See the separate webhook and idempotency checklist for delivery uncertainty and recovery. Here, the focus is constructing the formatted result correctly.
A brief to give an AI bot builder
Standardize replies for my Telegram menu bot. Preserve a complete plain-text body, then use a parse mode or explicit entities supported by the current SDK. Display user-entered product codes, comments, and URLs as data rather than formatting instructions. Use the same construction rule for sending and editing. For entities, calculate UTF-16 positions and regenerate them whenever a prefix or body changes. The first version needs only bold headings and line breaks; unsupported styles should remain readable text. Split at complete structural boundaries and generate formatting for each part separately. Distinguish formatting rejection, unknown network outcomes, and partial delivery. Do not resend everything after a generic error. Plain-text fallback must preserve meaning and be recognizable by maintainers. Do not add unsupported dependencies or claim that real Telegram acceptance checks have already passed.
No runtime language-model call is required. A fixed FAQ, menu, or status notice can have the same formatting failures. Start with deterministic test text before connecting actual business data.
Eight acceptance cases before release
- Chinese, English, and line breaks: preserve all text and emphasize only the intended heading.
- Product codes, multiplication signs, parentheses, hyphens, and backslashes: display dynamic values without accidental styling.
- Less-than, greater-than, and ampersand symbols: preserve content without interpreting it as template markup or exposing extra encoding.
📦 Done, Chinese prefixes, and composite emoji: keep entities aligned and avoid broken symbols.- Link labels and actual destinations: inspect both, not just the presence of colored text.
- Status edits and added prefixes: build emphasis for the new body rather than reusing old coordinates.
- Multiple messages: keep each part structurally complete and in order; handle truncation or full-reading links as specified.
- Definite formatting errors and unknown network outcomes: handle them separately, identify fallback, and avoid duplicating already delivered parts.
Record expected text, actual rendering, template version, and outcome. A screenshot demonstrates appearance; it does not replace checking body text, link destinations, or actual API results.
Applying this in BotFatherV2
BotFatherV2 supports creating and modifying Telegram bots through AI conversation. These rules can become requirements and post-release acceptance checks. Its public development documentation describes a fixed SDK surface, excludes arbitrary npm modules and Node/Bun runtime APIs, and keeps new paid runtime AI integrations outside the initial scope.
Ask the builder to confirm available message fields and sending methods before implementing the smallest format. The grammY and Python helpers cited here are explanatory examples, not installable BotFatherV2 components. If the necessary fields cannot be confirmed, use plain text first rather than promising a complete converter.
Create a small menu prototype with the sample inputs, review generation and validation results, and run the checks in Telegram. BotFatherV2 is independent and unaffiliated with Telegram's official BotFather.
Sources and date
- Telegram, Styled text with message entities: entity coordinates and UTF-16 definitions.
- grammY project, ParseMode and Parse Mode Plugin: parsing rules and entity-composition examples.
- python-telegram-bot project, MessageEntity, v22.8: entity-position helpers.
These are maintained primary documents with no single page publication date. They were checked on November 26, 2026. The brief, fallback policy, and acceptance cases are original design recommendations, not a list of automatic product features.