TTMSFNCCloudWhatsApp
Usage
The TTMSFNCCloudWhatsApp
component provides access to the WhatsApp Business Cloud API
. You can use this component to send various messages to users.
API Key.
This API works directly from your business account. This does not work on behalf of a user. As such, there is no log in or authentication required. You only need to provide your API Key and Phone number ID. These are used in the call as is. Do not distribute this information in a client application.
Properties
Property name |
Description |
PhoneNumberID |
ID of the phone number you want to use to send messages. Configured using the online WhatsApp platform |
APIVersion |
Set the target version of the the WhatsApp Business Cloud API . Defaults to version 14.0 |
Files |
Readonly list of all uploaded Files. After uploading/sending files for the first time these will be added automatically. |
Messages |
ReadOnly list of all sent messages. |
Methods
Method name |
Description |
CreateContact |
Creates a Contact object with some basic properties. Returns this contact |
UploadAudio |
Uploades a audio file or stream to the WhatsApp API |
UploadDocument |
Uploades a document file or stream to the WhatsApp API |
UploadSticker |
Uploades a Sticker file or stream to the WhatsApp API |
UploadImage |
Uploades a Image file or stream to the WhatsApp API |
UploadVideo |
Uploades a Video file or stream to the WhatsApp API |
SendContacts |
Send A single contact object or a array of contacts to a person |
SendLocation |
Send A location to someone. Latitude and longitude are required. |
SendMedia |
Send a uploaded media file to someone. Provide the Media ID or Index in the Files property to send the correct file |
SendTextMessage |
Send a simple text message |
SendImage |
Uploades image if needed and sends it to someone |
SendAudio |
Uploades audio if needed and sends it to someone |
SendDocument |
Uploades document if needed and sends it to someone |
SendSticker |
Uploades sticker if needed and sends it to someone |
SendVideo |
Uploades video if needed and sends it to someone |
Events
Event name |
Description |
OnUploadSuccess |
Event called when a file has been uploaded. Returns the media object with ID. |
OnSendSuccess |
Event called when a message has been sent successfully! This returns the sent message. |
OnError |
Event called when an error occurs during an API Call! |
Examples
Send a simple Text Message
procedure TForm1.SendContact(Sender: TObject);
begin
TMSFNCCloudWhatsApp1.SendTextMessage('0000000000', 'Hello World');
end;
procedure TForm1.SendContact(Sender: TObject);
var
Contact: TTMSFNCCloudWhatsAppContact;
begin
Contact := TMSFNCCloudWhatsApp1.CreateContact('firstName', 'lastName');
Contact.AddPhone('Phonenumber');
Contact.AddEmail('email');
TMSFNCCloudWhatsApp1.SendContacts('00000000000', Contact)
end;