Messages
| Function | What it does |
|---|---|
bot.say(text) | a message to the visitor → its id |
bot.edit(text) | edits the bot's last message → true/false |
bot.edit(id, text) | edits the message with this id → true/false |
bot.delete() | deletes the bot's last message → true/false |
bot.delete(id) | deletes the message with this id → true/false |
bot.file(url, caption?, name?) | a file by its link → the message id |
bot.say
include bot
bot.say("Order **accepted**")
bot.say("Number: ${$message.captures(/\d+/)[0]}")Order **accepted**
Number: 10452An empty string (or only spaces) isn't sent; bot.say returns nil. A non-string becomes a string:
include bot
bot.say(" ") # → nil
bot.say(42) != nil # → trueUp to 10 messages per run (together with bot.file), each up to 4000 bytes (≈ 2000 Cyrillic letters).
Markdown
The text of bot.say, bot.edit and the caption of bot.file are markdown: **bold**, *italic*, [link](https://…), \n — a new line.
include bot
items = ["Kettle — 2990 ₽", "Mug ×2 — 500 ₽"]
bot.say("**Your order:**\n" + items.map { "• ${it}" }.join("\n"))**Your order:**
• Kettle — 2990 ₽
• Mug ×2 — 500 ₽HTML doesn't work — it shows as text. javascript:, data:, vbscript:, file: links are disabled: the text may come from the visitor or someone else's API.
bot.edit
Edits a message the visitor has already got (widget and Telegram). Without an id — the bot's last message, including an AI answer or another block's.
include bot
id = bot.say("Looking up the order…")
bot.edit(id, "Order 10452: **on its way**") # → trueLooking up the order…
✎ Order 10452: **on its way**false — nothing to edit: no id given and no last message. An empty text, nil or a non-id in place of the id is an error.
An id lives as long as the dialogue: save it with bot.set and edit in the next run — after bot.wait().
include bot
bot.edit(bot.get("menu_msg"), "You chose: ${$message}")Up to 10 edits per run, text up to 4000 bytes.
bot.delete
include bot
hold = bot.say("One moment…")
bot.say("Order 10452 was shipped yesterday.")
bot.delete(hold) # → trueOne moment…
Order 10452 was shipped yesterday.
✕ One moment…bot.delete() without an id deletes the bot's last message; after that there is no "last" until the next bot.say, and bot.delete() returns false:
include bot
bot.say("One moment…")
bot.delete() # → true
bot.delete() # → falseUp to 10 deletes per run, counted apart from edits.
bot.file
Sends a file by its link, like the File block («Файл»): an attachment in the widget, a document in Telegram. The file itself lives anywhere on the internet (S3, a CDN, a website).
include bot
bot.file("https://cdn.example.com/price.pdf")
id = bot.file("https://cdn.example.com/inv/10452.pdf", "Your **invoice**", "Invoice-10452.pdf")
id != nil # → true📎 price.pdf — https://cdn.example.com/price.pdf
📎 Invoice-10452.pdf — https://cdn.example.com/inv/10452.pdf
Your **invoice**| Argument | |
|---|---|
url | only http:// or https:// with a host, up to 4000 bytes |
caption | a caption, markdown, up to 4000 bytes; nil or "" — none |
name | the file name, up to 200 characters, no /; by default — from the link |
A file is one of the run's 10 messages. bot.delete(id) takes its id, but a file doesn't become the "last message" for bot.edit() and bot.delete() without an id.
include bot
bot.file("ftp://files.example.com/price.pdf")is not a link to a file