Same time, the details are sent automatically to your WhatsApp using the WhatsApp Cloud API.
Step 1: Create Contact Form 7 Form
Add a new CF7 form with this shortcode:
[contact-form-7 id="123" title="Inquiry Form"] <p> Name (required)<br> [text* your-name] </p> <p> Email (required)<br> [email* your-email] </p> <p> Phone<br> [tel your-phone] </p> <p> Message<br> [textarea your-message] </p> <p> [submit "Send Inquiry"] </p>
Replace 123 with your actual form ID.
Step 2: Email Setup
In the Mail tab of CF7, configure:
To: yourmail@example.com
Subject: New Inquiry from Website
Message Body:
Name: [your-name] Email: [your-email] Phone: [your-phone] Message: [your-message]
This ensures you get inquiries in your email.
Step 3: WhatsApp Auto-Send (functions.php)
Now add this code to your theme’s functions.php or a site-specific plugin:
// Send Contact Form 7 inquiry to WhatsApp Cloud API
add_action('wpcf7_mail_sent', 'cf7_send_to_whatsapp');
function cf7_send_to_whatsapp($contact_form) {
$submission = WPCF7_Submission::get_instance();
if ($submission) {
$data = $submission->get_posted_data();
// Collect form fields
$name = sanitize_text_field($data['your-name']);
$email = sanitize_email($data['your-email']);
$phone = sanitize_text_field($data['your-phone']);
$message = sanitize_textarea_field($data['your-message']);
// Format WhatsApp message
$msg = "📩 *New Inquiry Received* \n\n".
"👤 Name: $name\n".
"📧 Email: $email\n".
"📞 Phone: $phone\n".
"💬 Message: $message";
// WhatsApp Cloud API credentials
$url = "https://graph.facebook.com/v19.0/YOUR_PHONE_NUMBER_ID/messages";
$token = "YOUR_ACCESS_TOKEN";
// Replace with your destination WhatsApp number
$recipient = "91XXXXXXXXXX";
$body = json_encode([
"messaging_product" => "whatsapp",
"to" => $recipient,
"type" => "text",
"text" => ["body" => $msg]
]);
$args = [
'body' => $body,
'headers' => [
'Authorization' => 'Bearer '.$token,
'Content-Type' => 'application/json'
]
];
wp_remote_post($url, $args);
}
}
Step 4: Replace with Your Details
-
YOUR_PHONE_NUMBER_ID→ from Meta WhatsApp Cloud API setup. -
YOUR_ACCESS_TOKEN→ permanent access token from Meta Developer Portal. -
91XXXXXXXXXX→ your WhatsApp number (with country code, no+).
Now, when a user submits the form:
-
You’ll get an email with inquiry details.
-
The same details will be pushed to your WhatsApp automatically.
If you’re using WordPress, chances are you already rely on Contact Form 7 (CF7) to collect inquiries. But what if you could instantly receive those messages on WhatsApp as well as email?
In this complete guide, you’ll learn how to send Contact Form 7 submissions directly to WhatsApp automatically, using a modern and reliable method. This tutorial is beginner-friendly, production-ready, and optimized for real-world usage.
Why Send Contact Form 7 Messages to WhatsApp?
Email notifications are useful, but they’re often slow and overlooked. WhatsApp gives you:
- ⚡ Instant notifications
- 📱 Higher response rate
- 💬 Real-time customer interaction
- 🔥 Better lead conversion
For businesses, this can significantly improve response time and customer engagement.
How It Works
When a user submits a Contact Form 7 form:
- CF7 triggers a hook (wpcf7_mail_sent)
- A custom PHP function captures form data
- The data is sent to WhatsApp via API
- You receive the message instantly on WhatsApp
Requirements
Before starting, make sure you have:
- WordPress website
- Contact Form 7 plugin installed
- Basic PHP access (theme functions.php or custom plugin)
- WhatsApp API (Cloud API or third-party service)
🛠 Common Errors & Fixes
❌ Message Not Sending
- Check API token
- Verify phone number format (with country code)
❌ CF7 Hook Not Triggering
- Ensure correct form fields
- Check plugin conflicts
❌ Hosting Blocking Requests
- Enable cURL
- Check firewall rules
Security Best Practices
- Never expose API keys publicly
- Validate user input
- Use HTTPS
- Limit API requests
- Sanitize all form data
⚡ Performance Tips
- Use async processing (queue system)
- Avoid blocking requests
- Log failures for debugging
SEO Benefits of WhatsApp Integration
- Faster lead response = better conversions
- Improved user engagement
- Lower bounce rates
- Better customer trust