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
- Formatting
- Delimiters
- Lists
- Links
Markup | Displayed text |
---|---|
\*Bold\* | Bold |
\_Italics\_ | Italics |
`Code` | Code |
Markup | Displayed text |
---|---|
First line\n---\nSecond line | First line ---- Second line |
First line\nSecond line | First line Second line |
Markup | Displayed text |
---|---|
\n* First \n* Second |
|
\n1. First\n2. Second |
|
Markup | Displayed text |
---|---|
[Our website](https://tovie.ai/) | Our website |
HTML
- Formatting
- Delimiters
- Links
Markup | Displayed text |
---|---|
<b>Bold</b> | Bold |
<i>Italics</i> | Italics |
<code>Code</code> | Code |
<u>Underline</u> | Underlined |
<strike>Strikethrough</strike> | |
<pre>Preformatted text</pre> | Preformatted text |
Markup | Displayed text |
---|---|
First line<br></br>Second line | First line Second line |
First line<br></br>----<br></br>Second line | First line ---- Second line |
Markup | Displayed text |
---|---|
<a href="https://tovie.ai/">Our website</a> | Our website |