WhatsApp Gateway Service
A lightweight service for sending WhatsApp messages with PDF attachments through Qontak API. Supports multiple message types and provides automatic retries for failed messages.
Configuration
Create a config-gw-wa.json file in the root directory:
{
"base_url": "https://cpone.aplikasi.web.id/one-api/",
"schedule": [
"*/2 6-20 * * *" // Runs every 2 minutes from 6 AM to 8 PM
],
"startDate": "2023-08-01", // Filter T_OrderHeaderDate from this date (YYYY-MM-DD)
"endDate": "2025-12-30" // Filter T_OrderHeaderDate until this date (YYYY-MM-DD)
}
Supported Message Types
- MCU Result: Medical checkup results with PDF attachment
- Payment Receipt: Payment receipts with PDF attachment
Installation
# Install dependencies
npm install
# Format code
npm run format
Build & Run
# Build TypeScript source
npm run build
# Compile to executable
npm run compile
# Run the application
npm run start
# Or build, compile and start in one command
npm run bcs
Run Compiled File
# Dijalankan di lokasi yang sama dengan `config-gw-wa.json`
node ./dist/gw-wa.js
Development Notes
The gateway checks for outbox items with status:
- N: New messages
- E: Error messages (with retry logic, max 5 attempts)
- R: Rejected messages
Each message type uses its own API endpoints for:
- listing,
- uploading files,
- sending messages,
- then updating status.
Description
Languages
TypeScript
100%