Verify WooCommerce Cash on Delivery Orders Via WhatsApp With BotSailor Webhook Workflow

blog

12 Dec 2022

3641

In this article, I will show you how to verify a cash-on-delivery order from the customer.

 

We have also created a video tutorial on how to verify a cash-on-delivery order from the customer. 

 

You can watch the video tutorial:

 

 

It will be very helpful to protect fake orders on WooCommerce Store.

 

You can now confirm a cash-on-delivery order by sending a WhatsApp message to the buyer. The buyer will get a message on WhatsApp asking them to confirm the order by saying yes or no.

 

It will send a message to customers, asking them to confirm the order.

 

Let’s see how to do that by using the BotSailor. 

 

First, you need to create a message template in BotSailor, the message template that will be sent to customers as soon as they create a Cash on Delivery order.

 

Second, you have to create a new Webhook workflow and add the Webhook to the WooCommerce store. Then, you have to map data.

 

To create a message template, follow the instructions step by step:

 

     

  1. , Go to the Dashboard of BotSailor -> Click on the Bot Manager menu in the left sidebar of the Dashboard -> click on the message template option.
  2.  

 

Before creating the message template, you have to create variables. At the bottom of the page, you will see the Template variable section.

 

To create a variable follow the below instructions: 

 

     

  1. Click on the create button -> provide a name for the variable in the Name field -> Click on the Save button.
  2.  

  3. In this way, create two variables – Product list and Total price. 
  4.  

 

To create a message template, follow the instructions below:

 

     

  1. Click on the create button -> provide a name in the template name field -> write a message in the message body -> use the two variables -- total price and product list.
  2.  

  3. Click on the Quick Reply option -> write confirm order in the first Button Text field -> write cancel order in the second Button Text field -> click on the save button. 
  4.  

  5. Click on the Check status button to see the status of the message template. 
  6.  

 

Read the blog to know more on how to create message template by BotSailor:

 

How to create a Message Template for WhatsApp by BotSailor

 

You need to create postbacks for those quick replies. 

 

To create postback follow the instructions:

 

     

  1. Click on the Postback option -> Click on Create button.
  2.  

  3. Configure the Start Bot Flow component. Double-click on the Start Bot Flow component.
  4.  

  5. Provide a title in the Title field. Choosing a Label and choosing a sequence is optional. 
  6.  

  7. Click on the Save button.
  8.  

  9. Add a Text element to the Start Bot Flow component.
  10.  

  11. Configure the Text element.
  12.  

  13. Double-click on the Text element -> writes a message in the field -> click on ok button.
  14.  

  15. Click on the Save button.   
  16.  

 

 

In this way, you have to create two postback -- Confirm Order and Cancel Order. You have to use the two postback for the two quick replies. 

 

Now you have to create a Webhook workflow. To create a webhook workflow, follow the instructions below:

 

     

  1. Click on the Webhook Workflow menu in the left sidebar of the dashboard. 
  2.  

  3. Click on the create button
  4.  

  5. Scroll down to the bottom of the page to the Workflow details section. 
  6.  

  7. Provide a name in the Workflow name field -> Then select the message template you have created to verify woocommerce order.  
  8.  

  9.  Click on the create workflow button.
  10.  

 

 

 

     

  • Now copy the Webhook URL.
  •  

 

 

 

 

     

  1. Go to your WordPress dashboard admin dashboard ->the WooCommerce plugin-> click on settings -> click on the Advance tab.
  2.  

  3. Click on the Webhooks option on the advanced settings page.
  4.  

  5. Click on the Add Webhook button. 
  6.  

 

 

 

 

 

 

 

Instantly, the Webhook data form will appear. Fill out the form: 

 

     

  1. Provide a name in the Name field. 
  2.  

  3. Select Active in the Status field. 
  4.  

  5.  Select Order Created in the Topic field.
  6.  

  7. In the Delivery URL field, paste the Webhook Callback URL that you have copied from the BotSailor.
  8.  

  9. Now Click on the Save Webhook button.  
  10.  

 

 

Now, you need to provide sample data for mapping. 

 

     

  1. Now go to BotSailor.
  2.  

  3. Click on the Capture Webhook Response.
  4.  

 

 

 Instantly, the Webhook Response Mapping page will appear with raw data.

 

 

It is sample data. When a Webhook is added, the sample data will be provided automatically. Just ignore this data.

 

 

     

  1. To do that, go to the WooCommerce store -> make a purchase order in WooCommerce.
  2.  

 

 

     

  1. Now return to BotSailor-> click on the Connection details button
  2.  

  3. Wait a few moments to get the real data collected from the order.
  4.  

 

After getting the real data, you have to configure the Webhook Response Mapping. To configure the Webhook Response Mapping, you have to fill out some fields.

 

     

  1. select the billing->phone number option in the Phone Number field.
  2.  

  3. Create and set a formatter to remove the plus sign from the phone number. (Because WhatsApp can’t send messages to a phone number that has a plus sign before the number.  )
  4.  

  5. Select total price in the total price variable field. 
  6.  

  7. Select line_items in the Product list variable field.
  8.  

 

 

You have to use a formmater for the product list because there may be one item in the order. 

 

Now let's see how to create a formatter for the product list.

 

     

  1. Click on the new button in Data formatter section. 
  2.  

  3. Provide a name in the Name field. 
  4.  

  5. Select concat list items in the Action field. 
  6.  

  7. Put a comma in the glue field. 
  8.  

  9. Write "name" in the position field. 
  10.  

  11. Click on the Save Formatter button
  12.  

 

 

     

  1. Now select the formatter in the product list field. 
  2.  

 

 

Now you have to select postback for the quick reply buttons in the message template. 

 

     

  1. Select Confirm order postback for the Confirm order field
  2.  

  3. Select Cancel order postback for the Cancel order field
  4.  

 

 

So, when the user clicks on the button, they will get a reply. Also, we need to confirm or cancel the order according to the button they click.

 

For that, we will use Call back APIs. Now, we will set up the API for confirming or canceling the order. For the "confirm order" button click, a note will be added to the order. The order will be cancelled if you click the Cancel Order button.

 

You can use only the "confirm order" button or both of them.

 

Let’s see how to create Callback APIs.

 

     

  1. To create a Callback API, click on the new button
  2.  

  3. Provide a name in the name field.
  4.  

  5. Select WooCommerce order note update in the API action field
  6.  

  7. In the Select Store API field, select an integrated WooCommerce Store.
  8.  

  9. Write a note in the Note field.
  10.  

  11. Click on the Save Callback API button.
  12.  

 

 

 

Now for the Confirmation order, select the Callback Api you have just created now.

 

 

 

 

Likewise, you have to create another callback API for cancel order button.

 

 

After you have created the Callback Api, select the API for cancel the order.

 

 

You don’t need to use the delay option because the message needs to be sent immediately. But you need to add a rule because this message will be sentt only to those who place the order with cash on delivery. 

 

Follow the instruction below to add a rule:

 

     

  1. Select the first option and then click on the Add rule button.
  2.  

  3. Instantly, three fields – select data field, select operator, put value –  will appear. 
  4.  

  5. In the select data field, select payment method: cod option.
  6.  

  7. In the select operator field, select Equal(=) option
  8.  

  9. Write cod, in the put value field.  
  10.  

  11. Click on the save workflow button. 
  12.  

 

 

 

 

 

 

To see report, click on the Workflow report button.

 

 

 

 

Now let's see how it works. 

 

     

  1. Go to WooCommerce and place an order with cash on delivery
  2.  

  3. Refresh the BotSailor to see if the workflow has been completed or not. Yes, the Workflow has been completed.
  4.  

  5. Let’s check on WhatsApp. 
  6.  

  7. Yes, the message has been arrived. The message has the total price and product list.
  8.  

  9. Now, if we click on the confirm button, a message will arrive and the purchase order should be confirmed on the WooCommerce shop.
  10.  

  11.  And if we click on the Cancel order button, a message will arrive and  it will cancel the order.
  12.  

  13. Let’s go to WooCommerce to check the order.
  14.  

 

 

 

 

 

 

 

 

 

     

  1. Let’s go to WooCommerce to check the order.
  2.  

  3. Click on the order, you can see that the note has been updated.
  4.  

 

 

 

 

 

     

  1. Make another order.
  2.  

  3.  After the BotSailor sends the WhatsApp message, let’s click on the Cancel button.
  4.  

  5. go to the WooCommerce store order,
  6.  

  7.  The order has been cancelled.
  8.  

 

 

This is how you can use BotSailor’s WhatsApp integration with your WooCommerce store to verify the cash on delivery orders.

 

Thank you for reading the article. 

Share This Post
author
Written by

Kamrul Hasan

➢  more from this author

Comments (0)