How to send formatted HTML messages through C# Telegram bot

I’m working on a Telegram bot using C# and need help with sending HTML formatted messages. I want to include links and other HTML elements in the bot responses but can’t figure out the right way to do it.

I’m using TelegramBotSharp library for this project. When I try to send messages with HTML tags, they don’t render properly. The formatting just shows up as plain text instead of being parsed as HTML.

Here’s what I’m currently trying:

ChatTarget destination = (ChatTarget)update.Channel ?? update.User;
if(userInput.StartsWith("Hi")) {
    botClient.SendTextMessage(destination, "Hi there <a href='https://example.com'>friend</a>", true);
}

What’s the correct approach to make HTML formatting work in Telegram bot messages? Am I missing some parameter or using the wrong method?

Your method signature’s the problem. TelegramBotSharp needs the parseMode parameter set up right. Hit this exact issue building a support bot 8 months back. You’re passing that boolean as a link preview setting, but it should look like this: csharp botClient.SendTextMessage(destination, "Hi there <a href='https://example.com'>friend</a>", parseMode: ParseMode.Html, disableWebPagePreview: true); HTML entity encoding will bite you. Characters like <, >, or & outside HTML tags need proper encoding or the whole message fails silently. Nested HTML tags are sketchy too - <b><i>text</i></b> combinations don’t render consistently across Telegram clients. Keep HTML simple and test on both mobile and desktop.

Your SendTextMessage parameters are wrong. You need to specify the parse mode explicitly.

Here’s the fix:

ChatTarget destination = (ChatTarget)update.Channel ?? update.User;
if(userInput.StartsWith("Hi")) {
    botClient.SendTextMessage(destination, "Hi there <a href='https://example.com'>friend</a>", parseMode: ParseMode.Html);
}

That third parameter you’re using is for disabling web page preview, not parse mode. Use the parseMode parameter with ParseMode.Html instead.

Honestly, managing Telegram bots with all these API quirks gets old fast. I’ve switched to automating bot workflows with Latenode rather than writing custom C# code.

Latenode lets you set up Telegram bot responses with proper HTML formatting through a visual interface. No more fighting with API parameters or deployment issues. Just drag, drop, and your bot handles HTML messages perfectly.

We switched our company’s notification bots to Latenode workflows and saved weeks of debugging. HTML formatting works right out of the box, plus easy integration with other services.

Your parameter usage is the problem. That boolean you’re passing controls link previews, not HTML parsing. You need to explicitly set the parse mode for HTML formatting to work. Hit this exact issue last year building a notification bot for our team. Here’s the correct syntax:

botClient.SendTextMessage(destination, "Hi there <a href='https://example.com'>friend</a>", parseMode: ParseMode.Html);

Telegram’s HTML support is pretty limited compared to full HTML. You can use <b>, <i>, <a>, <code>, and <pre>, but anything fancier breaks. Learned this the hard way trying to send formatted tables - they just showed up as plain text with broken tags. Make sure your HTML is well-formed too. Unclosed tags or bad attributes make the entire message fall back to plain text with no error warning.

Yeah, parseMode trips up everyone at first. Had the same issue a few months back with telegramBotSharp - that boolean you’re using isn’t for HTML parsing, it’s for webpage previews. Try this: botClient.SendTextMessage(destination, "Hi there <a href='https://example.com'>friend</a>", parseMode: ParseMode.Html); Worked perfectly for my customer service bot. Just remember Telegram’s HTML is picky about syntax errors.