TTMSFNCWhatsAppServer is a headless component that hosts the callback URL of a WhatsApp Business Platform webhook. It answers Meta's webhook verification with your verify token, receives the JSON payloads WhatsApp posts for incoming messages, lets you inspect and filter them, and forwards them over WebSocket to the connected TTMSFNCWhatsAppReceiver clients. It is built on TTMSFNCWebSocketServer and always runs over TLS, as WhatsApp requires.
Windows, macOS, iOS, Android, and Linux; in practice a server with a public HTTPS address.
TMS WEB Core
Not available; a browser cannot host a server.
Minimal example
Configure the verify token and certificate, start the server, and look at each payload before it is forwarded:
Start the webhook server and inspect incoming payloadsPascal
procedure TForm1.FormCreate(Sender: TObject);
begin
// Callback URL in the Meta dashboard: https://<your-domain>/
TMSFNCWhatsAppServer1.Port := 443;
TMSFNCWhatsAppServer1.VerifyToken := 'my-verify-token'; // same value as in the dashboard
TMSFNCWhatsAppServer1.CertificateFile := 'certs\cert.pem';
TMSFNCWhatsAppServer1.CertificateKeyFile := 'certs\key.pem';
TMSFNCWhatsAppServer1.RootCertificateFile := 'certs\chain.pem';
TMSFNCWhatsAppServer1.Active := True;
end;
procedure TForm1.TMSFNCWhatsAppServer1RawMessage(Sender: TObject;
AMessage: string; var ABroadcast: Boolean);
begin
// AMessage is the JSON body WhatsApp posted. This event runs on the
// server's connection thread, so queue user interface updates.
TThread.Queue(nil,
procedure
begin
Memo1.Lines.Add(AMessage);
end);
// Leave ABroadcast True to forward the payload to every connected receiver.
end;