Guides

Gifts

Main Walkthrough 22 of 22

Clients can browse, send, sell, and transfer Telegram Star gifts.

Getting Available Gifts

Use getGifts to list the gifts available for purchase.

const gifts = await client.getGifts();

for (const gift of gifts) {
  console.log(gift.id, gift.price);
}

id is the identifier used when sending a gift.

Getting a Gift

Use getGift with a gift slug to fetch its details.

const gift = await client.getGift("delicious-bento");

Sending a Gift

Use sendGift with the recipient and the gift identifier to purchase and send a gift.

await client.sendGift(userId, giftId);

Optionally, pass a message to attach text to the gift.

await client.sendGift(userId, giftId, {
  message: "Enjoy!",
});

Selling a Gift

Use sellGift to convert a gift to Telegram Stars. Reference the gift by its chat and identifier.

await client.sellGift({ type: "chat", chatId, id });

For a gift in a private chat, use type: "user" with the messageId.

await client.sellGift({ type: "user", messageId });

Transferring a Gift

Use transferGift to give a saved gift to another user.

await client.transferGift(userId, { type: "chat", chatId, id });