Skip to main content

Markup for Telegram bot replies

You can use the Markdown or HTML markup to change the appearance of the chatbot messages in Telegram.

Apply markup to specific messages

To apply markup to a specific message, include the markup key in a bot answer of the text type. Available values for the markup key are html and markdown.

script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "text",
"text": "HTML — <i>hypertext</i> markup language for web pages.",
"markup": "html"
});
tip

To learn several more ways to use HTML markup, please refer to the HTML markup page.

Apply markup to all bot replies

To enable markup for the whole script, pass the $context function with markup parameters to the postProcess handler:

bind("postProcess", function(context) {
if (context.request.channelType === "telegram") {
context.response.replies.forEach(function(reply) {
if (reply.type === "text") {
reply.markup = "markdown"; // Acceptable values: "html", "markdown"
}
});
}
});

All bot replies in Telegram are injected with a property indicating that the replies are marked up.

Markup syntax

Markdown

MarkupDisplayed text
\*Bold\*Bold
\_Italics\_Italics
`Code`Code

HTML

MarkupDisplayed text
<b>Bold</b>Bold
<i>Italics</i>Italics
<code>Code</code>Code
<u>Underline</u>Underlined
<strike>Strikethrough</strike>Strikethrough
<pre>Preformatted text</pre>
Preformatted text