Sending & Forwarding Messages
Part of the API Reference.
sendMessage
Future<Json> sendMessage(
Object chatId,
String text, {
String? businessConnectionId,
int? messageThreadId,
ParseMode? parseMode,
List<Json>? entities,
LinkPreviewOptions? linkPreviewOptions,
bool? disableNotification,
bool? protectContent,
bool? allowPaidBroadcast,
String? messageEffectId,
int? replyToMessageId,
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
}) async =>
Sends a text message to [chatId].
This is the most common method in the whole API. Use [parseMode] to enable Markdown/HTML formatting, [replyMarkup] to attach an inline/reply keyboard, and [replyParameters] to reply to an existing message.
forwardMessage
Future<Json> forwardMessage(
Object chatId,
Object fromChatId,
int messageId, {
int? messageThreadId,
bool? disableNotification,
bool? protectContent,
}) async =>
Forwards a single existing message from [fromChatId] to [chatId], keeping the “Forwarded from” attribution.
forwardMessages
Future<List<Json>> forwardMessages(
Object chatId,
Object fromChatId,
List<int> messageIds, {
int? messageThreadId,
bool? disableNotification,
bool? protectContent,
}) async =>
Forwards a batch of messages ([messageIds]) from [fromChatId] to [chatId] in one call.
copyMessage
Future<Json> copyMessage(
Object chatId,
Object fromChatId,
int messageId, {
int? messageThreadId,
String? caption,
ParseMode? parseMode,
List<Json>? captionEntities,
bool? showCaptionAboveMedia,
bool? disableNotification,
bool? protectContent,
bool? allowPaidBroadcast,
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
}) async =>
Copies a message from [fromChatId] to [chatId] without the “Forwarded from” header, as if you wrote it yourself. Media, captions, and reply markup are preserved.
copyMessages
Future<List<Json>> copyMessages(
Object chatId,
Object fromChatId,
List<int> messageIds, {
int? messageThreadId,
bool? disableNotification,
bool? protectContent,
bool? removeCaption,
}) async =>
Copies a batch of messages ([messageIds]) from [fromChatId] to [chatId] in one call.
sendMessageDraft
Future<bool> sendMessageDraft(
Object chatId,
int draftId, {
int? messageThreadId,
String? text,
ParseMode? parseMode,
List<Json>? entities,
}) async =>
Streams a partial message to [chatId] while it's still being generated — e.g. to show an AI response being "typed out" live. Supported only in chats with forum topic mode enabled. The streamed draft is ephemeral (a ~30-second preview); once the content is final, call [sendMessage] with the complete text to actually persist it. Re-using the same [draftId] animates the transition from the previous text.
sendRichMessage
Future<Json> sendRichMessage(
Object chatId,
Json richMessage, {
String? businessConnectionId,
int? messageThreadId,
bool? disableNotification,
bool? protectContent,
bool? allowPaidBroadcast,
String? messageEffectId,
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
}) async =>
Sends a rich message — one built from formatted text and structured
content blocks (images, lists, embeds, etc) rather than a single plain
caption. [richMessage] should be shaped like Telegram's
InputRichMessage (its blocks array and optional media); raw
[Json] is used given how many block types that structure can contain —
see https://core.telegram.org/bots/api#inputrichmessage for the shape,
or fall back to [call] directly if this typed wrapper doesn't fit.
sendRichMessageDraft
Future<bool> sendRichMessageDraft(
Object chatId,
Json richMessage, {
String? businessConnectionId,
int? messageThreadId,
ReplyParameters? replyParameters,
}) async =>
Streams a rich message to the chat progressively, the way [sendMessageDraft] streams plain text — useful for showing a rich message being "typed out" block by block. See [sendRichMessage] for the shape of [richMessage].
sendChecklist
Future<Json> sendChecklist(
String businessConnectionId,
int chatId,
InputChecklist checklist, {
bool? disableNotification,
bool? protectContent,
String? messageEffectId,
ReplyParameters? replyParameters,
InlineKeyboardMarkup? replyMarkup,
}) async =>
Sends a checklist on behalf of a connected business account.