Getting started with TMS FNC WhatsApp Server
Prerequisites
- TMS FNC Core and TMS FNC WebSocket installed (see Installation).
- A Meta developer app with the WhatsApp product and a WhatsApp Business account.
- A public domain name for the server and a certificate for it from a trusted certificate authority, plus the OpenSSL libraries next to the executable.
Add the component
- Drop
TTMSFNCWhatsAppServerfrom the TMS FNC WebSocket palette page onto a form, or create one at runtime. - Set
Port(typically443) andVerifyTokento a string of your choice. - Set
CertificateFile,CertificateKeyFile, andRootCertificateFileto your PEM certificate files. TLS is always enabled. - Set
Active := Trueto start the server. - Register
https://<your-domain>/as the callback URL with the same verify token in the Meta dashboard, and subscribe to themessagesfield.
Inspect incoming payloads
Every payload WhatsApp posts is passed to OnRawMessage before it is forwarded to the connected receivers:
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;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// 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;
}
void __fastcall TForm1::ShowRaw()
{
Memo1->Lines->Add(FRaw);
}
void __fastcall TForm1::TMSFNCWhatsAppServer1RawMessage(TObject *Sender,
System::UnicodeString AMessage, bool &ABroadcast)
{
// AMessage is the JSON body WhatsApp posted. This event runs on the
// server's connection thread, so queue user interface updates.
FRaw = AMessage;
TThread::Queue(nullptr, ShowRaw);
// Leave ABroadcast True to forward the payload to every connected receiver.
}
Next steps
- Webhook setup — the Meta dashboard steps, verification, and HTTPS in detail.
- Forwarding messages — filter and route payloads.
- API reference — full class, property, method, and event reference.