
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
whatsapp-business-serverless
Advanced tools
Connector for the WhatsApp Business APIs with TypeScript support. Serverless version.
This is a modified version of the WhatsApp Business SDK that has been optimized for Cloudflare Workers compatibility by removing Node.js-specific dependencies.
src/utils/restClient.ts
)fetch
APIsrc/WABA_client.ts
)File
or Blob
objects instead of file pathsArrayBuffer
instead of writing to file systemimport { WABAClient } from 'whatsapp-business';
export default {
async fetch(request: Request, env: any): Promise<Response> {
const client = new WABAClient({
apiToken: env.WHATSAPP_API_TOKEN,
phoneId: env.WHATSAPP_PHONE_ID,
accountId: env.WHATSAPP_ACCOUNT_ID,
});
// Your logic here
}
};
// Send text message
const response = await client.sendMessage({
to: "1234567890",
type: "text",
text: {
body: "Hello from Cloudflare Workers!"
}
});
Before (Node.js):
// ❌ This won't work in Workers
await client.uploadMedia({
file: "/path/to/file.jpg",
type: "image"
});
After (Workers Compatible):
// ✅ Use File or Blob objects
const formData = await request.formData();
const file = formData.get('file') as File;
await client.uploadMedia({
file: file, // File object from FormData
type: "image"
});
Before (Node.js):
// ❌ This won't work in Workers
await client.downloadMedia(mediaUrl, "/path/to/save/file.jpg");
After (Workers Compatible):
// ✅ Returns ArrayBuffer
const mediaBuffer = await client.downloadMedia(mediaUrl);
// Return as response or process as needed
return new Response(mediaBuffer, {
headers: {
'Content-Type': 'application/octet-stream'
}
});
Set these in your wrangler.toml
:
[vars]
WHATSAPP_API_TOKEN = "your_api_token"
WHATSAPP_PHONE_ID = "your_phone_id"
WHATSAPP_ACCOUNT_ID = "your_account_id"
All WhatsApp Business API methods are available:
getBusinessProfile()
updateBusinessProfile()
sendMessage()
- Send any type of messagemarkMessageAsRead()
uploadMedia()
- Upload media (File/Blob)getMedia()
- Get media URLdeleteMedia()
- Delete mediadownloadMedia()
- Download as ArrayBuffergetBusinessPhoneNumbers()
getSingleBusinessPhoneNumber()
updateIdentityCheckState()
requestPhoneNumberVerificationCode()
verifyPhoneNumberCode()
registerPhone()
deregisterPhone()
setupTwoStepAuth()
getHealthStatus()
If you're migrating from the original SDK:
See examples/cloudflare-worker-example.ts
for a complete working example.
FAQs
Connector for the WhatsApp Business APIs with TypeScript support. Serverless version.
The npm package whatsapp-business-serverless receives a total of 3 weekly downloads. As such, whatsapp-business-serverless popularity was classified as not popular.
We found that whatsapp-business-serverless demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.