Notifications with WhatsApp

Send automated notifications with customizable templates in your WooCommerce Store.

Feature Overview

↑ Back to top

With the Notifications with WhatsApp, you will have an integration with WhatsApp Cloud API to automatically send purchase data to buyers and sellers for the following actions:

  • New Order Notification for Sellers
  • New Order Notification for Customers
  • Update Order Status Notification for Customers
  • Abandoned Cart Notification for Customers
  • View Received Messages
  • Reply to Received Messages

Installation

↑ Back to top

See the steps to install the plugin:

  1. Download the extension from your WooCommerce dashboard.
  2. Go to Plugins > Add New > Upload and select the ZIP file you just downloaded.
  3. Click Install Now and then Activate.

Activation

↑ Back to top

Go to menu WooCommerce > Notifications with WhatsApp:

WhatsApp Connection Settings Cloud API Credentials

↑ Back to top

Enter your WhatsApp Cloud API credentials to connect your store and automatically send messages that have been configured in Message Templates.

Enable Log Cloud API -> Enable to record a log of communication between the store and the WhatsApp Cloud API on each purchase via WhatsApp

API Token -> Get your API token from WhatsApp

API Phone Number -> Get your API Phone number from WhatsApp

WhatsApp Business Account ID -> Get your Live WhatsApp Business Account ID from WhatsApp

Phone Number To -> Get your phone number that will be sent the message on WhatsApp. Example: 5511999999999

Enable check as default the input -> Enable to check as default the input: I want to receive order notifications via WhatsApp in checkout

WhatsApp Connection Webhook callback URL

↑ Back to top

Subscribe to Webhooks to get notifications about messages your business receives. Read more

Webhook URL -> Url that must be added in the webhook Meta

Verify Token -> Token that must be added in the webhook Meta

Message Template New Order Seller

↑ Back to top

Create the template message for sending new order messages to the seller:

Message Template New Order Customer

↑ Back to top

Create the template message for sending new order messages to the customer:

Message Template Update Order Status Customer

↑ Back to top

Create the template message for sending update order status messages to the customer:

Message Template Abandoned Cart Customer

↑ Back to top

Create the template message for sending abandoned cart messages to the customer:

Received Messages

↑ Back to top

View messages received on WhatsApp from customers who receive notifications

Reply to messages received on WhatsApp from customers who receive notifications

Usage

↑ Back to top

See how using the plugin works and how configure:

New Order

↑ Back to top

Update Order

↑ Back to top

Abandoned Cart

↑ Back to top

Order Note

↑ Back to top

Configuration Meta Business

↑ Back to top

For the plugin to work, you need to make some settings within Meta Business, see how to configure it below:

Tutorial Configure Meta Business

↑ Back to top

See the tutorial on how to configure Meta Business:

Create a Business Account

↑ Back to top

Access the link https://business.facebook.com and register your company, and then link this account to your business’s social networks (Facebook and Instagram)

To create an account you can also check: Create a Business Account in Meta Business Manager

To link this account to your company’s social networks, you can check: Add a Page to your Business Account

Verify your business

↑ Back to top

To use WhatsApp features, it is important that you complete a Business verification.

This is necessary to be able to fully use WhatsApp Cloud API credentials without intermediaries. Only people with full control of a business account can complete this process.

To complete Business verification you can check: Verify your business

Generate WhatsApp Cloud API credentials

↑ Back to top

Finally, we must generate a WhatsApp Cloud API credentials token temporary for tests.

To generate a token you can check: Using Authorization Tokens for the WhatsApp Business Platform or Add The WhatsApp Product To Your App

Creating a Permanent Access Token

↑ Back to top

Knowing that you need to use a bearer token in the Authorization header of an HTTP request is helpful, but it’s not enough. The only access token you’ve seen so far is temporary. Chances are that you want your app to access the API for more than 24 hours, so you need to generate a longer-lasting access token.

To create a system user, do the following:

  1. Go to Business Settings.
  2. Select the business account your app is associated with.
  3. Below Users, click System Users.
  4. Click Add.
  5. Name the system user, choose Admin as the user role, and click Create System User.
  1. Select the whatsapp_business_messaging permission.
  2. Click Generate New Token.
  3. Copy and save your token.

Add a Real Business Number

↑ Back to top

With your test business number and test WhatsApp business account, you can begin to develop your application.

When you use these test assets, you don’t pay to send messages as you work to develop your app.Once you are ready to start sending messages to your customers, you can add a real business phone number in the API Setup panel and create a real WhatsApp Business Account.

  1. Navigate to the Meta App that is set-up for WhatsApp by going to developers.facebook.com > My Apps > Select your App.
  2. Use left menu to navigate to the WhatsApp > API Setup panel.
  3. On the right pane select Add phone number button under Step 5: Add a phone number.

If your phone number is currently registered with WhatsApp Messenger or the WhatsApp Business App, you need to first delete it. You will not be able to use that number on the WhatsApp Business app simultaneously. Your number must be used on the Business Platform or Business App.

You can also check: Add a Phone Number

Configure Webhook Callback

↑ Back to top

1 – To receive messages on WhatsApp that sends notifications In the APP go to WhatsApp > Configuration:

2 – In webhook, click edit and add the url and verification token generated by the plugin:

3 – After verifying the token, in Webhook fields, click Manage, select all fields and click done:

Message Templates

↑ Back to top

WhatsApp message templates are specific message formats that companies use to send notifications or customer service messages to people who have opted in to receive notifications.

For the message to reach its destination, it is necessary to create the template for each model.

Tutorial Create Messages

↑ Back to top

See the tutorial on how to create the messages that will be sent:

Create Message Template New Order Seller / Customer

↑ Back to top

1 – Create the template message for sending notifications for Seller and/or Customer

Name -> Name your message template
Languages -> Choose languages for your message template.
Header -> Add a title or choose which type of media you’ll use for this header
Footer -> Add a short line of text to the bottom of your message template
Body -> Enter the text for your message in the language you’ve selected

2 – After creating the model, click in button Sent to API and wait for the status to change to approved. (This approval may take up to 24 hours)

You can also track the approval status of the message template within Meta Business at: WhatsApp Manager > Account tools > Message templates

3 – Once approved, the status will change and the messages will be sent

Create Message Template Update Order Status Customer

↑ Back to top

1 – Create the template message for sending update order status messages to the customer

Status Order -> Choose which order status represents this template message
Name -> Name your message template
Languages -> Choose languages for your message template.
Header -> Add a title or choose which type of media you’ll use for this header
Footer -> Add a short line of text to the bottom of your message template
Body -> Enter the text for your message in the language you’ve selected

2 – After creating the model, click in button Sent to API and wait for the status to change to approved. (This approval may take up to 24 hours)

You can also track the approval status of the message template within Meta Business at: WhatsApp Manager > Account tools > Message templates

3 – Once approved, the status will change and the messages will be sent

Create Message Template Abandoned Cart Customer

↑ Back to top

1 –  Create the template message for sending abandoned cart messages to the customer

Name -> Name your message template
Languages -> Choose languages for your message template.
Header -> Add a title or choose which type of media you’ll use for this header
Footer -> Add a short line of text to the bottom of your message template
Body -> Enter the text for your message in the language you’ve selected

2 – After creating the model, click in button Sent to API and wait for the status to change to approved. (This approval may take up to 24 hours)

You can also track the approval status of the message template within Meta Business at: WhatsApp Manager > Account tools > Message templates

3 – Once approved, the status will change and the messages will be sent

Test Message Template Abandoned Cart Customer

↑ Back to top

If you want to test an abandoned cart, follow the tutorial:

Variables Message Template

↑ Back to top

Allows you to personalize your messages for each recipient by entering customer and order information.

transactionIDInsert Order ID
Example: 283
transactionTaxInsert Order Tax
Example: 10.00
transactionShippingInsert Order Shipping
Example: 10.00
transactionTotalInsert Order Total
Example: 18.00
dateCreatedInsert Order Date
Example: 2023-05-16 – 02:01:51
userInfoInsert User Info Complete
Example: First name: John
Last name: Smith
Company name: Store
Country / Region: US
Street address: My Street
Apartment, suite, unit, etc.: 132
Town / City: Kingston
State / County: New York
Postcode / ZIP: 12401
Phone: 555-1212
Email address: johnsmith@email.com
userNameInsert User Name
Example: John Smith
userPhoneInsert User Phone
Example: 555-1212
userAddressInsert User Address
Example: My Street, 132 – Kingston, New York – 12401
productsInsert List Products Order
Example: 1x Beanie – value: 18 – cód: 18
customFieldInsert Custom Field
Example: Tracking Url, Order Invoice, etc

Update Message Template

↑ Back to top

After editing the message, it is important that you send the changes again by clicking the Update from API button

Exclude Message Template

↑ Back to top

You can remove the message by clicking the Exclude from API button

Custom Field

↑ Back to top

The Custom Field is designed to add information to your order that is not part of the standard order variables. You can use it to send: Tracking Link, Tracking Code, Order Invoice and any other relevant information you want to send.

For this, you can use the notifications_with_whatsapp_before_send_fields_message hook.

See video tutorial of how to use hook:

See more examples of how to use hook:

1 – Insert a Custom Field Variable in Message Template

2 – Create a Custom Field in Order

3- Insert Code for send Tracking url and Order Invoice in the message:

/**
 *  Fired before sending a message to WhatsApp
 *  This hook contains an empty string that must be the function's return with the desired value to be inserted in the custom field
 *  This hook contains an Order object (WC_Order) related to the message that will be triggered.
 *  Can be used to insert a non-default custom_field into the message.
 *
 * @param string $custom_field Empty string to be changed
 * @param object $order Order (Wc_Order)
 */
function my_custom_hook_notifications_with_whatsapp_before_send_fields_message( $custom_field, $order ){
    $order_id = $order->get_id();
    $tracking_url = $order->get_field('tracking_url');
    $order_invoice = $order->get_field('order_invoice');
    return 'Tracking url: ' . $tracking_url . '\n Order Invoice: ' . $order_invoice;
}
add_filter( 'notifications_with_whatsapp_before_send_fields_message', 'my_custom_hook_notifications_with_whatsapp_before_send_fields_message', 10, 2 );

You can also take advantage of the functions of other plugins that create their own fields in the order and then send them in the messages:

Code example for send Tracking number and Tracking url in the message using the plugin Advanced Shipment Tracking for WooCommerce instead of custom fields:

/**
 *  Fired before sending a message to WhatsApp
 *  This hook contains an empty string that must be the function's return with the desired value to be inserted in the custom field
 *  This hook contains an Order object (WC_Order) related to the message that will be triggered.
 *  Can be used to insert a non-default custom_field into the message.
 *
 * @param string $custom_field Empty string to be changed
 * @param object $order Order (Wc_Order)
 */
function my_custom_hook_notifications_with_whatsapp_before_send_fields_message( $custom_field, $order ){
    if ( function_exists( 'ast_get_tracking_items' ) ) {
	
        $order_id = $order->get_id();         
        $tracking_items = ast_get_tracking_items($order_id);
        $tracking_number='';
        $tracking_provider='';
        $tracking_url='';
        $date_shipped='';
        
        foreach($tracking_items as $tracking_item){		
            $tracking_number = $tracking_item['tracking_number'];
            $tracking_provider = $tracking_item['formatted_tracking_provider'];
            $tracking_url = $tracking_item['formatted_tracking_link'];
            $date_shipped = date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] );							
        }
    }
    return 'Tracking number: ' . $tracking_number . '\n Tracking url: ' . $tracking_url;
}
add_filter( 'notifications_with_whatsapp_before_send_fields_message', 'my_custom_hook_notifications_with_whatsapp_before_send_fields_message', 10, 2 );
Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.