Telegram API Client for Delphi & C++ Builder | eSeGeCe

Telegram TDLib Client

Build Telegram user-account or bot applications in Delphi/C++Builder. Wraps the official Telegram TDLib to expose authentication, chats, messages and update events.

TsgcTDLib_Telegram

Delphi/C++Builder wrapper for the official Telegram TDLib (tdjson). Drives the authentication state machine, exposes typed message send/receive events, and delivers every other TDLib update through OnEvent.

Component class

TsgcTDLib_Telegram

Protocol

Telegram TDLib

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Set TDLib, authenticate, message

Set Telegram.API.ApiId / ApiHash and Telegram.PhoneNumber, hook OnAuthenticationCode for the login flow, then send messages once OnAuthorizationStatus reports authorizationStateReady.

uses
  sgcLibs;

var
  Telegram: TsgcTDLib_Telegram;
begin
  Telegram := TsgcTDLib_Telegram.Create(nil);
  Telegram.Telegram.API.ApiId   := '123456';
  Telegram.Telegram.API.ApiHash := 'your-api-hash';
  Telegram.Telegram.PhoneNumber := '+34600111222';

  Telegram.OnAuthenticationCode := TelegramAuthenticationCode;
  Telegram.OnAuthorizationStatus := TelegramAuthorizationStatus;
  Telegram.OnMessageText         := TelegramMessageText;

  Telegram.Active := True;
end;

procedure TForm1.TelegramAuthenticationCode(Sender: TObject;
  var Code: string);
begin
  Code := InputBox('Telegram', 'Enter the code you received', '');
end;

procedure TForm1.TelegramAuthorizationStatus(Sender: TObject;
  const Status: string);
begin
  if Status = 'authorizationStateReady' then
    Telegram.GetChats;
end;

procedure TForm1.TelegramMessageText(Sender: TObject;
  MessageText: TsgcTelegramMessageText);
begin
  Memo1.Lines.Add(MessageText.ChatId + ': ' + MessageText.Text);
  Telegram.SendTextMessage(MessageText.ChatId, 'received!');
end;
// include: sgcLibs.hpp

TsgcTDLib_Telegram *Telegram = new TsgcTDLib_Telegram(this);
Telegram->Telegram->API->ApiId   = "123456";
Telegram->Telegram->API->ApiHash = "your-api-hash";
Telegram->Telegram->PhoneNumber = "+34600111222";

Telegram->OnAuthenticationCode = TelegramAuthenticationCode;
Telegram->OnAuthorizationStatus = TelegramAuthorizationStatus;
Telegram->OnMessageText = TelegramMessageText;

Telegram->Active = true;

void __fastcall TForm1::TelegramAuthenticationCode(TObject *Sender, AnsiString &Code)
{
  Code = InputBox("Telegram", "Enter the code you received", "");
}

void __fastcall TForm1::TelegramAuthorizationStatus(TObject *Sender, const AnsiString Status)
{
  if (Status == "authorizationStateReady")
    Telegram->GetChats();
}

void __fastcall TForm1::TelegramMessageText(TObject *Sender, TsgcTelegramMessageText *MessageText)
{
  Memo1->Lines->Add(MessageText->ChatId + ": " + MessageText->Text);
  Telegram->SendTextMessage(MessageText->ChatId, "received!");
}

What's inside

A Delphi facade over the official TDLib (tdjson) shared library — same protocol the official Telegram clients use.

Authentication flow

The component drives the TDLib authentication state machine: phone number, code, optional 2FA password, and persists the session under the local database directory.

Send messages

SendTextMessage, SendPhotoMessage, SendVideoMessage, SendDocumentMessage and SendMessageAlbum cover the main TDLib message-content types.

Chats & contacts

GetChats, GetChat, SearchPublicChat and GetUser expose the Telegram address book and joined channels/groups as typed responses.

Update stream

OnEvent delivers every TDLib updateXxx event — new messages, user typing, channel posts, edits, deletions — as a raw event name plus JSON for downstream routing, alongside the typed OnMessageText, OnNewChat and OnNewCallbackQuery events for common cases.

Native TDLib

Uses the official tdjson.dll / libtdjson.so / libtdjson.dylib — same end-to-end encryption guarantees as the official Telegram client.

Cross-platform

TDLib ships for Windows, macOS, Linux, Android and iOS. The component locates and loads the native library automatically per platform; you only handle the typed bridging through the events and methods above.

Specifications & references

Authoritative sources for the API this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — API_Telegram Full property, method and event reference for this component.
Demo Project — Demos\50.Other\01.Telegram_Client Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Build a Telegram Client?

Download the free trial and add Telegram messaging to your Delphi applications.