TNS
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
NEW! Try Stackie AI
API Management / CI/CD

Build a Package Tracker With WhatsApp API

The WhatsApp Business Platform Cloud API paired with Stream Chat gives you a powerful tool for real-time customer support, order tracking and automation.
Jun 12th, 2025 6:30am by
Featued image for: Build a Package Tracker With WhatsApp API
Image from Maridav on Shutterstock.

Customers expect fast, transparent updates about their orders. Think shipping status, delays, delivery confirmations and more.

The WhatsApp Business App makes it easy to communicate with your customers through features like catalogs, payments and quick replies. This is helpful for small businesses.

But once your business grows, the app starts falling short:

  • The WhatsApp Business App is designed for individual use. As the volume of ordered items grows and customer inquiries and conversations increase, it becomes unmanageable for a single person. While you can link your WhatsApp Business Account to multiple devices, that isn’t also scalable as you don’t have control over the actions staff members decide to take on your account. Not to mention that interactions will still be manual.
  • The app doesn’t have automation features for operations such as automatically sending shipping addresses and delivery notifications.
  • There’s no centralized view to track customers’ packages and interactions.

That’s where the WhatsApp Business Platform Cloud API comes in. It lets you integrate WhatsApp directly into your existing business system. And when paired with Stream Chat, you get a powerful tool for real-time customer support, order tracking and automation.

In this tutorial, you will learn how to build a complete package tracker using WhatsApp Cloud API and Stream Chat.

Prerequisite

To follow along, you need:

Setting up Your WhatsApp Platform Account

Follow the steps below to set up your WhatsApp Platform Account. This account will allow us to integrate with WhatsApp via the Cloud API.

  • Select an app type. In our case, let’s select “Business.” That gives us permission to use the WhatsApp Cloud API.
  • Add an app name.
  • Next, add the WhatsApp product to your app. It’s the only one you need for this tutorial.

  • Follow the next prompt to complete the setup.

  • Select “Start using the API” to get your API key.

    WhatsApp gives you a temporary access token that expires every 24 hours and a test phone number for development purposes. When you are ready to deploy to production, you can get a permanent access token and use your phone number.

Setting Up a Webhooks Endpoint

Next, let’s set up a webhooks endpoint in Node.js (Express).

routes/webhook.js


In the code above, check the incoming webhook message and extract the phone number (from) and message type (msg_type). The GET endpoint sets up the webhook using the value of verify_token. Add this value to the WhatsApp webhook configuration page to complete the webhook setup.

This is what the .env file looks like.

.env


Complete setup by adding the value of verify_token and the callback URL (your server’s URL) to the WhatsApp Cloud API webhook page in the Meta Developer Portal.

WhatsApp will send webhook events to the server as long as it is HTTPS and has a valid SSL certificate. Subscribe to the messages webhook field. We need only this field.

Showcasing Products on WhatsApp Business

When a customer chats with our WhatsApp Business number, we want to send them the list of products for sale.

Customers get a list of available products when they send “#product” in the chat.

routes/webhook.js


If the chat value is #product, we automatically send the customer an interactive message with a list of our products through the sendInteractiveProductMessage function. Let’s create the sendInteractiveProductMessage and sendUserAMessage functions inside another file.

utils.js


SendInteractiveProductMessage sends an interactive list of products to the user. Catalog templates are a far more effective way to share your products directly with customers within WhatsApp. However, we’ll use interactive list instead since we want to keep this tutorial focused on core integration.

SendUserAMessage allows us to send plain text chats.

Next, we will prompt the customer to make a payment after choosing the product(s) they want to buy.

routes/webhook.js


Here, we verified the message type sent from the WhatsApp Cloud API webhooks to determine our next action: sending a payment request to the customer for the purchased products.

Tracking Ordered Items on Stream Chat

It’s important to track ordered items and communicate with customers from a central hub outside WhatsApp. Stream Chat enables you to consolidate all your customer conversations from WhatsApp into Stream Chat, allowing you and your team to track purchases and engage with customers without needing to use the WhatsApp app.

Create a Channel

Create a Stream channel right inside the webhook.js file.

routes/webhook.js


When a customer sends a message to our WhatsApp business line, we immediately add them as a Stream user, create an order_tracking channel, and add both the customer and business to the channel.

Send Message as Customer

In addition to creating a user in Stream and adding that user to a channel, we also want to send every chat the customer sends to our WhatsApp Business number to Stream Chat.

routes/webhook.js


Chats (msg_body) from customers received through the WhatsApp message hook are sent to Stream Chat. Each message includes a custom reply_number value, which identifies the customer’s phone number so the business can reply directly from Stream Chat.

Before building the UI of our package tracker, set up the authorization route.

routes/auth.js


Build the Chat UI to see and respond to customers’ messages and orders.

Create a Chat.jsx in your React application.

Chat.jsx


The CustomMessageInput component has a submitHandler function that sends chats from the business to the customer’s WhatsApp. We’ll create a response.js route in our backend shortly to handle communication from the company (package tracker UI) to the customer’s WhatsApp.

The business is authenticated to join the order_tracking channel when the component mounts. We are also listening for new messages from customers. When a new message from a customer comes in, extract the WhatsApp phone number (reply_number) and store it in localStorage. (For production apps, you should store this in your database.) The business uses this phone number inside the submitHandler function to send back messages to the customer’s WhatsApp.

Create the response route in the backend:

routes/response.js


Remember to add the ChatComponent to the main page:

App.jsx

Chat Between Customers and Business

Our package tracker application is ready. Let’s test it out:

  • Text #product to the test phone number provided by WhatsApp.

  • The customer will immediately get a list of available products to shop.

 

  • Once they choose, they receive a payment link to complete the purchase.

  • They can chat with the business at any time.

    • The business receives WhatsApp conversations in the package tracker UI.

  • You can send the customer a response from the business’s package tracker UI, and they’ll receive it in their WhatsApp.

    Chat

Conclusion

With Stream Chat and WhatsApp Business Cloud API, you can build a package tracker that showcases products, collects payments, resolves issues, sends delivery updates and keeps customers informed — all in one place.

Stream empowers you to build communication apps and is flexible enough to integrate with your existing business tools to better serve your customers.

 

Group Created with Sketch.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.