Upload files to "/"
This commit is contained in:
commit
81d2a16dcb
|
|
@ -0,0 +1,99 @@
|
|||
# Dokumentasi API & Webhook WhatsApp Gateway (Go)
|
||||
|
||||
Sistem WhatsApp Gateway ini dikembangkan menggunakan Golang dan terhubung dengan library `whatsmeow` untuk memberikan REST API yang responsif dan ringan, serta dilengkapi sistem Webhook modern untuk push notification secara realtime.
|
||||
|
||||
---
|
||||
|
||||
## 🔒 Autentikasi
|
||||
Gunakan header berikut untuk mengakses API (jika diaktifkan di konfigurasi gateway Anda):
|
||||
- **Header:** `x-api-key`
|
||||
- **Value:** `API_KEY` rahasia Anda
|
||||
|
||||
---
|
||||
|
||||
## 📩 1. Mengirim Pesan (API Endpoints)
|
||||
Base URI: `http://localhost:5555/api` (atau disesuaikan dengan URL gateway Anda)
|
||||
|
||||
### Mengirim Teks (Personal / Grup)
|
||||
**Endpoint:** `POST /api/send-message`
|
||||
**Format Body (JSON):**
|
||||
```json
|
||||
{
|
||||
"phone": "628123456789",
|
||||
"message": "Halo, ini pesan otomatis."
|
||||
}
|
||||
```
|
||||
*Catatan:* Sistem otomatis mengenali dan memformat nomor.
|
||||
|
||||
### Mengirim Media (Gambar, Video, Dokumen)
|
||||
**Endpoint:**
|
||||
- `POST /api/send-image`
|
||||
- `POST /api/send-video`
|
||||
- `POST /api/send-document`
|
||||
- `POST /api/send-audio`
|
||||
- `POST /api/send-sticker`
|
||||
|
||||
**Format Body (Multipart/form-data):**
|
||||
- `phone`: Nomor tujuan
|
||||
- `caption`: Teks/caption (Opsional)
|
||||
- `file`: File upload yang valid
|
||||
|
||||
### Fitur Teks Lanjutan
|
||||
- **Quote (Reply):** `POST /api/send-message-quote` (menyertakan `quotedMsgId`)
|
||||
- **Mention (Tag):** `POST /api/send-message-mention` (menyertakan list `mentionedJIDs`)
|
||||
|
||||
---
|
||||
|
||||
## 📡 2. Pengecekan Status & QR
|
||||
- **Cek Status Bot:** `GET /api/status`
|
||||
- **Generate / Ambil QR Code:** `GET /api/qr` (hanya jika WhatsApp berstatus belum terhubung)
|
||||
|
||||
---
|
||||
|
||||
## 🪝 3. Dokumentasi Webhook (Realtime Events)
|
||||
Webhook berfungsi untuk menerima notifikasi secara otomatis ke server Anda (seperti aplikasi MikroTik) ketika ada pesan masuk ke WhatsApp.
|
||||
|
||||
### Cara Mengaktifkan Webhook
|
||||
Edit file `.env` di direktori aplikasi WhatsApp Gateway Golang:
|
||||
```env
|
||||
WEBHOOK_ENABLED=true
|
||||
WEBHOOK_URL=http://url-aplikasi-anda.com/webhook/wa-receive
|
||||
WEBHOOK_SECRET=kode_rahasia_anda (opsional, untuk X-Webhook-Signature)
|
||||
```
|
||||
|
||||
### Struktur Payload yang Diterima (POST Request)
|
||||
Server aplikasi Anda akan menerima JSON dengan struktur berikut:
|
||||
```json
|
||||
{
|
||||
"event": "message",
|
||||
"timestamp": "2024-03-29T22:30:00Z",
|
||||
"data": {
|
||||
"messageId": "3E3A4B89...",
|
||||
"from": "628123456789@s.whatsapp.net",
|
||||
"phoneNumber": "628123456789",
|
||||
"chatType": "personal",
|
||||
"isGroup": false,
|
||||
"pushName": "Budi",
|
||||
"messageType": "message",
|
||||
"text": "Teks pesan dari pengirim"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Fitur Auto-Reply langsung dari Webhook
|
||||
Anda dapat memberikan balasan otomatis *tanpa* perlu melakukan API Call lagi. Cukup response endpoint webhook Anda dengan JSON `200 OK`:
|
||||
```json
|
||||
{
|
||||
"action": "reply",
|
||||
"messages": [
|
||||
{ "type": "text", "content": "Halo Budi, pesan Anda telah kami terima!" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗂 Fitur Lainnya (Kontak & Grup)
|
||||
- **Get Kontak:** `GET /api/contacts` (Lokal)
|
||||
- **Cek Info Nomor WA:** `GET /api/contact/info?phone=628xx`
|
||||
- **Manajemen Grup:** `GET /api/groups` (List grup) dan `GET /api/groups/:jid/info` (Detail grup)
|
||||
Loading…
Reference in New Issue