Go back

How to send automated Shopify order notifications on WhatsApp

Mohamed Elbadwihi
October 28, 2022

In this blog post, you’ll learn how to send automated Shopify order notifications as WhatsApp messages to your customers. It takes about 30 minutes to 1 hour to set this up, and we’ll use “Order fulfilled” as an example in this guide. You can customize the automation to your exact needs. 

What you need

Before we continue, you’ll require a few things for this to work:

  1. A Shopify store (If you’re using a different eCommerce platform, let us know here.)
  2. A WhatsApp Business Platform account connected to Rasayel – We’ll be using the Rasayel API to send WhatsApp messages to your contacts.
  3. A WhatsApp message template for order confirmations.
  4. A MESA account (Shopify automation platform) – We’ll use this to create the automation. MESA offers a limited free plan which you can use to test this out on your store.

If you’re unfamiliar with the WhatsApp Business Platform, I suggest you read the following:

What is the WhatsApp Business API

If you’re unfamiliar with message templates, I recommend The Complete Guide to WhatsApp Message Templates.

What we're going to build

Here’s the flow we’re going to build:

Here’s what it will look like on your customer’s phone:

Let’s get started!

This guide assumes you have admin access to Shopify, Rasayel, and MESA. Please follow every step with care.

1. Prepare WhatsApp template

First, let’s make sure you have your WhatsApp template ready on Rasayel. If you don’t, you can create one by following this guide.

Here’s the template I’m going to use. Feel free to copy it:

Template name: order_ready_shipment
Template header (Text): Order ready for shipment
Template body: Hello {{1}}, your order number {{2}} has been prepared for shipment. You will receive your item within the next {{3}}. 
You may track your order status here: {{4}}

You’ll also need to have your channel ID and template ID ready. You can obtain this from the Rasayel dashboard. Go to Settings → Channels → WhatsApp, and select your template from the list:

Your channel ID will be in the URL, along with your template ID, as shown below:

2. Prepare Rasayel API key

Go to your Rasayel dashboard, select Settings → API Management. Click on New API key:

Give your API key a name, and click on Create:

Your API key is now ready. We’ll be using the Basic Auth value. You can access this later from the Rasayel dashboard, or store it in your password manager:

3. Create MESA automation 

If you don’t have MESA installed on your Shopify store, go ahead and do that now. You can install the app from the Shopify app store; click Add App and follow the instructions on the screen:

Next, we’re going to create the automation we need. In your MESA dashboard, click on Automation, and select Create New Workflow:

Select Shopify from the list of apps to connect:

You’ll be presented with a list of triggers that you can choose from. Feel free to explore the list and customize the workflow at this point. For example, you may wish to send a WhatsApp message when an order is paid, instead of when it’s ready for shipment.

I’m going to select Order Fulfilled as my trigger. Click Start:

In the following screen, search for API, and select API by MESA. This will allow us to make use of the Rasayel API to send WhatsApp messages:

Next, we’ll select No Authentication as the authentication method. Don’t worry; we will be authenticating the connection in a different way:

In your step configuration, select Post as the Method, and enter https://api.rasayel.io/api/graphql as the URL:

The Request Body should be empty. Select Advanced Options:

Make sure content type is application/json, and click on Add header:

This is where we’ll add our API authentication key. For Key, type Authorization. For Value, type Basic, leave a space, and then paste your Basic Auth value from Step #2: 

We’re almost there!

4. Create your API request (Be careful here!)

After adding your authentication key, scroll down and select Specify a custom request body. This is where you’ll enter the query that will send an automated WhatsApp message to your customers. Remember the channel ID and template ID we obtained in step 2? Grab those now.

Here’s what my request looks like:

Don’t be intimidated by how complex it looks. It’s fairly simple, but it’s important that you follow these instructions with care. First, here is the request for you to copy:

{"query":"mutation TemplateProactiveMessageCreate($input: MessageProactiveTemplateCreateInput!) {\n  templateProactiveMessageCreate(input: $input) {\n    clientMutationId\n  }\n}","variables":{"input":{"messageTemplateId":164448,"channelId":100,"components":[{"parameters":[{"text":"{{shopify.customer.first_name}}","type":"TEXT"},{"text":"{{shopify.id}}","type":"TEXT"},{"text":"5 days","type":"TEXT"},{"text":"www.shoptrack.com/shop/12/{{shopify.id}}","type":"TEXT"}],"type":"BODY"}],"receiver":"{{shopify.customer.phone}}"}}}

Let me break it down. The first part is code that tells our API what you’re trying to do. There’s nothing you need to change there. We’ll only concern ourselves with what comes after the word variables.

Your template ID will go after messageTemplateId. In the above example, my template ID is 16448. Replace this number with your ID. 

Your channel ID will go after channelID. In the above example, mine is 100. Replace this with your channel ID.

Then comes the part of the script where we define what the variables in the template are. Since this is an automation, we want to make sure that each template is customized to fit each person it’s sent to. The general format for this is:

[{"text":"variable one","type":"TEXT"}]

If there are two templates, it becomes the following:

[{"text":"variable one","type":"TEXT"},{"text":"variable two","type":"TEXT"}]

And so on. In the template I’m using, I have four variables:

Hello {{1}}, your order number {{2}} has been prepared for shipment. You will receive your item within the next {{3}}. 
You may track your order status here: {{4}}

Your template might be different, and you may need to adjust the script to match. As I mentioned, we need to use dynamic data to ensure that the template fits the person we’re sending it to, and the order that’s being fulfilled. MESA allows us to do this in an easy manner.  For instance, the code for the customer’s name that’s attached to the order is {{shopify.customer.first_name}}. You’ll notice that in my script above. Here it is again, with the variables highlighted:

{"query":"mutation TemplateProactiveMessageCreate($input: MessageProactiveTemplateCreateInput!) {\n  templateProactiveMessageCreate(input: $input) {\n    clientMutationId\n  }\n}","variables":{"input":{"messageTemplateId":164448,"channelId":100,"components":[{"parameters":[{"text":"{{shopify.customer.first_name}}","type":"TEXT"},{"text":"{{shopify.id}}","type":"TEXT"},{"text":"5 days","type":"TEXT"},{"text":"www.shoptrack.com/shop/12/{{shopify.id}}","type":"TEXT"}],"type":"BODY"}],"receiver":"{{shopify.customer.phone}}"}}}

In this example, I’m adding the customer’s name to the template, along with their order ID. I’m also creating a parcel tracker link that is a combination of their order ID and my shipment tracking website, and finally, I use shopify.customer.phone as the target of the message.

If you wish to add more variables, or to use different kinds of variables in your template, you can see a list of all the data that MESA has access to by clicking on the {+} button at the bottom of the request box. You’ll be able to access variables such as your customer’s email address, shipping address, order details, and more:

5. Test your automation

If you’re confident that you’ve set up everything correctly, click on Done, and then Test. This will allow you to test your automation without using actual Shopify customer data. You can replace {{shopify.customer.phone}} with your own phone number for testing, and then change it back later:

If everything went well, you should see the following on your phone:

Congratulations! 🥳 You’ve now created an automated order notification on WhatsApp!

Learn more

Further reading: The importance of WhatsApp for your Shopify store

If you’d like to learn more about how WhatsApp can help you grow your Shopify store, please reach out to us on WhatsApp at: +13024070488

We also offer a free consultation session where we go through your use case, answer any questions you have about WhatsApp, and help you build a strategy to make the best out of the platform. Book a call with us here. We’d love to speak you:

For Europe, Middle East, and Africa

For North and South America

Table of contents

Focus on your business.
Let Rasayel manage the chaos

Your customers, and your team, will thank you for it