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.