Enquiry sent automatically to WhatsApp

Enquiry sent automatically to WhatsApp

Someone submits the inquiry form on your WordPress site, the inquiry details should be sent automatically to your WhatsApp number (not just email).

There are 2 practical methods:

Method 1: Redirect user to WhatsApp (Simple & Free)

This method opens WhatsApp with the inquiry filled in, but the user has to press send.

Example with Contact Form 7

  1. Install Contact Form 7 plugin.

  2. Add a hidden redirect script in functions.php:

    add_action('wpcf7_mail_sent', 'redirect_to_whatsapp');
    
    function redirect_to_whatsapp($contact_form) {
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $data = $submission->get_posted_data();
            
            $name = urlencode($data['your-name']);
            $email = urlencode($data['your-email']);
            $message = urlencode($data['your-message']);
    
            $whatsapp_url = "https://wa.me/919876543210?text=New%20Inquiry%0AName:%20$name%0AEmail:%20$email%0AMessage:%20$message";
    
            echo "<script>window.open('$whatsapp_url','_blank');</script>";
        }
    }
    
    

Replace 919876543210 with your WhatsApp number.
This will open WhatsApp with the inquiry message ready to send.

Method 2: Auto-send to WhatsApp (Professional Way)

For automatic sending (without user interaction), you must use WhatsApp Business API (Meta Cloud API, Twilio, Gupshup, etc.).

Example using Meta WhatsApp Cloud API:

  1. Get WhatsApp Cloud API access token from Meta Developer Portal.

  2. Get your Phone Number ID.

  3. Add this code in functions.php:

    add_action('wpcf7_mail_sent', 'send_whatsapp_message');
    
    function send_whatsapp_message($contact_form) {
        $submission = WPCF7_Submission::get_instance();
        if ($submission) {
            $data = $submission->get_posted_data();
    
            $name = $data['your-name'];
            $email = $data['your-email'];
            $message = $data['your-message'];
    
            $msg = "📩 New Inquiry\n\nName: $name\nEmail: $email\nMessage: $message";
    
            $url = "https://graph.facebook.com/v19.0/YOUR_PHONE_NUMBER_ID/messages";
            $token = "YOUR_ACCESS_TOKEN";
    
            $body = json_encode([
                "messaging_product" => "whatsapp",
                "to" => "91XXXXXXXXXX",   // Your WhatsApp Number
                "type" => "text",
                "text" => ["body" => $msg]
            ]);
    
            $args = [
                'body'    => $body,
                'headers' => [
                    'Authorization' => 'Bearer '.$token,
                    'Content-Type'  => 'application/json'
                ]
            ];
    
            wp_remote_post($url, $args);
        }
    }
    
    

This will auto-send the inquiry details to your WhatsApp number in the background whenever a user submits the form.

Previous Article

Gemini chatbot : create for WordPress Plugin

Next Article

Contact Form 7 inquiries go Email and WhatsApp automatically

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨