Sendzen API Documentation
HomeGetting Started
HomeGetting Started
Visit Website
Sign In
Create an account
  1. Programming Languages
  • Start Guide
    • Getting Started
    • API Reference
  • Messages
    • Template Messages
      • Send Text Message
      • Send Interactive Message
      • Send Media Message
    • Session Messages
      • Send Text Message
      • Send Image Message
      • Send Video Message
      • Send Audio Message
      • Send Document Message
      • Send Interactive Reply Message
    • Incoming Messages
      • Received Text Message
      • Received Message with Reaction
      • Received Media Message with Image
      • Received Callback from a Quick Reply Button Click
  • Template
    • List Templates
      GET
    • Create Template
      POST
    • Delete Template
      DELETE
  • Project
    • Create Project
      POST
    • List Projects
      GET
    • Update Project
      PUT
    • Retrieve Project
      GET
  • WABA
    • List WABA
      GET
    • Retrieve WABA Details from Meta
      GET
    • Retrieve WhatsApp Business Profile Detail
      GET
    • Update WhatsApp Business Profile
      POST
  • Knowledge Base
    • Programming Languages
      • Python
      • Node.js
      • PHP
      • Laravel
      • Java
      • C# .NET
    • Onboarding
      • WhatsApp Setup
  • Logs
    • Retrieve All Event Logs
    • Incoming Message Logs
    • Message Status Logs
    • Other Event Logs
    • Multiple Event Types
  • Schemas
    • Schemas
      • Template Message
      • Url
      • 401/403 Message Response
      • AccountLoginRequest
      • APIKeyDto
      • Address
      • Account
      • AccountRegisterRequest
      • CommonResponse
      • AccountDetailDto
      • CreateOrUpdateProjectRequest
      • Contact
      • Error
      • PartnerConfigDto
      • ContactName
      • Button
      • ErrorResponse
      • CarouselCard
      • LoginResponse
      • Email
      • PartnerInfoDto
      • Component
      • ProjectDetailDto
      • ProjectWABADetail
      • Interactive
      • WABADetail
      • WABASignUp
      • InteractiveAction
      • WABADto
      • InteractiveBody
      • CreateTemplateRequest
      • InteractiveButton
      • InteractiveFooter
      • InteractiveHeader
      • InteractiveMedia
      • Example
      • InteractiveProductItem
      • InteractiveProductSection
      • InteractiveReply
      • InteractiveRow
      • InteractiveSection
      • Location
      • Media
      • MessageRequest
      • MessageResponse
      • MessageTemplate
      • Organization
      • LimitedTimeOffer
      • Phone
      • Reaction
      • Response
      • TemplateAction
      • NamedParameter
      • TemplateButtons
      • OrderCheckoutDto
      • TemplateCarousel
      • OrderDto
      • TemplateComponent
      • OrderStatusEnum
      • TemplateCurrency
      • TemplateDateTime
      • PaymentGatewayDto
      • TemplateLimitedTimeOffer
      • TemplateMedia
      • TemplateParameter
      • TemplateProductItem
      • TemplateSection
      • TemplateTapTargetConfiguration
      • SupportedApp
      • Text
      • WhatsAppBusinessProfile
      • UploadMedia
    • Knowledge Base
  1. Programming Languages

WhatsApp API with Node.js

This guide provides everything you need to send messages, build bots, and automate communication using the WhatsApp API with Node.js (also known as WhatsApp Business API NodeJS). We'll provide production-ready code examples and best practices using SendZen.io to ensure a world-class developer experience.
Whether you want to write a simple Node.js script to send WhatsApp message from Node.js or build a sophisticated AI chatbot using the WhatsApp bot API Node.js, you're in the right place. Unofficial libraries that rely on web scraping are unreliable and will get your number banned. Using the official WhatsApp Cloud API NodeJS (WhatsApp Business API) is the only stable and scalable method for professional applications.
SendZen makes the WhatsApp API integration Node.js incredibly simple. This guide covers everything from basic messaging to building complete WhatsApp bots using Node.js. Let's dive in.
This guide covers:
Send WhatsApp message using Node.js - Complete API integration examples.
Receiving messages using an Express webhook.
Create WhatsApp bot NodeJS - Build interactive bots from scratch.
WhatsApp API Node.js GitHub - Production-ready code examples.
Best practices for production, including WhatsApp gateway NodeJS integration.

Prerequisites#

Before you start, you'll need:
1.
Node.js 14+ installed.
2.
A free SendZen.io Account to get your API Key.
3.
The axios and express npm packages. Install them with npm:

Part 1: How to Send a WhatsApp Message with Node.js#

Sending a transactional message programmatically, like an order confirmation or a 2FA code, is a core use case. This guide shows you how to send WhatsApp message programmatically Node.js using the official WhatsApp API NodeJS. This Node.js code uses the axios library to make a simple API call to the WhatsApp Web API NodeJS.
Create a file named sendMessage.js and add the following code.
To run this script:
1.
Replace YOUR_API_TOKEN and RECIPIENT_NUMBER with your details.
2.
Run the file from your terminal: node sendMessage.js.
You've just successfully sent an automated WhatsApp message using Node.js! This simple function demonstrates how to send WhatsApp message from Node.js free and is the foundation for all outbound messaging using the WhatsApp API Node.js.

Part 2: Receiving Messages with a Node.js Webhook#

To build a WhatsApp bot using Node.js or create a Node.js bot WhatsApp, your application needs to listen for incoming messages. The WhatsApp API NodeJS does this using webhooks. When a user messages your number, WhatsApp sends the message data as a JSON POST request to a URL you specify.
We'll use Express, a lightweight web framework, to create a simple webhook server for WhatsApp API integration Node.js.
Create a file named app.js:
To make this work:
1.
Run the Express App: node app.js. Your server is now running on localhost:5000.
2.
Expose to the Web: WhatsApp can't reach localhost. Use a tool like ngrok to create a public URL for your local server:
3.
Configure the Webhook: Copy the https://....ngrok.io URL provided by ngrok, append your route (/webhooks/whatsapp), and paste it into the Webhook URL field in your SendZen dashboard.
Now, when you send a message to your WhatsApp number, you'll see the message data printed in your terminal.

Part 3: Building a Complete WhatsApp Bot in Node.js#

Let's combine what we've learned to create WhatsApp bot NodeJS - a simple but complete WhatsApp bot using Node.js. This Node.js bot WhatsApp will reply to specific keywords, demonstrating a full WhatsApp bot API Node.js implementation.
We'll modify our app.js to import and use the sendWhatsAppMessage function we wrote earlier. This example shows how to build a WhatsApp bot using Node.js from scratch.
Run this updated app.js with ngrok again. Now, when you send "hello" or "status" to your WhatsApp number, the bot will reply automatically! This is the foundation for all WhatsApp automation with Node.js and demonstrates how to send WhatsApp message using Node.js programmatically.
You can find more examples and contribute to this codebase on WhatsApp API GitHub NodeJS repositories. This implementation uses the WhatsApp Cloud API Node.js for reliable messaging.

Advanced Topics & Best Practices#

Scaling Up: Node.js WhatsApp Bulk Sender#

To send bulk messages programmatically, such as alerts to all your users, simply loop through an array of recipient numbers and call the sendWhatsAppMessage function for each. Use Promise.all() or a queue system for better performance with large volumes. This demonstrates how to send WhatsApp message programmatically Node.js at scale.
Important: To initiate conversations with users, WhatsApp requires you to use pre-approved Message Templates. This is a crucial policy to prevent spam. You can easily manage and send templates via the SendZen API. For bulk campaigns, use templates.

Express WhatsApp API Integration#

WhatsApp API integration Node.js with Express follows the same principles we've demonstrated. You can extend the webhook route with middleware for authentication, logging, and error handling. This creates a robust WhatsApp gateway NodeJS solution.

Using ES6 Modules (Optional)#

If you prefer ES6 modules for your WhatsApp API Node.js project, update your package.json to include "type": "module", then use import statements. This modern approach works great with the WhatsApp Web API NodeJS:

Additional Resources#

WhatsApp API Node.js GitHub Examples#

Looking for more examples? Check out WhatsApp API GitHub NodeJS repositories for additional code samples, integrations, and community contributions. Our implementation demonstrates how to use the WhatsApp Cloud API Node.js and WhatsApp Web API NodeJS effectively.

Key Features Covered#

✅ Send WhatsApp message Node.js - Complete API integration
✅ WhatsApp API send message Node.js - Production-ready code
✅ Node.js send WhatsApp message - Simple and reliable
✅ WhatsApp bot using Node.js - Full bot implementation
✅ WhatsApp gateway NodeJS - Enterprise-ready solution
✅ WhatsApp API integration Node.js - Best practices included

Free vs Paid Options#

While this guide shows you how to send WhatsApp message from Node.js free for development, production applications should use the official WhatsApp Business API NodeJS for reliability and compliance. The WhatsApp Cloud API NodeJS ensures your messages are delivered securely and won't get your account banned.

Common Questions#

Q: How do I send WhatsApp message from Node.js?
A: Use the sendWhatsAppMessage function provided in Part 1. It uses the official WhatsApp API NodeJS to send messages programmatically.
Q: Can I send WhatsApp message Node.js API for free?
A: Yes, you can send WhatsApp message from Node.js free during development. For production, use the official WhatsApp Business API NodeJS.
Q: How to create WhatsApp bot NodeJS?
A: Follow Part 3 of this guide to create WhatsApp bot NodeJS. It shows you how to build a complete WhatsApp bot using Node.js.
Q: Is there a WhatsApp API GitHub NodeJS example?
A: Yes, check out WhatsApp API GitHub NodeJS repositories for community examples and contributions.
Q: What's the difference between WhatsApp Cloud API Node.js and WhatsApp Web API NodeJS?
A: Both refer to the official WhatsApp Business API NodeJS. The WhatsApp Cloud API Node.js is the cloud-hosted version, while WhatsApp Web API NodeJS refers to the web-based API interface.
Q: How do I send WhatsApp message programmatically Node.js?
A: Use the code examples in Part 1 to send WhatsApp message programmatically Node.js. The function uses axios to make HTTP requests to the API.

Start Building Now#

You now have a complete toolkit for WhatsApp API programming in Node.js. By combining a simple function to send WhatsApp message using Node.js and an Express webhook to receive them, you can build powerful, automated communication workflows.
Whether you're building a WhatsApp bot using Node.js, integrating the WhatsApp API NodeJS into your application, or setting up a WhatsApp gateway NodeJS, SendZen makes it simple.
With SendZen's developer-first WhatsApp API Node.js solution, you can stop wrestling with complex setups and focus on creating amazing applications.
Sign Up for Free & Get Your API Key →
Modified at 2025-11-04 09:10:54
Previous
Python
Next
PHP
Built with