Skip to content

Messages ​

FunctionWhat 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 ​

mzs
include bot
bot.say("Order **accepted**")
bot.say("Number: ${$message.captures(/\d+/)[0]}")
text
Order **accepted**
Number: 10452

An empty string (or only spaces) isn't sent; bot.say returns nil. A non-string becomes a string:

mzs
include bot
bot.say("   ")  # → nil
bot.say(42) != nil  # → true

Up 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.

mzs
include bot
items = ["Kettle — 2990 ₽", "Mug ×2 — 500 ₽"]
bot.say("**Your order:**\n" + items.map { "• ${it}" }.join("\n"))
text
**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.

mzs
include bot
id = bot.say("Looking up the order…")
bot.edit(id, "Order 10452: **on its way**")  # → true
text
Looking 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().

mzs
include bot
bot.edit(bot.get("menu_msg"), "You chose: ${$message}")

Up to 10 edits per run, text up to 4000 bytes.

bot.delete ​

mzs
include bot
hold = bot.say("One moment…")
bot.say("Order 10452 was shipped yesterday.")
bot.delete(hold)  # → true
text
One 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:

mzs
include bot
bot.say("One moment…")
bot.delete()  # → true
bot.delete()  # → false

Up 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).

mzs
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
text
📎 price.pdf — https://cdn.example.com/price.pdf
📎 Invoice-10452.pdf — https://cdn.example.com/inv/10452.pdf
Your **invoice**
Argument
urlonly http:// or https:// with a host, up to 4000 bytes
captiona caption, markdown, up to 4000 bytes; nil or "" — none
namethe 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.

mzs
include bot
bot.file("ftp://files.example.com/price.pdf")
text
is not a link to a file