WhatsApp Confirmation for a WordPress Contact Form
A visitor fills in a contact form on your WordPress site and then gets... an automatic email that lands in the spam filter or simply never gets read. Meanwhile you only find out about a new enquiry yourself when you happen to open your mailbox. A WhatsApp confirmation, to the visitor, to yourself, or both, does get read within seconds. This article shows how to connect that to a WordPress form, without having to apply for anything at Meta or build a separate app.
The principle: form plugin calls your code, your code calls TextMeFlow
Most WordPress form plugins (Contact Form 7, WPForms, Gravity Forms) offer an "action hook" that fires as soon as a form is submitted successfully. You attach a single function to it that sends a WhatsApp message via the TextMeFlow API: a simple POST request, just like from plain PHP code. No Meta Business verification is needed: you link your WhatsApp number with a QR scan and you're done.
Contact Form 7: the wpcf7_mail_sent hook
Contact Form 7 fires the wpcf7_mail_sent hook after a form has been processed successfully. Add this to the functions.php file of your (child) theme or to a small custom plugin file:
add_action('wpcf7_mail_sent', function ($contact_form) {
$submission = WPCF7_Submission::get_instance();
if (!$submission) {
return;
}
$data = $submission->get_posted_data();
$phone = $data['tel-eigenaar'] ?? '+32472932208'; // your own number
$naam = $data['your-name'] ?? 'someone';
wp_remote_post('https://api.textmeflow.eu/v1/messages', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . getenv('TEXTMEFLOW_API_KEY'),
],
'body' => json_encode([
'to' => $phone,
'text' => "New contact request from {$naam} via the website.",
]),
'timeout' => 5,
]);
});
Use wp_remote_post() instead of curl or file_get_contents(). It's the WordPress standard, works with the built-in HTTP layer and respects any proxy settings of the hosting. Put the API key in an environment variable or a wp-config.php constant, never hardcoded in a file that ends up in git.
Gravity Forms and WPForms: a similar pattern
Gravity Forms has the hook gform_after_submission, WPForms has wpforms_process_complete. Both hand you the submitted fields as an array, in the same way as the Contact Form 7 example above. The only thing that changes is how you pull the phone number and name out of the supplied data; the wp_remote_post() call to /v1/messages stays identical.
Send to the visitor, not just to yourself
An internal notification is useful, but a direct confirmation to the visitor themselves ("Thanks for your enquiry, we'll get back to you within 1 working day") increases trust and reduces the number of "did you actually receive my message?" phone calls. The condition: the visitor must have entered a valid phone number of their own in the form. Never send unprompted to a number you got from another source.
Mind the format: TextMeFlow only accepts E.164 (+32472932208), not 0472932208 or numbers with spaces or dashes. A simple normalisation before the API call prevents a lot of failed sends:
function normaliseer_telefoonnummer(string $nummer): string {
$nummer = preg_replace('/[^0-9+]/', '', $nummer);
if (str_starts_with($nummer, '0')) {
$nummer = '+32' . substr($nummer, 1); // adjust the country code to your market
}
return $nummer;
}
What if the form gets a lot of traffic
For a contact form that's filled in sporadically, there's nothing special to worry about. If you expect peaks, for example after an ad campaign, keep your plan's rate limits in mind: the Free plan allows 20 messages per hour, Starter 60. Check your current limits and usage in /en/docs/api and consider an upgrade if a form structurally generates more volume than your current plan allows.
Getting started
You don't need a Meta Business account, an approval process or a separate server, just a WordPress site, a form plugin you already use, and a TextMeFlow account. Test the connection on your own phone number first before you put it live for visitors.
Start free on TextMeFlow →: 50 messages per month, no expiry date, no credit card needed.
Want to send WhatsApp messages via API yourself?
Free forever up to 50 messages/month. Scan a QR and send your first message within 5 minutes.
Free forever