How to send custom emoji from Bot in Telegram
Asked Answered
C

2

2

I'm trying to send the custom_emoji through Telegram API using MessageEntity object.

Here is how I've tried to do it:

const message = 'πŸš€'
ctx.sendMessage({
  text: message,
  entities: [{
    type: 'custom_emoji',
    length: message.length,
    offset: 0,
    custom_emoji_id: '5389102131527556772'
  }]
})

p.s. I'm using Telegraf TS, but it doesn't matter since it's just a basic function

Ciscaucasia answered 14/11, 2022 at 21:18 Comment(1)
We encountered the same problem. We think that its now available rn because you can not buy premium for bots – Haddington
C
1

Telegram finally published more detailed doc covering this moment: https://core.telegram.org/bots/api#markdownv2-style

Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.

MarkdownV2 style

![πŸ‘](tg://emoji?id=5368324170671202286)

HTML style

<tg-emoji emoji-id="5368324170671202286">πŸ‘</tg-emoji>

The documentation is a bit vague. So will explain how I get it:

  1. You need to make one time purchase with 5k TON, to allow your bot to attach custom usernames.
  2. Attach one of the usernames you own through fragment.com
  3. Sending custom emoji should be available from now on More details you can find on Fragment FAQ

p.s. Custom emoji id could be found in web.telegram.org through inspector: customEmojiId in Telegram Web version

Ciscaucasia answered 7/8, 2023 at 17:24 Comment(3)
Can you write me full code using sendMessage() ? – Dematerialize
Could you please tell me more explanations? If i purchase username on Fragment via my telegram, the bot which was created by my telegram will use custom emoji? So.. the bot owner's telegram username should be one of the listing of Fragment to use custom emoji? – Dematerialize
The documentation is a bit vague. So will explain how I get it: 1. You need to make one time purchase with 5k TON, to allow your bot to attach custom usernames. 2. Attach one of the usernames you own through fragment.com 3. Sending custom emoji should be available from now on More details you can find on fragment.com/… I am about to test this workflow so I can share results afterwards with wider audience – Ciscaucasia
H
0

Based on the Telegram API documentation: Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.

This does not mean that you need to buy names worth TON, but be sure to buy a name and link it to your bot. Then, using HTML or MarkdownV2 parse_mode you can send custom emoji in your bot's messages.Here is information about the cost of the name that is used for the bot. It can send premium emoji.

Heerlen answered 5/4, 2024 at 8:54 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.