96 lines
1.7 KiB
Markdown
96 lines
1.7 KiB
Markdown
# wa-test-nextjs
|
|
|
|
Mini app Next.js untuk test koneksi WhatsApp webhook ke nomor testing.
|
|
|
|
## Halaman
|
|
- /login
|
|
- /settings
|
|
- /test
|
|
- /webhook-logs
|
|
|
|
## API
|
|
- GET /api/webhooks/whatsapp
|
|
- POST /api/webhooks/whatsapp
|
|
- POST /api/test/send
|
|
|
|
## Flow test
|
|
- kirim `daftar`
|
|
- app balas minta nama
|
|
- kirim nama
|
|
- app balas konfirmasi
|
|
|
|
## Jalankan
|
|
```bash
|
|
cp .env.example .env
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
## Deploy test server
|
|
Target deploy:
|
|
- domain `wa.iptek.co`
|
|
- app port `127.0.0.1:3007`
|
|
- reverse proxy `nginx`
|
|
|
|
Contoh langkah di server:
|
|
|
|
1. Buat user deploy khusus:
|
|
```bash
|
|
sudo adduser deploywa
|
|
sudo usermod -aG sudo deploywa
|
|
sudo mkdir -p /var/www
|
|
sudo chown -R deploywa:deploywa /var/www
|
|
su - deploywa
|
|
```
|
|
|
|
2. Clone project:
|
|
```bash
|
|
cd /var/www
|
|
git clone https://git.iptek.co/wirabasalamah/webhook-test.git wa-test-nextjs
|
|
cd wa-test-nextjs
|
|
```
|
|
|
|
3. Siapkan environment:
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
4. Install dependency dan build:
|
|
```bash
|
|
npm ci
|
|
npm run build
|
|
```
|
|
|
|
5. Jalankan dengan PM2:
|
|
```bash
|
|
npx pm2 start ecosystem.config.cjs
|
|
npx pm2 save
|
|
```
|
|
|
|
6. Pasang config nginx:
|
|
```bash
|
|
sudo cp deploy/nginx/wa.iptek.co.conf /etc/nginx/sites-available/wa.iptek.co.conf
|
|
sudo ln -s /etc/nginx/sites-available/wa.iptek.co.conf /etc/nginx/sites-enabled/wa.iptek.co.conf
|
|
sudo nginx -t
|
|
sudo systemctl reload nginx
|
|
```
|
|
|
|
7. Jika pakai HTTPS:
|
|
```bash
|
|
sudo certbot --nginx -d wa.iptek.co
|
|
```
|
|
|
|
Set `.env` minimal:
|
|
```bash
|
|
NEXT_PUBLIC_APP_URL=https://wa.iptek.co
|
|
WHATSAPP_VERIFY_TOKEN=...
|
|
WHATSAPP_ACCESS_TOKEN=...
|
|
WHATSAPP_PHONE_NUMBER_ID=...
|
|
WA_TEST_NUMBER=...
|
|
WA_TEST_LOGIN_USERNAME=...
|
|
WA_TEST_LOGIN_PASSWORD=...
|
|
SESSION_SECRET=...
|
|
```
|
|
|
|
Contoh config nginx ada di `deploy/nginx/wa.iptek.co.conf`.
|