including:
- remove batch_size di config-gw-wa.json
- merge function, bedakan dengan message_type
62 lines
1.4 KiB
Markdown
62 lines
1.4 KiB
Markdown
# 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:
|
|
```json
|
|
{
|
|
"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
|
|
```bash
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Format code
|
|
npm run format
|
|
```
|
|
|
|
## Build & Run
|
|
```bash
|
|
# 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
|
|
```sh
|
|
# 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. |