To send bold:
parse_mode
to markdown
and send *bold*
parse_mode
to html
and send <b>bold</b>
To send italic:
parse_mode
to markdown
and send _italic_
parse_mode
to html
and send <i>italic</i>
If you are using PHP you can use this, and I'm sure it's almost similar in other languages as well
$WebsiteURL = "https://api.telegram.org/bot".$BotToken;
$text = "<b>This</b> <i>is some Text</i>";
$Update = file_get_contents($WebsiteURL."/sendMessage?chat_id=$chat_id&text=$text&parse_mode=html);
echo $Update;
Here is the list of all tags that you can use
<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<a href="http://www.example.com/">inline URL</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
According to the docs you can set the parse_mode
field to:
The Markdown mode still works but it's now considered a legacy one. Use MarkdownV2 instead.
You can pass the parse_mode
parameter like this:
https://api.telegram.org/bot[yourBotKey]/sendMessage?chat_id=[yourChatId]&parse_mode=MarkdownV2&text=[yourMessage]
For bold and italic using MarkdownV2:
*bold text*
_italic text_
And for HTML:
<b>bold</b> or <strong>bold</strong>
<i>italic</I> or <em>italic</em>
Make sure to encode your query-string parameters regardless the format you pick. For example:
val message = "*bold text*";
val encodedMsg = URLEncoder.encode(message, "UTF-8");
var message = "*bold text*"
var encodedMsg = encodeURIComponent(message)
$message = "*bold text*";
$encodedMsg = urlencode($message);
So when sending the message to telegram you use:
$token = <Enter Your Token Here>
$url = "https://api.telegram.org/bot".$token;
$chat_id = <The Chat Id Goes Here>;
$test = <Message goes Here>;
//sending Message normally without styling
$response = file_get_content($url."\sendMessage?chat_id=$chat_id&text=$text");
If our message has html tags in it we add "parse_mode" so that our url becomes:
$response = file_get_content($url."\sendMessage?chat_id=$chat_id&text=$text&parse_mode=html")
parse mode can be "HTML" or "markdown"
For italic you can use the 'i' tag, for bold try the 'b' tag
<i> italic </i>
<b> bold </b>
To Send bold,italic,fixed width code you can use this :
# Sending a HTML formatted message
bot.send_message(chat_id=@yourchannelname,
text="*boldtext* _italictext_ `fixed width font` [link] (http://google.com).",
parse_mode=telegram.ParseMode.MARKDOWN)
make sure you have enabled the bot as your admin .Then only it can send message
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With