A secure WhatsApp Cloud API SDK for NestJS and Express
npm install @rkitwork/whatsapp-ramukjar-cloud-sdkbash
npm install @rkitwork/whatsapp-ramukjar-cloud-sdk
`
---
Quick Start
$3
`ts
import { WhatsAppClient } from '@rkitwork/whatsapp-ramukjar-cloud-sdk';
const client = new WhatsAppClient({
token: process.env.WHATSAPP_TOKEN!,
phoneNumberId: process.env.PHONE_ID!,
apiVersion: 'v24.0',
});
`
---
$3
`ts
import { WhatsApp } from '@rkitwork/whatsapp-ramukjar-cloud-sdk';
await client.sendMessage(
'919XXXXXXXXX',
WhatsApp.text('Hello from WhatsApp Cloud SDK 🚀')
);
`
$3
`ts
import { Injectable } from '@nestjs/common';
import { WhatsAppClient, WhatsApp } from '@rkitwork/whatsapp-ramukjar-cloud-sdk';
@Injectable()
export class AppService {
private client = new WhatsAppClient({
token: process.env.WHATSAPP_TOKEN!,
phoneNumberId: process.env.PHONE_ID!,
apiVersion: 'v24.0',
});
async sendText() {
return this.client.sendMessage(
'919XXXXXXXXX',
WhatsApp.text('Hello from NestJS 🚀')
);
}
}
`
$3
`ts
import express from 'express';
import { WhatsAppClient, WhatsApp } from '@rkitwork/whatsapp-ramukjar-cloud-sdk';
const app = express();
const client = new WhatsAppClient({
token: process.env.WHATSAPP_TOKEN!,
phoneNumberId: process.env.PHONE_ID!,
});
app.get('/send', async (_, res) => {
const response = await client.sendMessage(
'919XXXXXXXXX',
WhatsApp.text('Hello from Express 🚀')
);
res.json(response);
});
app.listen(3000, () => console.log('Server running on port 3000'));
`
$3
| Method | Parameters | Description |
| ------------------- | --------------------------------------------- | --------------------------------------------------------- |
| WhatsApp.text | body: string | Sends a plain text message |
| WhatsApp.image | link: string, caption?: string | Sends an image with an optional caption |
| WhatsApp.video | link: string, caption?: string | Sends a video with an optional caption |
| WhatsApp.audio | link: string | Sends an audio message |
| WhatsApp.document | link: string, filename?: string | Sends a document with an optional filename |
| WhatsApp.location | lat: number, lng: number, name?: string | Sends a location with coordinates and optional place name |
---
> text` is a helper function that returns a proper WhatsApp Cloud API payload.