sdk.telegram — Telegram
Complete reference for the 51 Telegram methods: messaging, media, moderation, stars, gifts, collectibles, and more. Access via sdk.telegram in any plugin tool executor or lifecycle hook.
Quick Example
import type { PluginSDK } from "@teleton-agent/sdk";
export const tools = [
{
name: "greet",
description: "Send a greeting with a photo",
parameters: { chatId: { type: "string" } },
async execute({ chatId }: { chatId: string }, sdk: PluginSDK) {
// Who am I?
const me = sdk.telegram.getMe();
// Send a text message with an inline button
const msgId = await sdk.telegram.sendMessage(chatId, "Hello from the plugin!", {
inlineKeyboard: [[{ text: "Click me", callback_data: "greet:clicked" }]],
});
// Send a photo with caption
await sdk.telegram.sendPhoto(chatId, "/tmp/welcome.jpg", {
caption: `Sent by @${me?.username ?? "unknown"}`,
replyToId: msgId,
});
return { success: true, messageId: msgId };
},
},
];Core (5 methods)
Fundamental messaging operations: sending, editing, reacting, dice, and identity.
| Method | Returns | Description |
|---|---|---|
sendMessage(chatId, text, opts?) | Promise<number> | Send a text message. Returns the message ID. |
editMessage(chatId, messageId, text, opts?) | Promise<number> | Edit an existing message's text and/or keyboard. Returns the message ID. |
sendDice(chatId, emoticon, replyToId?) | Promise<DiceResult> | Send a dice/slot animation. Returns the rolled value and message ID. |
sendReaction(chatId, messageId, emoji) | Promise<void> | Add an emoji reaction to a message. |
getMe() | TelegramUser | null | Get the bot's own user info. Returns null if not connected. |
sendMessage
sendMessage(
chatId: string,
text: string,
opts?: SendMessageOptions
): Promise<number>Sends a text message to the specified chat. The optional opts parameter accepts replyToId (message ID to reply to) and inlineKeyboard (2D array of InlineButton objects for inline keyboard rows).
Throws: PluginSDKError with code BRIDGE_NOT_CONNECTED or OPERATION_FAILED.
const msgId = await sdk.telegram.sendMessage(chatId, "Choose an option:", {
replyToId: 12345,
inlineKeyboard: [
[
{ text: "Option A", callback_data: "choose:a" },
{ text: "Option B", callback_data: "choose:b" },
],
[{ text: "Cancel", callback_data: "choose:cancel" }],
],
});editMessage
editMessage(
chatId: string,
messageId: number,
text: string,
opts?: EditMessageOptions
): Promise<number>Edits an existing message's text. Pass opts.inlineKeyboard to update the keyboard, or omit it to keep the existing keyboard.
sendDice
sendDice(
chatId: string,
emoticon: string,
replyToId?: number
): Promise<DiceResult>Sends a dice animation and returns the result. Supported emoticons and value ranges:
| Emoticon | Name | Values |
|---|---|---|
| 🎲 | Dice | 1–6 |
| 🎯 | Darts | 1–6 |
| 🏀 | Basketball | 1–5 |
| ⚽ | Football | 1–5 |
| 🎳 | Bowling | 1–6 |
| 🎰 | Slots | 1–64 |
sendReaction
sendReaction(
chatId: string,
messageId: number,
emoji: string
): Promise<void>Adds an emoji reaction to a message. Common reactions include thumbs up, fire, heart, etc.
getMe
getMe(): TelegramUser | nullReturns the bot's own TelegramUser info synchronously. Returns null if the Telegram bridge is not connected. Note: this is not async — it returns directly, not a Promise.
const me = sdk.telegram.getMe();
if (!me) return { success: false, error: "Telegram not connected" };
console.log(`I am @${me.username}, ID: ${me.id}`);Media (7 methods)
Send photos, videos, voice messages, files, GIFs, stickers, and download media from messages.
| Method | Returns | Description |
|---|---|---|
sendPhoto(chatId, photo, opts?) | Promise<number> | Send a photo (file path or Buffer). Returns message ID. |
sendVideo(chatId, video, opts?) | Promise<number> | Send a video. Returns message ID. |
sendVoice(chatId, voice, opts?) | Promise<number> | Send a voice message (OGG/Opus format). Returns message ID. |
sendFile(chatId, file, opts?) | Promise<number> | Send a file/document. Accepts additional fileName option. Returns message ID. |
sendGif(chatId, gif, opts?) | Promise<number> | Send an animated GIF. Returns message ID. |
sendSticker(chatId, sticker) | Promise<number> | Send a sticker (WEBP format). Returns message ID. |
downloadMedia(chatId, messageId) | Promise<Buffer | null> | Download media from a message. Returns null if no media found. |
Signatures
sendPhoto(chatId: string, photo: string | Buffer, opts?: MediaSendOptions): Promise<number>
sendVideo(chatId: string, video: string | Buffer, opts?: MediaSendOptions): Promise<number>
sendVoice(chatId: string, voice: string | Buffer, opts?: MediaSendOptions): Promise<number>
sendFile(chatId: string, file: string | Buffer, opts?: MediaSendOptions & { fileName?: string }): Promise<number>
sendGif(chatId: string, gif: string | Buffer, opts?: MediaSendOptions): Promise<number>
sendSticker(chatId: string, sticker: string | Buffer): Promise<number>
downloadMedia(chatId: string, messageId: number): Promise<Buffer | null>All media send methods accept either a file path (string) or a Buffer. The MediaSendOptions type provides caption, reply-to, inline keyboard, and dimension/duration hints for video and voice.
sendFile additionally accepts fileName in its options to set the displayed file name. sendSticker takes no options — just the chat ID and sticker data.
Throws: PluginSDKError with code BRIDGE_NOT_CONNECTED or OPERATION_FAILED (except downloadMedia which returns null on failure).
// Photo with caption and reply
await sdk.telegram.sendPhoto(chatId, "/tmp/chart.png", {
caption: "Daily price chart",
replyToId: originalMsgId,
});
// Video with dimensions
await sdk.telegram.sendVideo(chatId, videoBuffer, {
caption: "Screen recording",
duration: 30,
width: 1920,
height: 1080,
});
// File with custom name
await sdk.telegram.sendFile(chatId, reportBuffer, {
fileName: "report-2026-03.pdf",
caption: "Monthly report attached",
});
// Download and re-send media
const media = await sdk.telegram.downloadMedia(chatId, 42);
if (media) {
await sdk.telegram.sendPhoto(otherChatId, media, {
caption: "Forwarded image",
});
}Messages (5 methods)
Retrieve, search, delete, and forward messages.
| Method | Returns | Description |
|---|---|---|
getMessages(chatId, limit?) | Promise<SimpleMessage[]> | Get recent messages from a chat. Default limit: 50. |
searchMessages(chatId, query, limit?) | Promise<SimpleMessage[]> | Search messages in a chat by query. Default limit: 20. |
getReplies(chatId, messageId, limit?) | Promise<SimpleMessage[]> | Get replies to a specific message (thread). Default limit: 50. |
deleteMessage(chatId, messageId, revoke?) | Promise<void> | Delete a message. revoke deletes for all users (default: true). |
forwardMessage(fromChatId, toChatId, messageId) | Promise<number | null> | Forward a message to another chat. Returns forwarded message ID. |
Signatures
getMessages(chatId: string, limit?: number): Promise<SimpleMessage[]>
searchMessages(chatId: string, query: string, limit?: number): Promise<SimpleMessage[]>
getReplies(chatId: string, messageId: number, limit?: number): Promise<SimpleMessage[]>
deleteMessage(chatId: string, messageId: number, revoke?: boolean): Promise<void>
forwardMessage(fromChatId: string, toChatId: string, messageId: number): Promise<number | null>All retrieval methods return an array of SimpleMessage objects (or an empty array on error). The deleteMessage method defaults revoke to true, which removes the message for all participants.
// Search for messages mentioning "invoice"
const results = await sdk.telegram.searchMessages(chatId, "invoice", 10);
// Forward the first match to the admin chat
if (results.length > 0) {
await sdk.telegram.forwardMessage(chatId, adminChatId, results[0].id);
}
// Get thread replies
const replies = await sdk.telegram.getReplies(chatId, parentMsgId, 20);
console.log(`Thread has ${replies.length} replies`);Scheduling (4 methods)
Schedule messages for future delivery, inspect scheduled messages, and send them immediately or delete them.
| Method | Returns | Description |
|---|---|---|
scheduleMessage(chatId, text, scheduleDate) | Promise<number | null> | Schedule a text message for later delivery. scheduleDate is a Unix timestamp. |
getScheduledMessages(chatId) | Promise<SimpleMessage[]> | Get all pending scheduled messages in a chat. |
deleteScheduledMessage(chatId, messageId) | Promise<void> | Delete a scheduled message before it is sent. |
sendScheduledNow(chatId, messageId) | Promise<void> | Send a scheduled message immediately instead of waiting. |
Signatures
scheduleMessage(chatId: string, text: string, scheduleDate: number): Promise<number | null>
getScheduledMessages(chatId: string): Promise<SimpleMessage[]>
deleteScheduledMessage(chatId: string, messageId: number): Promise<void>
sendScheduledNow(chatId: string, messageId: number): Promise<void>// Schedule a reminder for 1 hour from now
const oneHour = Math.floor(Date.now() / 1000) + 3600;
const scheduledId = await sdk.telegram.scheduleMessage(
chatId,
"Reminder: team standup in 5 minutes!",
oneHour
);
// List all scheduled messages
const pending = await sdk.telegram.getScheduledMessages(chatId);
console.log(`${pending.length} messages scheduled`);
// Send one immediately
if (pending.length > 0) {
await sdk.telegram.sendScheduledNow(chatId, pending[0].id);
}
// Or cancel one
if (scheduledId) {
await sdk.telegram.deleteScheduledMessage(chatId, scheduledId);
}Pinning (1 method)
Pin or unpin messages in chats and channels.
| Method | Returns | Description |
|---|---|---|
pinMessage(chatId, messageId, opts?) | Promise<void> | Pin or unpin a message. Options: silent (no notification), unpin (unpin instead of pin). |
Signature
pinMessage(
chatId: string,
messageId: number,
opts?: { silent?: boolean; unpin?: boolean }
): Promise<void>// Pin silently (no notification to members)
await sdk.telegram.pinMessage(chatId, importantMsgId, { silent: true });
// Unpin
await sdk.telegram.pinMessage(chatId, importantMsgId, { unpin: true });Chat & Users (6 methods)
Look up chat info, user profiles, resolve usernames, list participants, browse dialogs, and fetch message history.
| Method | Returns | Description |
|---|---|---|
getChatInfo(chatId) | Promise<ChatInfo | null> | Get chat/group/channel information. |
getUserInfo(userId) | Promise<UserInfo | null> | Get user information by ID or username. |
resolveUsername(username) | Promise<ResolvedPeer | null> | Resolve a @username to a peer entity. Pass username without the @ prefix. |
getParticipants(chatId, limit?) | Promise<UserInfo[]> | Get participants of a group/channel. Default limit: 100. |
getDialogs(limit?) | Promise<Dialog[]> | Get all dialogs (conversations). Default limit: 50, max: 100. |
getHistory(chatId, limit?) | Promise<SimpleMessage[]> | Get message history from a chat. Default limit: 50, max: 100. |
Signatures
getChatInfo(chatId: string): Promise<ChatInfo | null>
getUserInfo(userId: number | string): Promise<UserInfo | null>
resolveUsername(username: string): Promise<ResolvedPeer | null>
getParticipants(chatId: string, limit?: number): Promise<UserInfo[]>
getDialogs(limit?: number): Promise<Dialog[]>
getHistory(chatId: string, limit?: number): Promise<SimpleMessage[]>// Resolve a username to get their ID
const peer = await sdk.telegram.resolveUsername("durov");
if (peer) {
console.log(`@durov is a ${peer.type} with ID ${peer.id}`);
}
// Get chat info
const chat = await sdk.telegram.getChatInfo(chatId);
if (chat) {
console.log(`${chat.title} (${chat.type}) — ${chat.membersCount ?? "?"} members`);
}
// List recent dialogs
const dialogs = await sdk.telegram.getDialogs(20);
for (const d of dialogs) {
console.log(`${d.title} [${d.type}] unread: ${d.unreadCount}`);
}
// Browse history
const history = await sdk.telegram.getHistory(chatId, 30);
console.log(`Last ${history.length} messages fetched`);Interactive (2 methods)
Create polls and quizzes in chats.
| Method | Returns | Description |
|---|---|---|
createPoll(chatId, question, answers, opts?) | Promise<number | null> | Create a poll with 2–10 answer options. Returns message ID. |
createQuiz(chatId, question, answers, correctIndex, explanation?) | Promise<number | null> | Create a quiz with a correct answer. Returns message ID. |
Signatures
createPoll(
chatId: string,
question: string,
answers: string[],
opts?: PollOptions
): Promise<number | null>
createQuiz(
chatId: string,
question: string,
answers: string[],
correctIndex: number,
explanation?: string
): Promise<number | null>// Anonymous poll with multiple choice
await sdk.telegram.createPoll(chatId, "Favorite blockchain?", [
"TON", "Ethereum", "Solana", "Bitcoin"
], {
isAnonymous: true,
multipleChoice: false,
});
// Quiz with explanation
await sdk.telegram.createQuiz(
chatId,
"What is the native token of TON?",
["ETH", "TON", "SOL", "BTC"],
1, // correct index (TON)
"Toncoin (TON) is the native cryptocurrency of The Open Network."
);Moderation (4 methods)
Ban, unban, mute, and kick users in groups and channels. The bot must have admin privileges.
| Method | Returns | Description |
|---|---|---|
banUser(chatId, userId) | Promise<void> | Permanently ban a user from a group/channel. |
unbanUser(chatId, userId) | Promise<void> | Unban a previously banned user. |
muteUser(chatId, userId, untilDate?) | Promise<void> | Mute a user (restrict sending messages). untilDate is a Unix timestamp; pass 0 for permanent mute. |
kickUser(chatId, userId) | Promise<void> | Kick a user (ban + immediate unban). User can rejoin via invite link. |
Signatures
banUser(chatId: string, userId: number | string): Promise<void>
unbanUser(chatId: string, userId: number | string): Promise<void>
muteUser(chatId: string, userId: number | string, untilDate: number): Promise<void>
kickUser(chatId: string, userId: number | string): Promise<void>Note: muteUser requires an untilDate parameter (not optional in the type signature). Pass 0 for a permanent mute, or a future Unix timestamp for a temporary mute.
// Mute for 1 hour
const oneHourFromNow = Math.floor(Date.now() / 1000) + 3600;
await sdk.telegram.muteUser(chatId, spammerId, oneHourFromNow);
// Kick (can rejoin)
await sdk.telegram.kickUser(chatId, troublemaker);
// Permanent ban
await sdk.telegram.banUser(chatId, spammerId);
// Forgive and unban
await sdk.telegram.unbanUser(chatId, spammerId);Stars (2 methods)
Query the bot's Telegram Stars balance and transaction history.
| Method | Returns | Description |
|---|---|---|
getStarsBalance() | Promise<number> | Get current Telegram Stars balance. |
getStarsTransactions(limit?) | Promise<StarsTransaction[]> | Get Stars transaction history. Default limit: 50. |
Signatures
getStarsBalance(): Promise<number>
getStarsTransactions(limit?: number): Promise<StarsTransaction[]>const balance = await sdk.telegram.getStarsBalance();
console.log(`Stars balance: ${balance}`);
const txs = await sdk.telegram.getStarsTransactions(10);
for (const tx of txs) {
const direction = tx.amount > 0 ? "received" : "spent";
console.log(`${direction} ${Math.abs(tx.amount)} stars — ${tx.description ?? "no description"}`);
}Gifts (5 methods)
Send, browse, and purchase Telegram Star Gifts.
| Method | Returns | Description |
|---|---|---|
sendGift(userId, giftId, opts?) | Promise<void> | Send a star gift to a user. Options: message, anonymous. |
getAvailableGifts() | Promise<StarGift[]> | Get available star gifts catalog. |
getMyGifts(limit?) | Promise<ReceivedGift[]> | Get star gifts received by the bot. Default limit: 50. |
getResaleGifts(giftId, limit?) | Promise<StarGift[]> | Get gifts available for resale from a collection. |
buyResaleGift(giftId) | Promise<void> | Buy a star gift from the resale market. |
Signatures
sendGift(
userId: number | string,
giftId: string,
opts?: { message?: string; anonymous?: boolean }
): Promise<void>
getAvailableGifts(): Promise<StarGift[]>
getMyGifts(limit?: number): Promise<ReceivedGift[]>
getResaleGifts(giftId: string, limit?: number): Promise<StarGift[]>
buyResaleGift(giftId: string): Promise<void>// Browse available gifts
const gifts = await sdk.telegram.getAvailableGifts();
const cheapest = gifts.sort((a, b) => a.starsAmount - b.starsAmount)[0];
// Send the cheapest gift anonymously
await sdk.telegram.sendGift(userId, cheapest.id, {
message: "A small gift for you!",
anonymous: true,
});
// Check received gifts
const myGifts = await sdk.telegram.getMyGifts(10);
console.log(`Received ${myGifts.length} gifts`);
// Browse resale market for a specific collection
const resale = await sdk.telegram.getResaleGifts(cheapest.id, 20);
if (resale.length > 0) {
await sdk.telegram.buyResaleGift(resale[0].id);
}Collectibles (6 methods)
Transfer, price, and inspect collectible gifts and unique NFTs. These methods interact with Telegram's Fragment marketplace and unique gift system.
| Method | Returns | Description |
|---|---|---|
transferCollectible(msgId, toUserId) | Promise<TransferResult> | Transfer a collectible gift to another user. msgId is from getMyGifts(). |
setCollectiblePrice(msgId, price) | Promise<void> | Set or remove the resale price of a collectible. Pass 0 to unlist. |
getCollectibleInfo(slug) | Promise<CollectibleInfo | null> | Get info about a Fragment collectible (username or phone number). |
getUniqueGift(slug) | Promise<UniqueGift | null> | Look up a unique NFT gift by its slug (from t.me/nft/<slug>). |
getUniqueGiftValue(slug) | Promise<GiftValue | null> | Get market value/appraisal of a unique NFT gift. |
sendGiftOffer(userId, giftSlug, price, opts?) | Promise<void> | Send a buy offer on a unique NFT gift to its owner. |
Signatures
transferCollectible(msgId: number, toUserId: number | string): Promise<TransferResult>
setCollectiblePrice(msgId: number, price: number): Promise<void>
getCollectibleInfo(slug: string): Promise<CollectibleInfo | null>
getUniqueGift(slug: string): Promise<UniqueGift | null>
getUniqueGiftValue(slug: string): Promise<GiftValue | null>
sendGiftOffer(
userId: number | string,
giftSlug: string,
price: number,
opts?: GiftOfferOptions
): Promise<void>// Look up a unique NFT gift
const gift = await sdk.telegram.getUniqueGift("blue-diamond-42");
if (!gift) return { success: false, error: "Gift not found" };
console.log(`${gift.title} #${gift.num} owned by ${gift.owner.name}`);
console.log(`Attributes: ${gift.attributes.map(a => a.name).join(", ")}`);
// Check its market value
const value = await sdk.telegram.getUniqueGiftValue("blue-diamond-42");
if (value) {
console.log(`Floor: ${value.floorPrice} | Avg: ${value.averagePrice}`);
}
// Send a buy offer (valid for 24h by default)
await sdk.telegram.sendGiftOffer(gift.owner.id!, "blue-diamond-42", 5000);
// Or with custom duration (minimum 6 hours = 21600 seconds)
await sdk.telegram.sendGiftOffer(gift.owner.id!, "blue-diamond-42", 5000, {
duration: 43200, // 12 hours
});
// Transfer a collectible you own
const myGifts = await sdk.telegram.getMyGifts(50);
const collectible = myGifts.find(g => g.messageId);
if (collectible?.messageId) {
const result = await sdk.telegram.transferCollectible(collectible.messageId, recipientId);
console.log(`Transferred to ${result.transferredTo}, paid: ${result.paidTransfer}`);
}
// Set resale price (in Stars)
await sdk.telegram.setCollectiblePrice(collectible!.messageId!, 2500);
// Unlist from resale
await sdk.telegram.setCollectiblePrice(collectible!.messageId!, 0);
// Look up a Fragment collectible (username or phone)
const info = await sdk.telegram.getCollectibleInfo("durov");
if (info) {
console.log(`@${info.value} purchased on ${info.purchaseDate} for ${info.cryptoAmount} ${info.cryptoCurrency}`);
}Stories (1 method)
Post a story to the bot's Telegram profile.
| Method | Returns | Description |
|---|---|---|
sendStory(mediaPath, opts?) | Promise<number | null> | Post a photo or video story. Returns story ID. |
Signature
sendStory(
mediaPath: string,
opts?: { caption?: string }
): Promise<number | null>Security gotcha: The mediaPath must be within an allowed directory. The following paths are whitelisted:
/tmpDownloads/Pictures/Videos/- The Teleton workspace directory
Paths are resolved with realpathSync() to prevent symlink traversal. Attempting to send a story from outside these directories will throw an error.
const storyId = await sdk.telegram.sendStory("/tmp/daily-chart.jpg", {
caption: "Today's market overview",
});
if (storyId) {
console.log(`Story posted: ${storyId}`);
}Advanced (3 methods)
Low-level utilities: typing indicator, raw GramJS client access, and connection status.
| Method | Returns | Description |
|---|---|---|
setTyping(chatId) | Promise<void> | Show "typing..." indicator in a chat. Automatically expires after ~5 seconds. |
getRawClient() | unknown | null | Get the raw GramJS TelegramClient for advanced MTProto operations. Returns null if not connected. |
isAvailable() | boolean | Check if the Telegram bridge is connected and ready. |
Signatures
setTyping(chatId: string): Promise<void>
getRawClient(): unknown | null
isAvailable(): booleangetRawClient() returns the underlying GramJS TelegramClient instance typed as unknown. Cast it in your plugin to use MTProto APIs not covered by the SDK. This is an escape hatch — prefer the typed SDK methods when possible.
// Always check availability first
if (!sdk.telegram.isAvailable()) {
return { success: false, error: "Telegram not connected" };
}
// Show typing while processing
await sdk.telegram.setTyping(chatId);
// Use raw client for inline bot results
const client = sdk.telegram.getRawClient();
if (client) {
const { Api } = require("telegram");
const results = await (client as any).invoke(
new Api.messages.GetInlineBotResults({
bot: "@pic",
query: "sunset",
peer: chatId,
offset: "",
})
);
console.log(`Got ${results.results.length} inline results`);
}Type Definitions
All types used by sdk.telegram methods. Import from @teleton-agent/sdk.
SendMessageOptions
interface SendMessageOptions {
/** Message ID to reply to */
replyToId?: number;
/** Inline keyboard buttons (2D array: rows of buttons) */
inlineKeyboard?: InlineButton[][];
}EditMessageOptions
interface EditMessageOptions {
/** Updated inline keyboard (omit to keep existing) */
inlineKeyboard?: InlineButton[][];
}InlineButton
interface InlineButton {
/** Button label text */
text: string;
/** Callback data sent when button is pressed */
callback_data: string;
}MediaSendOptions
interface MediaSendOptions {
/** Media caption text */
caption?: string;
/** Message ID to reply to */
replyToId?: number;
/** Inline keyboard buttons */
inlineKeyboard?: InlineButton[][];
/** Duration in seconds (for video/voice) */
duration?: number;
/** Width in pixels (for video) */
width?: number;
/** Height in pixels (for video) */
height?: number;
}PollOptions
interface PollOptions {
/** Whether voters are anonymous (default: true) */
isAnonymous?: boolean;
/** Allow multiple answers (default: false) */
multipleChoice?: boolean;
}SimpleMessage
interface SimpleMessage {
/** Message ID */
id: number;
/** Message text */
text: string;
/** Sender user ID */
senderId: number;
/** Sender username */
senderUsername?: string;
/** Message timestamp */
timestamp: Date;
}TelegramUser
interface TelegramUser {
/** Telegram user ID */
id: number;
/** Username without @ (may be undefined) */
username?: string;
/** First name */
firstName?: string;
/** Whether the user is a bot */
isBot: boolean;
}ChatInfo
interface ChatInfo {
/** Chat ID as string */
id: string;
/** Chat title (or user's first name for private chats) */
title: string;
/** Chat type */
type: "private" | "group" | "supergroup" | "channel";
/** Number of members (groups/channels only) */
membersCount?: number;
/** Chat username without @ (if public) */
username?: string;
/** Chat/channel description/bio */
description?: string;
}UserInfo
interface UserInfo {
/** Telegram user ID */
id: number;
/** First name */
firstName: string;
/** Last name */
lastName?: string;
/** Username without @ */
username?: string;
/** Whether the user is a bot */
isBot: boolean;
}ResolvedPeer
interface ResolvedPeer {
/** Entity ID */
id: number;
/** Entity type */
type: "user" | "chat" | "channel";
/** Username if available */
username?: string;
/** Title (for groups/channels) or first name (for users) */
title?: string;
}DiceResult
interface DiceResult {
/** The dice value (1-6 for dice, 1-64 for slots, etc.) */
value: number;
/** Message ID of the dice message */
messageId: number;
}StarGift
interface StarGift {
/** Gift ID */
id: string;
/** Cost in Telegram Stars */
starsAmount: number;
/** Remaining available (limited gifts) */
availableAmount?: number;
/** Total supply (limited gifts) */
totalAmount?: number;
}ReceivedGift
interface ReceivedGift {
/** Gift ID */
id: string;
/** Sender user ID */
fromId?: number;
/** Unix timestamp when received */
date: number;
/** Stars value */
starsAmount: number;
/** Whether saved to profile */
saved: boolean;
/** Associated message ID */
messageId?: number;
}Dialog
interface Dialog {
/** Chat ID */
id: string | null;
/** Chat title or name */
title: string;
/** Chat type */
type: "dm" | "group" | "channel";
/** Number of unread messages */
unreadCount: number;
/** Number of unread mentions */
unreadMentionsCount: number;
/** Whether the chat is pinned */
isPinned: boolean;
/** Whether the chat is archived */
isArchived: boolean;
/** Last message date (unix timestamp) */
lastMessageDate: number | null;
/** Last message preview (truncated) */
lastMessage: string | null;
}StarsTransaction
interface StarsTransaction {
/** Transaction ID */
id: string;
/** Amount (positive = received, negative = spent) */
amount: number;
/** Transaction date (unix timestamp) */
date: number;
/** Peer info */
peer?: string;
/** Description */
description?: string;
}TransferResult
interface TransferResult {
/** Message ID of the transferred gift */
msgId: number;
/** Recipient identifier */
transferredTo: string;
/** Whether transfer cost Stars */
paidTransfer: boolean;
/** Stars spent (if paid transfer) */
starsSpent?: string;
}CollectibleInfo
interface CollectibleInfo {
/** Collectible type */
type: "username" | "phone";
/** The username or phone number */
value: string;
/** Purchase date (ISO 8601) */
purchaseDate: string;
/** Fiat currency */
currency: string;
/** Fiat amount */
amount?: string;
/** Crypto currency (e.g. "TON") */
cryptoCurrency?: string;
/** Crypto amount */
cryptoAmount?: string;
/** Fragment URL */
url?: string;
}UniqueGift
interface UniqueGift {
/** Gift ID */
id: string;
/** Collection gift ID */
giftId: string;
/** URL slug */
slug: string;
/** Gift title */
title: string;
/** Number in collection */
num: number;
/** Owner info */
owner: {
id?: string;
name?: string;
address?: string;
username?: string;
};
/** TON address of the gift NFT */
giftAddress?: string;
/** NFT attributes */
attributes: Array<{ type: string; name: string; rarityPercent?: number }>;
/** Availability info */
availability?: { total: number; remaining: number };
/** Link to NFT page */
nftLink: string;
}GiftValue
interface GiftValue {
/** NFT slug */
slug: string;
/** Initial sale date (ISO 8601) */
initialSaleDate?: string;
/** Initial sale price in Stars */
initialSaleStars?: string;
/** Last sale date (ISO 8601) */
lastSaleDate?: string;
/** Last sale price */
lastSalePrice?: string;
/** Floor price */
floorPrice?: string;
/** Average price */
averagePrice?: string;
/** Number listed */
listedCount?: number;
/** Currency */
currency?: string;
}GiftOfferOptions
interface GiftOfferOptions {
/** Offer validity in seconds (default: 86400 = 24h, min: 21600 = 6h) */
duration?: number;
}StartContext
interface StartContext {
/** Telegram bridge for advanced operations */
bridge: unknown;
/** Plugin's isolated SQLite database (null if unavailable) */
db: unknown;
/** Sanitized application config (no API keys) */
config: Record<string, unknown>;
/** Plugin-specific config from config.yaml */
pluginConfig: Record<string, unknown>;
/** Prefixed logger */
log: PluginLogger;
}Full Method Index
All 51 methods on sdk.telegram at a glance, grouped by category.
| # | Method | Returns | Category |
|---|---|---|---|
| 1 | sendMessage(chatId, text, opts?) | Promise<number> | Core |
| 2 | editMessage(chatId, messageId, text, opts?) | Promise<number> | Core |
| 3 | sendDice(chatId, emoticon, replyToId?) | Promise<DiceResult> | Core |
| 4 | sendReaction(chatId, messageId, emoji) | Promise<void> | Core |
| 5 | getMe() | TelegramUser | null | Core |
| 6 | sendPhoto(chatId, photo, opts?) | Promise<number> | Media |
| 7 | sendVideo(chatId, video, opts?) | Promise<number> | Media |
| 8 | sendVoice(chatId, voice, opts?) | Promise<number> | Media |
| 9 | sendFile(chatId, file, opts?) | Promise<number> | Media |
| 10 | sendGif(chatId, gif, opts?) | Promise<number> | Media |
| 11 | sendSticker(chatId, sticker) | Promise<number> | Media |
| 12 | downloadMedia(chatId, messageId) | Promise<Buffer | null> | Media |
| 13 | getMessages(chatId, limit?) | Promise<SimpleMessage[]> | Messages |
| 14 | searchMessages(chatId, query, limit?) | Promise<SimpleMessage[]> | Messages |
| 15 | getReplies(chatId, messageId, limit?) | Promise<SimpleMessage[]> | Messages |
| 16 | deleteMessage(chatId, messageId, revoke?) | Promise<void> | Messages |
| 17 | forwardMessage(fromChatId, toChatId, messageId) | Promise<number | null> | Messages |
| 18 | scheduleMessage(chatId, text, scheduleDate) | Promise<number | null> | Scheduling |
| 19 | getScheduledMessages(chatId) | Promise<SimpleMessage[]> | Scheduling |
| 20 | deleteScheduledMessage(chatId, messageId) | Promise<void> | Scheduling |
| 21 | sendScheduledNow(chatId, messageId) | Promise<void> | Scheduling |
| 22 | pinMessage(chatId, messageId, opts?) | Promise<void> | Pinning |
| 23 | getChatInfo(chatId) | Promise<ChatInfo | null> | Chat & Users |
| 24 | getUserInfo(userId) | Promise<UserInfo | null> | Chat & Users |
| 25 | resolveUsername(username) | Promise<ResolvedPeer | null> | Chat & Users |
| 26 | getParticipants(chatId, limit?) | Promise<UserInfo[]> | Chat & Users |
| 27 | getDialogs(limit?) | Promise<Dialog[]> | Chat & Users |
| 28 | getHistory(chatId, limit?) | Promise<SimpleMessage[]> | Chat & Users |
| 29 | createPoll(chatId, question, answers, opts?) | Promise<number | null> | Interactive |
| 30 | createQuiz(chatId, question, answers, correctIndex, explanation?) | Promise<number | null> | Interactive |
| 31 | banUser(chatId, userId) | Promise<void> | Moderation |
| 32 | unbanUser(chatId, userId) | Promise<void> | Moderation |
| 33 | muteUser(chatId, userId, untilDate) | Promise<void> | Moderation |
| 34 | kickUser(chatId, userId) | Promise<void> | Moderation |
| 35 | getStarsBalance() | Promise<number> | Stars |
| 36 | getStarsTransactions(limit?) | Promise<StarsTransaction[]> | Stars |
| 37 | sendGift(userId, giftId, opts?) | Promise<void> | Gifts |
| 38 | getAvailableGifts() | Promise<StarGift[]> | Gifts |
| 39 | getMyGifts(limit?) | Promise<ReceivedGift[]> | Gifts |
| 40 | getResaleGifts(giftId, limit?) | Promise<StarGift[]> | Gifts |
| 41 | buyResaleGift(giftId) | Promise<void> | Gifts |
| 42 | sendStory(mediaPath, opts?) | Promise<number | null> | Stories |
| 43 | transferCollectible(msgId, toUserId) | Promise<TransferResult> | Collectibles |
| 44 | setCollectiblePrice(msgId, price) | Promise<void> | Collectibles |
| 45 | getCollectibleInfo(slug) | Promise<CollectibleInfo | null> | Collectibles |
| 46 | getUniqueGift(slug) | Promise<UniqueGift | null> | Collectibles |
| 47 | getUniqueGiftValue(slug) | Promise<GiftValue | null> | Collectibles |
| 48 | sendGiftOffer(userId, giftSlug, price, opts?) | Promise<void> | Collectibles |
| 49 | setTyping(chatId) | Promise<void> | Advanced |
| 50 | getRawClient() | unknown | null | Advanced |
| 51 | isAvailable() | boolean | Advanced |