WhatsApp Cloud API Client — sgcWebSockets | eSeGeCe

WhatsApp Cloud API

Send template, text, media and interactive messages through the WhatsApp Cloud API from Delphi/C++Builder. Includes a built-in HTTPS Webhook listener for inbound events.

TsgcWhatsApp_Client

Delphi/C++Builder client for the WhatsApp Business Cloud API. Send messages over HTTPS, host a Webhook endpoint for delivery and status events.

Component class

TsgcWhatsApp_Client

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Set token, send messages, host Webhook

Set WhatsAppOptions.Token and PhoneNumberId, call a SendMessage... method to send, then StartServer and hook OnMessageReceived to receive replies.

uses
  sgcLibs;

var
  WhatsApp: TsgcWhatsApp_Client;
begin
  WhatsApp := TsgcWhatsApp_Client.Create(nil);
  WhatsApp.WhatsAppOptions.PhoneNumberId := '123456789012345';
  WhatsApp.WhatsAppOptions.Token := 'EAAG...';

  WhatsApp.SendMessageText('+34666555444', 'hello from Delphi');

  WhatsApp.OnMessageReceived := WhatsAppMessageReceived;
  WhatsApp.StartServer;
end;

procedure TForm1.WhatsAppMessageReceived(Sender: TObject;
  const aMessage: TsgcWhatsApp_Receive_Message;
  var aMarkAsRead: Boolean);
begin
  Memo1.Lines.Add(aMessage.RawMessage);
  aMarkAsRead := True;
end;
// include: sgcLibs.hpp

TsgcWhatsApp_Client *WhatsApp = new TsgcWhatsApp_Client(this);
WhatsApp->WhatsAppOptions->PhoneNumberId = "123456789012345";
WhatsApp->WhatsAppOptions->Token = "EAAG...";

WhatsApp->SendMessageText("+34666555444", "hello from Delphi");

WhatsApp->OnMessageReceived = WhatsAppMessageReceived;
WhatsApp->StartServer();

void __fastcall TForm1::WhatsAppMessageReceived(TObject *Sender,
    TsgcWhatsApp_Receive_Message * const aMessage, bool &aMarkAsRead)
{
  Memo1->Lines->Add(aMessage->RawMessage);
  aMarkAsRead = true;
}

What's inside

Combines an HTTPS Cloud API client with a built-in Webhook HTTPS server so a single Delphi process handles outbound and inbound traffic.

Send messages

SendMessageText, SendMessageTemplate, SendMessageImage/Document/Audio/Video, SendMessageInteractiveList, SendMessageInteractiveButtons, SendMessageLocation and SendMessageContact cover the main Cloud API content types.

Webhook listener

The component starts its own embedded HTTPS server (StartServer/StopServer, configured through ServerOptions) to host the verification and delivery webhook Meta requires. OnMessageReceived and OnMessageSent deliver typed events, OnRawMessage exposes the untouched JSON.

Authentication

OAuth Bearer authentication via WhatsAppOptions.Token; the webhook verification handshake is checked automatically against ServerOptions.WebhookOptions.Token, and OnBeforeSubscribe gives your app one more chance to accept or reject the subscription.

Template parameters

SendMessageTemplate accepts named/positional parameters, a language code and the component builds the typed structure Meta requires.

Media upload

Call SendFileImage, SendFileDocument, SendFileAudio, SendFileVideo or SendFileSticker with a local file path, the component uploads it through UploadMedia and references the returned media id automatically. DownloadMedia and DeleteMedia manage assets already on Meta's servers.

TLS-secured Webhook

Configure ServerOptions.SSLOptions for the inbound webhook — Meta requires it to be reachable over TLS. The top-level TLSOptions covers the outbound HTTPS calls to the Graph API separately.

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_Whatsapp Full property, method and event reference for this component.
Demo Project — Demos\50.Other\05.WhatsApp 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 Send WhatsApp Messages?

Download the free trial and integrate the WhatsApp Cloud API into your Delphi applications.