Messaging
send.* sends messages, edit.* updates them, and delete removes them.
send.*β
All send.* variants accept an optional chat_id (target a specific chat) and most accept reply_markup (an inline or reply keyboard). RichText parameters support parse_mode: "Markdown" | "HTML".
send.textβ
send.text(text: "Hello!", parse_mode: "Markdown", reply_to: message.message_id)
| Param | Type | Notes |
|---|---|---|
text! | RichText | The message body |
chat_id | ChatId | Target chat (default: current) |
parse_mode | String | "Markdown", "HTML", or "" |
reply_markup | ReplyMarkup | Inline or reply keyboard |
reply_to | MessageRef | Attach as a reply |
Mediaβ
| Variant | Required | Other params |
|---|---|---|
send.photo | file! | caption, chat_id |
send.video | file! | caption, chat_id |
send.document | file! | caption, chat_id |
send.audio | file! | caption, duration, performer, title, parse_mode, reply_markup |
send.voice | file! | caption, duration, parse_mode, reply_markup |
send.animation | file! | caption, has_spoiler, parse_mode, reply_markup |
send.video_note | file! | duration, length, reply_markup |
send.sticker | file! | reply_markup |
send.media_group | media! (Array) | chat_id |
send.photo(file: "https://example.com/cat.jpg", caption: "π±")
send.document(file: "https://example.com/report.pdf", caption: "Q3 report")
send.media_group(media: [
{ type: "photo", media: "https://example.com/1.jpg" },
{ type: "photo", media: "https://example.com/2.jpg" }
])
Location, venue, contactβ
send.location(latitude: 51.5, longitude: -0.12)
send.venue(latitude: 51.5, longitude: -0.12, title: "Big Ben", address: "Westminster")
send.contact(first_name: "Sam", phone_number: "+15551234567")
| Variant | Required |
|---|---|
send.location | latitude!, longitude! (opt: live_period, horizontal_accuracy) |
send.venue | latitude!, longitude!, title!, address! |
send.contact | first_name!, phone_number! (opt: last_name, vcard) |
Poll and diceβ
send.poll(question: "Best language?", options: ["Botgami", "Other"], is_anonymous: false)
send.dice(emoji: "π²")
| Variant | Required | Notes |
|---|---|---|
send.poll | question!, options! | poll_type, is_anonymous, allows_multiple_answers |
send.dice | β | emoji (π² π― π β¦) |
See Polls, forms & menus for richer poll usage.
send.chat_actionβ
Show a "typingβ¦" style indicator:
send.chat_action(action: "typing")
send.answer_callbackβ
Show a toast or alert in response to a button tap (the callback is auto-answered anyway β use this only when you want a visible toast):
send.answer_callback(text: "Added to cart!", show_alert: false)
send.invoice (Telegram Stars)β
Send a Telegram Stars invoice. prices is an array of { label, amount } where amount is the star count, and currency is "XTR". The buyer's tap is handled by the on pre_checkout and on successful_payment triggers.
send.invoice(
"Pro Plan",
"Unlock all premium features",
"pro-plan", // payload β echoed back to your payment flows
[{ label: "Pro Plan", amount: 250 }], // 250 β
currency: "XTR"
)
| Param | Type | Notes |
|---|---|---|
title! | String | Invoice title |
description! | String | Invoice description |
payload! | String | Your own routing id, echoed to pre_checkout.invoice_payload / payment.invoice_payload |
prices! | Array | [{ label, amount }] β amount is the star count |
currency | String | "XTR" for Stars |
chat_id | ChatId | Target chat (default: current) |
reply_markup | ReplyMarkup | Optional keyboard |
edit.*β
Update a message you already sent. Inside a callback flow, message: callback.message targets the message the button was attached to.
edit.text(message: callback.message, text: "β
Updated!", parse_mode: "Markdown")
edit.caption(message: callback.message, caption: "New caption")
// Attach a named menu (recommended):
edit.reply_markup(message: callback.message, reply_markup: shopMenu("all"))
// Or replace with a raw inline keyboard:
edit.reply_markup(message: callback.message, reply_markup: { inline_keyboard: [[{ text: "OK", callback_data: "ok" }]] })
| Variant | Required |
|---|---|
edit.text | message!, text! (opt: parse_mode, reply_markup) |
edit.caption | message!, caption! (opt: parse_mode, reply_markup) |
edit.reply_markup | message!, reply_markup! |
deleteβ
delete(message: callback.message)
Removes a previously sent message.
reactβ
Set or clear the bot's emoji reaction on a message. Pass an empty emoji ("") to clear it.
react(message.message_id, "π") // set
react(message.message_id, "") // clear
| Param | Type | Notes |
|---|---|---|
message_id! | Number | The message to react to |
emoji! | String | The reaction emoji (empty string clears) |
chat_id | ChatId | Target chat (default: current) |
See the on reaction trigger to respond when users react.
answer_inlineβ
Respond to an on inline_query with a list of article results.
answer_inline(inline.id, [
{ id: "tip-1", title: "Quick tip", text: "Use /help to see commands.", description: "Bot basics" },
{ id: "tip-2", title: "Pricing", text: "Pro is 250 β/month.", description: "Plans" }
])
| Param | Type | Notes |
|---|---|---|
query_id! | String | The inline query id (inline.id) |
results! | Array | [{ id, title, text, description }] |
msg.* β pin, unpin, forward, copyβ
Manage existing messages by id. Each takes an optional chat_id (defaults to the current chat). Network actions can fail β attach on error => { }.
msg.pin(message.message_id)
msg.unpin(message.message_id) // omit id to unpin all
msg.forward(from_chat_id, message_id, chat_id: target_chat)
msg.copy(from_chat_id, message_id, chat_id: target_chat, caption: "Reposted")
| Variant | Params |
|---|---|
msg.pin | message_id!, chat_id |
msg.unpin | message_id (omit to unpin all), chat_id |
msg.forward | from_chat_id!, message_id!, chat_id |
msg.copy | from_chat_id!, message_id!, chat_id, caption |
msg.forward keeps the "forwarded from" attribution; msg.copy reposts without it. See Groups & admin for moderation uses.