Skip to main content
Sdks
JavaScript SDK
The JavaScript SDK offers a simple and flexible way to integrate WhatsApp messaging into Node.js applications. It requires minimal configuration and works well with existing JavaScript projects.
Both SDKs support the same features and endpoints, so functionality is identical across them.
Advantages of JavaScript SDK
- Fast setup
- No type configuration required
- Works with most Node.js versions
- Ideal for rapid development
Best Fit For
- MVP development
- Small to mid-size projects
- Automation scripts
- Legacy Node.js systems
Installation
Node.js
npm install @duochatduochat-sdk
Node.js Usage
import { SdkSendMessageDto, duochatSdk } from "@duochatduochat-sdk";
(async () => {
const duochatSdk = new duochatSdk({
token: "YOUR_TOKEN_HERE", // 👈 Get this from https:/duochat/
});
const sdkSendMessageDto: SdkSendMessageDto = {
countryCode: "91",
phoneNumber: "9876543210",
messageType: "text",
templateName: "welcome_template",
messageText: "Hello from duochat!",
components: ["button1", "button2"],
context: {},
mediaMessage: {},
media: {},
};
const { data } = await duochatSdk.sdk.sdkControllerSendMessage(
sdkSendMessageDto
);
console.log("Message sent successfully:", data);
})();
Browser vs Node.js
- Browser: Use publishable keys, limited to safe operations
- Node.js: Use secret keys, full API access
- CORS: Browser requests are subject to CORS policies
- Security: Never expose secret keys in browser code
Was this page helpful?