A powerful NodeJS SDK for interacting with the Mekari Qontak API. This library provides a streamlined and developer-friendly way to integrate messaging capabilities into your applications.
- Node.js version 14 or higher
- WhatsApp Business API account
- A Qontak account with WhatsApp Channel enabled
- API credentials (Client ID and Client Secret)
- Approved message templates
- 🔐 Secure authentication with HMAC
- 📱 WhatsApp messaging integration
- 📤 File upload capabilities
- 💬 Conversation management
- 🔄 TypeScript support
- 📦 Zero dependencies (except axios)
- Installation
- Quick Start
- Authentication
- API Reference
- Examples
- Error Handling
- Contributing
- Support
- Testing
- Releasing to NPM
npm install qontak-client
# or
yarn add qontak-clientimport { QontakClient } from "qontak-client";
const api = new QontakClient({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
});
// Example: Send WhatsApp OTP message
try {
const response = await api.broadcast.createBroadcastDirect({
to_name: "John Doe",
to_number: "6281234567890", // Example dummy number
message_template_id: "YOUR_TEMPLATE_ID",
channel_integration_id: "YOUR_CHANNEL_ID",
language: {
code: "id"
},
parameters: {
buttons: [
{
index: "0",
type: "url",
value: "123456"
}
],
body: [
{
key: "1",
value_text: "123456",
value: "otp"
}
]
}
});
console.log("Response:", response);
} catch (error) {
console.error("Error:", error.response.data);
}-
Access the Mekari Developer Center:
- Production: https://developers.mekari.com
- Staging: https://developers.mekari.io
-
Create an HMAC Auth Application using your Admin Account:
- Follow the guide at Managing Applications
- You'll receive a client ID and client secret
-
Required Scopes:
qontak-chat:all // Access to api.mekari.com/qontak/chat qontak-crm:all // Access to api.mekari.com/qontak/crm
-
WhatsApp Templates
getListWhatsappTemplate()sendWhatsAppMessage()uploadMedia()
-
CRM Operations
createContact()updateContact()getContact()
For detailed API documentation, visit docs.qontak.com
Check out our example applications:
The SDK includes comprehensive error handling:
try {
const response = await api.template.getListWhatsappTemplate();
} catch (error) {
if (error.response) {
// API error with response
console.error('API Error:', error.response.data);
} else if (error.request) {
// Network error
console.error('Network Error:', error.request);
} else {
// Other errors
console.error('Error:', error.message);
}
}The API may return the following HTTP status codes:
| Status Code | Name | Description | Common Causes | Solution |
|---|---|---|---|---|
| 401 | Unauthorized | Authentication failed | - Invalid credentials - Missing credentials - Expired token |
- Check client ID and secret - Ensure credentials are valid - Refresh authentication token |
| 403 | Forbidden | Access denied | - Insufficient permissions - Missing required scopes - Invalid scopes |
- Verify required scopes (qontak-chat:all, qontak-crm:all)- Check application permissions - Contact support if issue persists |
| 404 | Not Found | Resource unavailable | - Invalid endpoint URL - Resource doesn't exist - Deleted resource |
- Verify endpoint URL - Check resource ID - Ensure resource exists |
| 429 | Too Many Requests | Rate limit exceeded | - Too many requests - Rate limit reached - Burst of requests |
- Implement exponential backoff - Reduce request frequency - Wait before retrying |
| 500 | Internal Server Error | Server error | - Server processing error - Database error - System failure |
- Wait and retry - Contact support if persistent - Check API status |
| 502 | Bad Gateway | Gateway error | - Invalid response from upstream - Network issues - Service unavailable |
- Wait and retry - Check API status - Contact support |
| 503 | Service Unavailable | Service down | - Maintenance - Overload - System failure |
- Wait and retry - Check maintenance schedule - Contact support |
| 504 | Gateway Timeout | Request timeout | - Slow response - Network issues - Server overload |
- Implement timeout handling - Retry with backoff - Contact support |
try {
const response = await api.template.getListWhatsappTemplate();
} catch (error) {
if (error.response) {
switch (error.response.status) {
case 401:
console.error('Authentication failed. Please check your credentials.');
break;
case 403:
console.error('Access forbidden. Check your permissions and scopes.');
break;
case 404:
console.error('Resource not found. Verify the endpoint URL.');
break;
case 429:
console.error('Rate limit exceeded. Please wait before retrying.');
// Implement exponential backoff here
break;
case 500:
console.error('Internal server error. Please try again later.');
break;
default:
console.error('API Error:', error.response.data);
}
}
}- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Documentation: docs.qontak.com
- Product Website: qontak.com
- Support Center: help-center.mekari.com
For integration support, contact:
- Your company's Mekari representative (Presales/Aftersales team)
- Support Center (details available at help-center.mekari.com)
This project is licensed under the ISC License - see the LICENSE file for details.
The project uses Jest for testing. To run the tests:
# Run all tests
npm test
# Run tests in watch mode (good for development)
npm run test:watch
# Run tests with coverage report
npm run test:coverageTests are located in the src/__tests__ directory and follow these conventions:
- Test files are named
*.test.ts - Each test file corresponds to a specific module
- Tests are organized using
describeblocks for grouping - Each test case uses
itortestfor individual tests
The project maintains a minimum test coverage requirement. You can view the coverage report by running:
npm run test:coverageThis will generate a coverage report in the coverage directory.
- NPM account with access to the package
- NPM access token with publish permissions
- GitHub account with repository access
- GitHub personal access token with repo permissions
-
Add your NPM token to GitHub repository secrets:
- Go to your repository settings
- Navigate to Secrets and Variables > Actions
- Add a new secret named
NPM_TOKENwith your npm access token
-
Configure your NPM account:
# Login to NPM
npm login
# Set up your package scope (if using a scope)
npm config set scope @your-scopeThe project follows Semantic Versioning:
MAJORversion for incompatible API changesMINORversion for backwards-compatible functionality additionsPATCHversion for backwards-compatible bug fixes
- Update the version:
# For patch updates (bug fixes)
npm version patch
# For minor updates (new features)
npm version minor
# For major updates (breaking changes)
npm version major- Push changes and tags:
git push origin main --tagsThe GitHub Actions workflow will automatically:
- Build the project
- Run tests
- Create a GitHub release
- Publish to NPM
- Include all necessary files in the release
The following files are included in each release:
dist/**/*- Compiled JavaScript filespackage.json- Package configurationpackage-lock.json- Dependency lock fileREADME.md- DocumentationCHANGELOG.md- Version historyLICENSE- License file
If the release fails:
- Check the GitHub Actions logs for errors
- Verify your NPM token has publish permissions
- Ensure all tests pass locally
- Check if the version number is already taken on NPM
- Verify the package name is available
-
Before Release
- Update CHANGELOG.md
- Run tests locally
- Check for breaking changes
- Update documentation if needed
-
During Release
- Use semantic versioning
- Tag releases with git
- Include all necessary files
- Test the published package
-
After Release
- Verify the package on NPM
- Test installation in a new project
- Update documentation if needed
- Monitor for issues
To publish a beta version:
# Create a beta version
npm version prerelease --preid=beta
# Push changes and tags
git push origin main --tagsThe package will be published with the beta tag:
npm install qontak-client@betaIf you need to rollback a release:
- Unpublish the version:
npm unpublish qontak-client@<version>- Create a new patch version:
npm version patch- Push the changes:
git push origin main --tagsFor release-related issues:
- Check the GitHub Issues
- Review the NPM documentation
- Contact the maintainers