03 Oct 2026 · 13 views
The real power of an API is automation. A customer fills your enquiry form, and within seconds they get a WhatsApp message from your business. No one has to copy numbers by hand.

recipient and message) and the address of the page (like /send/whatsapp).

Turn the switch Off again and the page goes back to the simple view: the code tabs and the technical names hide, and the fold closes.
Put this where your form is saved (after you save the enquiry in your database):
<?php
// Your key is kept in a server setting called EPT_API_KEY, not in the code
$name = trim(str_replace('|', ' ', $_POST['name'] ?? ''));
$mobile = $_POST['mobile'] ?? '';
$ch = curl_init('https://epublictouch.com/app/api/send/whatsapp');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('EPT_API_KEY')],
CURLOPT_POSTFIELDS => [
'recipient' => $mobile,
'type' => 'template',
'template' => 'enquiry_thanks',
'params' => $name !== '' ? $name : 'there',
'name' => $name,
],
]);
$answer = json_decode((string) curl_exec($ch), true);
curl_close($ch);
// $answer['result'] is "success" or "failed"; $answer['message'] says why
What each part does:
Authorization: Bearer … sends the key in a header. This is safer than putting it in the link.recipient is the mobile number from your form. A 10-digit Indian number is fine.params fills {{1}} of the template with the customer's name. We remove the | sign from the name because | separates values.name saves the customer's name in your Contacts if the number is new.Add your key to wp-config.php:
define('EPT_API_KEY', 'paste-your-key-here');
Then add this to your theme's functions.php (or a small plugin). Change your-name and your-phone to your form's field names:
add_action('wpcf7_mail_sent', function ($form) {
$data = WPCF7_Submission::get_instance()->get_posted_data();
$name = trim(str_replace('|', ' ', $data['your-name'] ?? ''));
wp_remote_post('https://epublictouch.com/app/api/send/whatsapp', [
'timeout' => 20,
'headers' => ['Authorization' => 'Bearer ' . EPT_API_KEY],
'body' => [
'recipient' => $data['your-phone'] ?? '',
'type' => 'template',
'template' => 'enquiry_thanks',
'params' => $name !== '' ? $name : 'there',
'name' => $name,
],
]);
});
This sends a template to every row of your sheet and writes the result in column D. Your sheet: A = name, B = mobile, C = order number, D = status (leave empty).
EPT_API_KEY, value: your key. This keeps the key out of the code.sendToAllRows and click Run. Allow access the first time.function sendToAllRows() {
var key = PropertiesService.getScriptProperties().getProperty('EPT_API_KEY');
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange().getValues();
for (var i = 1; i < rows.length; i++) { // row 1 has the headings
var name = rows[i][0], mobile = rows[i][1], order = rows[i][2], status = rows[i][3];
if (!mobile || status === 'Sent') continue; // skip empty and already sent rows
var res = UrlFetchApp.fetch('https://epublictouch.com/app/api/send/whatsapp', {
method: 'post',
headers: { Authorization: 'Bearer ' + key },
payload: {
recipient: String(mobile),
type: 'template',
template: 'order_update',
params: [name, order].join('|'),
ref: 'sheet-row-' + (i + 1)
},
muteHttpExceptions: true
});
var answer = JSON.parse(res.getContentText());
sheet.getRange(i + 1, 4).setValue(answer.result === 'success' ? 'Sent' : answer.message);
Utilities.sleep(600); // a small gap between messages
}
}
ref is your own ID for each row. If you run the script twice by mistake, the same row is not sent again for 24 hours.Use the tool's "Webhook" or "HTTP request" step:
https://epublictouch.com/app/api/send/whatsappAuthorization = Bearer YOUR_API_KEYrecipient, type, template, params (form or JSON, both work)result in the answer and save message when it fails. It tells you exactly what went wrong.Something not working? Part 9 explains every error message in simple words, with what to do.
Next: Part 9 — Errors and limits
Try everything live in the API Tester.