Telegram Sponsored Messages

From sgcWebSockets 2022.3.0, Sponsored Messages are supported. Sponsored Messages requires Telegram 1.8.0+, so the Telegram libraries have been updated to support this feature.

Sponsored messages on Telegram are displayed in large public one-to-many channels with 1000+ subscribers and are limited to 160 characters. Sponsored Messages are based solely on the topic of the public channels in which they are shown.

This means that no user data is mined or analyzed to display ads, and every user viewing a particular channel on Telegram sees the same sponsored messages.

Getting sponsored messages 

 Each time the user opens a channel, channels.getSponsoredMessages must be called to receive sponsored messages available for this channel. The result must be cached for 5 minutes.

Displaying sponsored messages 

Sponsored messages must be displayed below all other posts in the channel, after the user scrolls futher down, past the last message. The promoted channel or bot specified in the from_id field must be displayed as the author of the message. The message should also contain one of the following buttons at the bottom:

  • View Bot — if a bot is being promoted. Tapping the button must open the chat with the bot. If start_param is specified, the app must use the deep linking mechanism to open the bot.
  • View Channel — if a channel is being promoted. Tapping the button must open the channel.
  • View Post — if a channel is being promoted and channel_post is specified. Tapping the button must open the particular channel post.


Find below an example to request and show Sponsored Messages using sgcWebSockets library.

//Send a request to the channel asking if there are sponsored messages available, just call the method GetChatSponsoredMessage.
oTelegram := TsgcTDLib_Telegram.Create(nil);
oTelegram.Telegram.API.ApiHash := 'ABCDEFGHIJKLMN';
oTelegram.Telegram.API.ApiId := '1234';
oTelegram.PhoneNumber := '008745744155';
oTelegram.Active := true;

//If the chat has sponsored messages, the event OnMessageSponsored is called with the content of the Sponsored message. 
//If there are no messages, a 404 error is returned.
procedure(Sender: TObject; MessageSponsored: TsgcTelegramMessageSponsored);

//Call the method ViewMethod after the Sponsored Messages has been shown to the user.
oTelegram.ViewMessage('100', '54653256245'); 
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

New sgcWebSockets Windows Installer
Delphi Kucoin Futures API Client

Related Posts