Repository navigation
App Telegram
Telegram Notifications uses BLL decoding in message-related actions. After configuring the app and bot, enter a message such as this in a supported message field:
Today is {[ date("dddd") ]}.
You can combine text with a calculation:
The rounded result is {[ math.round(3.14159, 2) ]}.
The community list also mentions escaping Markdown characters with BLL. Escaping depends on Telegram's formatting mode, so test the final message in that mode. Never include your bot token in a message, Flow example or shared screenshot. See the Telegram topic.
The BLL supported-app list names this Telegram app. The following are adaptations for a supported message action, not separate forum screenshots:
Report at {[ date("yyyy-MM-dd HH:mm") ]}
Average temperature: {[ number(math.mean([18, 20, 22]), 1) ]}
Replace the sample readings with your numeric tags. If the formatting mode is MarkdownV2, characters such as the date's hyphens and a decimal point need escaping. Use the plain-message mode if offered by your version, or the appropriate escaping below.
To send a BLL variable without evaluating code, insert its tag in the message. In the same-name variable discussion, the stale tag belonged to a deleted Homey Logic variable, not its BLL replacement. Reselect the BLL tag rather than typing the variable's name.
The Telegram FAQ
recommends a BLL custom escaping function for parsing errors such as
can't parse entities. Its example escapes regular-expression characters;
that character set is not a complete MarkdownV2 text escaper.
This adaptation follows Telegram's
MarkdownV2 plain-text rules,
including underscore, tilde, hash, exclamation mark and backslash.
In BLL Functions, create telegramPlain and save:
(function (text) {
return String(text).replace(/[_*\[\]()~`>#+\-=|{}.!\\]/g, "\\$&");
})In a supported message field, test:
{[ telegramPlain("Sensor_A: 21.5 (OK)!") ]}
The function returns Sensor\_A: 21\.5 \(OK\)\!; Telegram displays
Sensor_A: 21.5 (OK)! as literal text. You can also format first:
{[ telegramPlain("Report at " + date("yyyy-MM-dd HH:mm")) ]}
This helper is for ordinary text outside code blocks and link destinations. Those contexts have different escaping rules. Escape once, at the output boundary; escaping already escaped text adds extra backslashes. To preserve intentional Markdown, escape only the dynamic plain-text segments, not the complete markup.
The FAQ also suggests selecting HTML mode. HTML still requires escaping
dynamic text containing &, < or >. An adaptation for a function
named telegramHtml is:
(function (text) {
return String(text).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
})For example:
<b>Status:</b> {[ telegramHtml("Kitchen < 20 & window open") ]}
The static <b> tag supplies formatting, while the dynamic part remains
literal text. Do not use the MarkdownV2 helper in HTML mode, or this HTML
text helper for arbitrary HTML attributes.
Adapt the random greeting example in a supported message field:
{[ _.sample(["Good night", "Sleep well", "Sweet dreams"]) ]}
Evaluate once and reuse the result if several recipients should receive the same selection. BLL decoding does not authorize Telegram users or protect secrets: configure the app's bot registration controls separately.
Support development - If Better Logic Library is useful to you, you can support its
continued development through GitHub Sponsors,
Patreon,
PayPal, or
bunq.
Thank you!