---
title: "Discussion on \"🗨️ Build a WhatsApp API using Node & Express\" | Hashnode"
description: "Discussion on \"🗨️ Build a WhatsApp API using Node & Express\". 🤫 Using a library"
url: "https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [🗨️ Build a WhatsApp API using Node & Express](https://blog.usmans.me/whatsapp-api-node-express?utm_source=hashnode&utm_medium=feed)

🤫 Using a library

Jan 8, 2022 · 5 min read · blog.usmans.me  
Updated Mar 22, 2022  
Read the article

-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#express](https://hashnode.com/tag/express)
-   [#apis](https://hashnode.com/tag/apis)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)

## Written by

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

@usmanwrites · India

  
[View profile](https://hashnode.com/@usmanwrites)

Learning web development, running a YouTube channel

I am a full stack developer, YouTuber and blogger!

## Responses 5

Markdown supported · ⌘↵ to post

[Amit Kumar](https://hashnode.com/@phonekhata)

[Sep 24, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/632f0dd23a049a0d9db75a73)

Thank you for writing the post. I was trying to setup an auto responder for multiple numbers. One of the comment I read was const client = new Client({ puppeteer: { headless: false }, clientId : 'example'  
});

I believe, we can use clientId as mobile number. I was wondering if we need to fix session.json as well?

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

[Sep 24, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/632f0dd23a049a0d9db75a73#reply-632f14293ac18d0d78a0213d)

Due to the latest updates in the library, `settings.json` file isnt used.

If you use `clientId` as mobile number, that's fine. It's basically used for multiple sessions. It creates folders for each new session/client id you put in

[Amit Kumar](https://hashnode.com/@phonekhata)

[Sep 24, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/632f0dd23a049a0d9db75a73#reply-632f208a3a049a0d9db75d1c)

Thanks for prompt reply. Will try

[Budi Ramadhanus](https://hashnode.com/@Brama)

[Aug 27, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/6309bf5638843b7139784b75)

Im looking delivery message (pending, Delivered, read) can u explaint about that function ?

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

[Aug 27, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/6309bf5638843b7139784b75#reply-6309d84638843b713978501d)

Do you want to get the status of a message if that is pending, delivered or read??

If that's what you want, you can do something like this:

```
// Store the sent message in a variable
const sentMessage = await client.sendMessage(chatId, content);

console.log(sentMessage.ack)
```

`sentMessage.ack` will be either one of these:

-   `ACK_ERROR`
-   `ACK_PENDING`
-   `ACK_SERVER`
-   `ACK_DEVICE`
-   `ACK_READ`
-   `ACK_PLAYED`

For more information, you can refer the [docs](https://docs.wwebjs.dev/global.html#MessageAck)

[Joshua Omobola](https://hashnode.com/@koha)

[May 8, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/62784c53317fc95a74caaaa1)

Devastatingly fantastic! Thank you, @usmanwrites

[Eizil](https://hashnode.com/@Eizil)

[Mar 30, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/6244767f988211ec79b7cb8f)

Hi,

this is really interesting, i'm just learning node.js and stumble with your article using express.

Would you mind to shed some direction if I want to extend your API to use with multiple numbers?

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

[Mar 30, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/6244767f988211ec79b7cb8f#reply-62447d7863734fec55de5c82)

Hi Eizil! Thanks for commenting and asking 😃.

So if you want to use this API with multiple numbers, the `whatsapp-web.js` team actually worked on the multi-device feature [here](https://github.com/pedroslopez/whatsapp-web.js/pull/889) and they successfully published that to production.

With that, now you can set the `clientId` property in the `Client` constructor that will load the client of your choice once they are logged in. So you can make it dynamic in your case.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1648655721394/516lXrvT7.png)

[Eizil](https://hashnode.com/@Eizil)

[Mar 30, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/6244767f988211ec79b7cb8f#reply-62448195988211ec79b7cd81)

[Usman Sabuwala](https://hashnode.com/@usmanwrites) that was quick, thank you for your reply, will look into it and try it myself.

thanks again

[uik kos](https://hashnode.com/@kosuik)

[Mar 14, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/622ef0e1df08b9b82341a768)

Hi , i am new to nodesjs , i am trying to use your code but having some error

c:\\nodejs\\whatsapp\\app.js:54 app.listen(PORT, () => console.log(`🚀 @ http://localhost:${PORT}`)); ^

ReferenceError: app is not defined at Object.<anonymous> (c:\\nodejs\\whatsapp\\app.js:54:1) at Module.\_compile (node:internal/modules/cjs/loader:1103:14) at Object.Module.\_extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module.\_load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint \[as runMain\] (node:internal/modules/run\_main:77:12) at node:internal/main/run\_main\_module:17:47

can you share your code to download? Thanks a lot

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

[Mar 14, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/622ef0e1df08b9b82341a768#reply-622ef5ca38e0a0d99d32e8ba)

Hi. Sorry there was a mistake in the post that I updated now. When requiring all the packages, in order to make express work, you will have to initialise the `app` variable which I forgot. Thank you for pointing out the mistake.

Add this line with other variables

```
const app = express();
```

[uik kos](https://hashnode.com/@kosuik)

[Mar 16, 2022](https://hashnode.com/posts/whatsapp-api-node-express/61d9864acda0d0294b695f9d/comment/622ef0e1df08b9b82341a768#reply-62318ea8febabbf75388e9bc)

Hi [Usman Sabuwala](https://hashnode.com/@usmanwrites) ~ Thanks so much for your reply , that is working for me now ~ Thanks so much for your help ~^\_^
