Skip to content

GramIO API Reference / @gramio/contexts/dist / ChatJoinRequestContext

Class: ChatJoinRequestContext<Bot>

Defined in: contexts/index.d.ts:6130

Represents a join request sent to a chat.

Documentation

Extends

Type Parameters

Type Parameter
Bot extends BotLike

Constructors

Constructor

new ChatJoinRequestContext<Bot>(options): ChatJoinRequestContext<Bot>

Defined in: contexts/index.d.ts:6133

Parameters

ParameterType
optionsChatJoinRequestContextOptions<Bot>

Returns

ChatJoinRequestContext<Bot>

Overrides

Context.constructor


Constructor

new ChatJoinRequestContext(...args): ChatJoinRequestContext

Defined in: contexts/index.d.ts:6130

Parameters

ParameterType
...argsany[]

Returns

ChatJoinRequestContext

Overrides

Context<Bot>.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
botpublicBot-Context.botcontexts/index.d.ts:5240
isTopicMessagepublic() => boolean-SendMixin.isTopicMessagecontexts/index.d.ts:5458
payloadpublicTelegramChatJoinRequestThe raw data that is used for this ContextChatJoinRequest.payloadcontexts/index.d.ts:6132
update?publicTelegramUpdate-Context.updatecontexts/index.d.ts:5242
updateId?publicnumber-Context.updateIdcontexts/index.d.ts:5241
updateTypeprotectedUpdateName-Context.updateTypecontexts/index.d.ts:5243

Accessors

[toStringTag]

Get Signature

get [toStringTag](): string

Defined in: contexts/index.d.ts:5246

MDN

Returns

string

Inherited from

Context.[toStringTag]


bio

Get Signature

get bio(): string

Defined in: contexts/index.d.ts:4229

Bio of the user

Returns

string

Inherited from

ChatJoinRequest.bio


businessConnectionId

Get Signature

get businessConnectionId(): string

Defined in: contexts/index.d.ts:5279

Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.

Returns

string

Inherited from

TargetMixin.businessConnectionId


chat

Get Signature

get chat(): Chat

Defined in: contexts/index.d.ts:4221

Chat to which the request was sent

Returns

Chat

Inherited from

ChatJoinRequest.chat


chatId

Get Signature

get chatId(): number

Defined in: contexts/index.d.ts:5277

Chat ID

Returns

number

Inherited from

TargetMixin.chatId


chatType

Get Signature

get chatType(): TelegramChatType

Defined in: contexts/index.d.ts:5281

Chat type

Returns

TelegramChatType

Inherited from

TargetMixin.chatType


date

Get Signature

get date(): number

Defined in: contexts/index.d.ts:4227

Date the request was sent in Unix time

Returns

number

Inherited from

ChatJoinRequest.date


from

Get Signature

get from(): User

Defined in: contexts/index.d.ts:4223

User that sent the join request

Returns

User

Inherited from

ChatJoinRequest.from


Get Signature

get inviteLink(): ChatInviteLink

Defined in: contexts/index.d.ts:4231

Chat invite link that was used by the user to send the join request

Returns

ChatInviteLink

Inherited from

ChatJoinRequest.inviteLink


queryId

Get Signature

get queryId(): string

Defined in: contexts/index.d.ts:4237

Identifier of the join request query. If present, then the bot must call sendChatJoinRequestWebApp or directly call answerChatJoinRequestQuery within 10 seconds.

Returns

string

Inherited from

ChatJoinRequest.queryId


senderBoostCount

Get Signature

get senderBoostCount(): number

Defined in: contexts/index.d.ts:5271

Optional. If the sender of the message boosted the chat, the number of boosts added by the user

Returns

number

Inherited from

TargetMixin.senderBoostCount


senderChat

Get Signature

get senderChat(): Chat

Defined in: contexts/index.d.ts:5267

Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The supergroup itself for messages from anonymous group administrators. The linked channel for messages automatically forwarded to the discussion group

Returns

Chat

Inherited from

TargetMixin.senderChat


senderId

Get Signature

get senderId(): number

Defined in: contexts/index.d.ts:5275

Sender's ID

Returns

number

Inherited from

TargetMixin.senderId


threadId

Get Signature

get threadId(): number

Defined in: contexts/index.d.ts:5457

Returns

number

Inherited from

SendMixin.threadId


userChatId

Get Signature

get userChatId(): number

Defined in: contexts/index.d.ts:4225

Identifier of a private chat with the user who sent the join request. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user.

Returns

number

Inherited from

ChatJoinRequest.userChatId

Methods

answerQuery()

answerQuery(result): Promise<true>

Defined in: contexts/index.d.ts:6144

Processes the received chat join request query.

Requires query_id to be present on the join request — the bot must respond within 10 seconds.

Parameters

ParameterType
resultAnswerChatJoinRequestQueryResult

Returns

Promise<true>


approve()

approve(): Promise<true>

Defined in: contexts/index.d.ts:6135

Approves chat join request

Returns

Promise<true>


clone()

clone(options?): ChatJoinRequestContext

Defined in: contexts/index.d.ts:5935

Parameters

ParameterType
options?ChatJoinRequestContextOptions

Returns

ChatJoinRequestContext

Inherited from

CloneMixin.clone


createActionController()

createActionController(action, params?): ChatActionController<Bot>

Defined in: contexts/index.d.ts:5924

Parameters

ParameterType
actionSendChatActionAction
params?Pick<SendChatActionParams, "business_connection_id" | "message_thread_id"> & object & CreateActionControllerParams

Returns

ChatActionController<Bot>

Deprecated

Creates a controller that when start()ed executes sendChatAction(action) every interval milliseconds until stop()ped

Inherited from

ChatActionMixin.createActionController


createInviteLink(params?): Promise<TelegramChatInviteLink>

Defined in: contexts/index.d.ts:5772

Creates an additional invite link

Parameters

ParameterType
params?Optional<CreateChatInviteLinkParams, "chat_id">

Returns

Promise<TelegramChatInviteLink>

Inherited from

ChatInviteControlMixin.createInviteLink


decline()

decline(): Promise<true>

Defined in: contexts/index.d.ts:6137

Declines chat join request

Returns

Promise<true>


editInviteLink(link, params?): Promise<TelegramChatInviteLink>

Defined in: contexts/index.d.ts:5774

Edits non-primary invite link created by the bot

Parameters

ParameterType
linkstring
params?Optional<EditChatInviteLinkParams, "chat_id" | "invite_link">

Returns

Promise<TelegramChatInviteLink>

Inherited from

ChatInviteControlMixin.editInviteLink


exportInviteLink(params?): Promise<string>

Defined in: contexts/index.d.ts:5770

Generates new primary invite link

Parameters

ParameterType
params?Optional<ExportChatInviteLinkParams, "chat_id">

Returns

Promise<string>

Inherited from

ChatInviteControlMixin.exportInviteLink


getChatBoosts()

getChatBoosts(userId): Promise<TelegramUserChatBoosts>

Defined in: contexts/index.d.ts:5586

Returns chat boosts by the user

Parameters

ParameterType
userIdnumber

Returns

Promise<TelegramUserChatBoosts>

Inherited from

SendMixin.getChatBoosts


hasFrom()

hasFrom(): this is Require<ChatJoinRequestContext<Bot>, "from" | "senderId">

Defined in: contexts/index.d.ts:5256

Checks if the instance has from and senderId properties

Returns

this is Require<ChatJoinRequestContext<Bot>, "from" | "senderId">

Inherited from

TargetMixin.hasFrom


hasSenderChat()

hasSenderChat(): this is Require<ChatJoinRequestContext<Bot>, "senderChat">

Defined in: contexts/index.d.ts:5260

Checks if the instance has senderChat property

Returns

this is Require<ChatJoinRequestContext<Bot>, "senderChat">

Inherited from

TargetMixin.hasSenderChat


is()

is<T>(rawTypes): this is InstanceType<ContextsMapping<Bot>[T]> & GetDerives<Bot, T> & (IsAny<Bot["__Derives"]> extends true ? {} : Bot["__Derives"] extends {} ? Bot["__Derives"]["global"] & Bot["__Derives"][T] : {})

Defined in: contexts/index.d.ts:5249

Type Parameters

Type Parameter
T extends UpdateName

Parameters

ParameterType
rawTypesMaybeArray<SoftString<T>>

Returns

this is InstanceType<ContextsMapping<Bot>[T]> & GetDerives<Bot, T> & (IsAny<Bot["__Derives"]> extends true ? {} : Bot["__Derives"] extends {} ? Bot["__Derives"]["global"] & Bot["__Derives"][T] : {})

Inherited from

Context.is


isChannel()

isChannel(): this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Channel>

Defined in: contexts/index.d.ts:5289

Is this chat a channel?

Returns

this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Channel>

Inherited from

TargetMixin.isChannel


isGroup()

isGroup(): this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Group>

Defined in: contexts/index.d.ts:5285

Is this chat a group?

Returns

this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Group>

Inherited from

TargetMixin.isGroup


isPM()

isPM(): this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Private>

Defined in: contexts/index.d.ts:5283

Is this chat a private one?

Returns

this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Private>

Inherited from

TargetMixin.isPM


isSupergroup()

isSupergroup(): this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Supergroup>

Defined in: contexts/index.d.ts:5287

Is this chat a supergroup?

Returns

this is RequireValue<ChatJoinRequestContext<Bot>, "chatType", Supergroup>

Inherited from

TargetMixin.isSupergroup


revokeInviteLink(link, params?): Promise<TelegramChatInviteLink>

Defined in: contexts/index.d.ts:5776

Revokes an invite link generated by a bot

Parameters

ParameterType
linkstring
params?Optional<RevokeChatInviteLinkParams, "chat_id" | "invite_link">

Returns

Promise<TelegramChatInviteLink>

Inherited from

ChatInviteControlMixin.revokeInviteLink


send()

send(text, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5469

Sends message to current chat.

Pass a branded @gramio/format rich value (Markdown RichString or a native structured block/message from @gramio/format/rich) and it is sent via sendRichMessage instead — bot.api.* stays 1:1; the method is chosen here.

Parameters

ParameterType
textstring | { toString: string; } | RichStringLike
params?Optional<SendMessageParams, "text" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.send


sendAnimation()

sendAnimation(animation, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5517

Sends animation to current chat

Parameters

ParameterType
animationstring | Blob
params?Optional<SendAnimationParams, "animation" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendAnimation


sendAudio()

sendAudio(audio, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5513

Sends audio to current chat

Parameters

ParameterType
audiostring | Blob
params?Optional<SendAudioParams, "audio" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendAudio


sendChatAction()

sendChatAction(action, params?): Promise<true>

Defined in: contexts/index.d.ts:5541

Sends chat action to current chat

Parameters

ParameterType
actionSendChatActionAction
params?Optional<SendChatActionParams, "chat_id" | "action">

Returns

Promise<true>

Inherited from

SendMixin.sendChatAction


sendChecklist()

sendChecklist(params): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5533

Sends checklist to current chat

Parameters

ParameterType
paramsOptional<SendChecklistParams, "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendChecklist


sendContact()

sendContact(params): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5529

Sends contact to current chat

Parameters

ParameterType
paramsOptional<SendContactParams, "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendContact


sendDice()

sendDice(emoji, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5543

Sends dice

Parameters

ParameterType
emojiSendDiceEmoji
params?Partial<SendDiceParams>

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendDice


sendDocument()

sendDocument(document, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5511

Sends document to current chat

Parameters

ParameterType
documentstring | Blob
params?Optional<SendDocumentParams, "document" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendDocument


sendInvoice()

sendInvoice(params): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5525

Sends invoice to current user

Parameters

ParameterType
paramsOptional<SendInvoiceParams, "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendInvoice


sendLivePhoto()

sendLivePhoto(livePhoto, photo, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5509

Sends live photo to current chat

Parameters

ParameterType
livePhotostring | Blob
photostring | Blob
params?Optional<SendLivePhotoParams, "photo" | "live_photo" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendLivePhoto


sendLocation()

sendLocation(latitude, longitude, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5523

Sends location to current chat

Parameters

ParameterType
latitudenumber
longitudenumber
params?Optional<SendLocationParams, "chat_id" | "latitude" | "longitude">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendLocation


sendMedia()

sendMedia<T>(query): ReturnType<T extends "animation" ? (animation, params?) => Promise<MessageContext<Bot>> : T extends "audio" ? (audio, params?) => Promise<MessageContext<Bot>> : T extends "document" ? (document, params?) => Promise<MessageContext<Bot>> : T extends "photo" ? (photo, params?) => Promise<MessageContext<Bot>> : T extends "sticker" ? (sticker, params?) => Promise<MessageContext<Bot>> : T extends "video_note" ? (videoNote, params?) => Promise<MessageContext<Bot>> : T extends "video" ? (video, params?) => Promise<MessageContext<...>> : T extends "voice" ? (voice, params?) => Promise<...> : () => never>

Defined in: contexts/index.d.ts:5560

Automatically uses correct media method to send media

Type Parameters

Type Parameter
T extends string

Parameters

ParameterType
queryobject & tSendMethods

Returns

ReturnType<T extends "animation" ? (animation, params?) => Promise<MessageContext<Bot>> : T extends "audio" ? (audio, params?) => Promise<MessageContext<Bot>> : T extends "document" ? (document, params?) => Promise<MessageContext<Bot>> : T extends "photo" ? (photo, params?) => Promise<MessageContext<Bot>> : T extends "sticker" ? (sticker, params?) => Promise<MessageContext<Bot>> : T extends "video_note" ? (videoNote, params?) => Promise<MessageContext<Bot>> : T extends "video" ? (video, params?) => Promise<MessageContext<...>> : T extends "voice" ? (voice, params?) => Promise<...> : () => never>

Example

js
context.sendMedia({
  type: 'photo',
  photo: MediaUpload.path('./image.png'),
  caption: 'good image yes yes'
})

Inherited from

SendMixin.sendMedia


sendMediaGroup()

sendMediaGroup(mediaGroup, params?): Promise<MessageContext<Bot>[]>

Defined in: contexts/index.d.ts:5547

Sends media group to current chat

Parameters

ParameterType
mediaGroup(TelegramInputMediaAudio | TelegramInputMediaDocument | TelegramInputMediaLivePhoto | TelegramInputMediaPhoto | TelegramInputMediaVideo)[]
params?Optional<SendMediaGroupParams, "media" | "chat_id">

Returns

Promise<MessageContext<Bot>[]>

Inherited from

SendMixin.sendMediaGroup


sendMessageDraft()

sendMessageDraft(params): Promise<true>

Defined in: contexts/index.d.ts:5539

Sends a message draft to the current private chat

Parameters

ParameterType
paramsOptional<SendMessageDraftParams, "chat_id">

Returns

Promise<true>

Inherited from

SendMixin.sendMessageDraft


sendPaidMedia()

sendPaidMedia(paidMedia, starCount, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5545

Sends paid media to current chat

Parameters

ParameterType
paidMediaTelegramInputPaidMedia[]
starCountnumber
params?Optional<SendPaidMediaParams, "media" | "chat_id" | "star_count">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendPaidMedia


sendPhoto()

sendPhoto(photo, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5507

Sends photo to current chat

Parameters

ParameterType
photostring | Blob
params?Optional<SendPhotoParams, "photo" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendPhoto


sendPoll()

sendPoll(params): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5531

Sends poll to current chat

Parameters

ParameterType
paramsOptional<SendPollParams, "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendPoll


sendQueryWebApp()

sendQueryWebApp(webAppUrl): Promise<true>

Defined in: contexts/index.d.ts:6152

Processes the received chat join request query by showing a Mini App to the user before deciding the outcome.

Requires query_id to be present on the join request — the bot must respond within 10 seconds.

Parameters

ParameterType
webAppUrlstring

Returns

Promise<true>


sendRichMessage()

sendRichMessage(richMessage, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5471

Sends rich message to current chat

Parameters

ParameterType
richMessageTelegramInputRichMessage
params?Optional<SendRichMessageParams, "chat_id" | "rich_message">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendRichMessage


sendRichMessageDraft()

sendRichMessageDraft(richMessage, draftId, params?): Promise<true>

Defined in: contexts/index.d.ts:5478

Streams a partial rich message draft to the current chat. The streamed draft is ephemeral and acts as a temporary 30-second preview — once the output is finalized, you must call sendRichMessage with the complete message to persist it.

Parameters

ParameterType
richMessageTelegramInputRichMessage
draftIdnumber
params?Optional<SendRichMessageDraftParams, "chat_id" | "rich_message" | "draft_id">

Returns

Promise<true>

Inherited from

SendMixin.sendRichMessageDraft


sendSticker()

sendSticker(sticker, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5535

Sends sticker

Parameters

ParameterType
stickerstring | Blob
params?Optional<SendStickerParams, "sticker" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendSticker


sendVenue()

sendVenue(params): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5527

Sends venue to current chat

Parameters

ParameterType
paramsOptional<SendVenueParams, "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendVenue


sendVideo()

sendVideo(video, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5515

Sends video to current chat

Parameters

ParameterType
videostring | Blob
params?Optional<SendVideoParams, "video" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendVideo


sendVideoNote()

sendVideoNote(videoNote, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5519

Sends video note to current chat

Parameters

ParameterType
videoNotestring | Blob
params?Optional<SendVideoNoteParams, "video_note" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendVideoNote


sendVoice()

sendVoice(voice, params?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5521

Sends voice to current chat

Parameters

ParameterType
voicestring | Blob
params?Optional<SendVoiceParams, "voice" | "chat_id">

Returns

Promise<MessageContext<Bot>>

Inherited from

SendMixin.sendVoice


stopPoll()

stopPoll(messageId, params?): Promise<Poll>

Defined in: contexts/index.d.ts:5537

Stops poll in current chat

Parameters

ParameterType
messageIdnumber
params?Partial<StopPollParams>

Returns

Promise<Poll>

Inherited from

SendMixin.stopPoll


streamMessage()

Call Signature

streamMessage(options?): MessageDraft<Bot>

Defined in: contexts/index.d.ts:5583

Streams message drafts to the current chat, finalizing each completed draft as a sent message.

Two forms (mirroring SendMixin.streamRichMessage):

  • Iterable — pass an Iterable/AsyncIterable of MessageDraftPiece; it's drained and the array of sent messages is returned.
  • Handle — call with no iterable to get a MessageDraft: append() pieces and finalize(), or use await using to finalize on scope exit.

Both use sendMessageDraft for live previews and sendMessage to finalize each 4096-char segment.

Parameters
ParameterType
options?StreamMessageOptions
Returns

MessageDraft<Bot>

Example
ts
// iterable form
const messages = await context.streamMessage(llmStream);

// handle form (auto-finalize)
await using draft = context.streamMessage();
for await (const token of llm) draft.append(token);
Inherited from

SendMixin.streamMessage

Call Signature

streamMessage(stream, options?): Promise<MessageContext<Bot>[]>

Defined in: contexts/index.d.ts:5584

Streams message drafts to the current chat, finalizing each completed draft as a sent message.

Two forms (mirroring SendMixin.streamRichMessage):

  • Iterable — pass an Iterable/AsyncIterable of MessageDraftPiece; it's drained and the array of sent messages is returned.
  • Handle — call with no iterable to get a MessageDraft: append() pieces and finalize(), or use await using to finalize on scope exit.

Both use sendMessageDraft for live previews and sendMessage to finalize each 4096-char segment.

Parameters
ParameterType
streamIterable<MessageDraftPiece, any, any> | AsyncIterable<MessageDraftPiece, any, any>
options?StreamMessageOptions
Returns

Promise<MessageContext<Bot>[]>

Example
ts
// iterable form
const messages = await context.streamMessage(llmStream);

// handle form (auto-finalize)
await using draft = context.streamMessage();
for await (const token of llm) draft.append(token);
Inherited from

SendMixin.streamMessage


streamRichMessage()

Call Signature

streamRichMessage(options?): RichMessageDraft<Bot>

Defined in: contexts/index.d.ts:5504

Stream a rich message to the current chat, draft-first.

The hard part of sendRichMessageDraft is the contract: the draft is an ephemeral ~30-second preview, and you must finalize it with sendRichMessage or the message vanishes. This helper owns that lifecycle (throttled previews, a single finalize), so you can't forget it.

Two forms:

  • Handleconst draft = ctx.streamRichMessage(); draft.append(chunk); … await draft.finalize(). With await using, finalize runs automatically on scope exit.
  • Iterable — pass an (async) iterable of chunks; it's drained, finalized, and the sent message is returned.

A chunk is a @gramio/format RichString or a raw rich-markdown string.

Parameters
ParameterType
options?StreamRichMessageOptions
Returns

RichMessageDraft<Bot>

Example
ts
// handle form (auto-finalize)
await using draft = ctx.streamRichMessage();
for await (const token of llm) draft.append(rich`${token}`);

// iterable form
const message = await ctx.streamRichMessage(llmStream);
Inherited from

SendMixin.streamRichMessage

Call Signature

streamRichMessage(stream, options?): Promise<MessageContext<Bot>>

Defined in: contexts/index.d.ts:5505

Stream a rich message to the current chat, draft-first.

The hard part of sendRichMessageDraft is the contract: the draft is an ephemeral ~30-second preview, and you must finalize it with sendRichMessage or the message vanishes. This helper owns that lifecycle (throttled previews, a single finalize), so you can't forget it.

Two forms:

  • Handleconst draft = ctx.streamRichMessage(); draft.append(chunk); … await draft.finalize(). With await using, finalize runs automatically on scope exit.
  • Iterable — pass an (async) iterable of chunks; it's drained, finalized, and the sent message is returned.

A chunk is a @gramio/format RichString or a raw rich-markdown string.

Parameters
ParameterType
streamIterable<RichChunk, any, any> | AsyncIterable<RichChunk, any, any>
options?StreamRichMessageOptions
Returns

Promise<MessageContext<Bot>>

Example
ts
// handle form (auto-finalize)
await using draft = ctx.streamRichMessage();
for await (const token of llm) draft.append(rich`${token}`);

// iterable form
const message = await ctx.streamRichMessage(llmStream);
Inherited from

SendMixin.streamRichMessage