TEMBAKAN Webhook Setup

Dokumentasi setting online webhook untuk app, NodeMCU, dan endpoint server.

Konsep Alur

Server webhook online menyimpan trigger ke queue. Trigger bisa diambil oleh app lokal atau langsung oleh NodeMCU WiFi version.

Browser / sistem online -> /fire -> queue server -> /poll -> relay ON

Jika app lokal dan NodeMCU sama-sama polling machine ID yang sama, queue akan diambil oleh yang polling duluan. Pilih salah satu mode polling.

Environment Server

VariableContohKeterangan
WEBHOOK_KEYsecret123Key untuk authorize endpoint /fire, /webhook, /poll, /status. Set di environment hosting/server.
DEFAULT_MACHINEdefaultMachine ID default kalau request tidak mengirim machineId.
PORT3000Port server, biasanya otomatis dari hosting.

Cara Kirim Key

Query      : ?key=secret123
JSON body  : {"key":"secret123"}
Form body  : key=secret123
Header     : x-webhook-key: secret123
Bearer     : Authorization: Bearer secret123

Setting di App TEMBAKAN

  1. Buka app TEMBAKAN.
  2. Pilih WiFi Mode.
  3. Isi WiFi NodeMCU pada bagian WiFi Configuration, lalu klik Save & Connect.
  4. Isi bagian Online Webhook:
FieldIsi
Server URLhttps://domain-kamu tanpa slash akhir juga boleh.
Webhook KeySama dengan WEBHOOK_KEY server.
Machine IDContoh default, harus sama dengan URL trigger.
Enable online pollingCentang jika app lokal yang akan polling server. Jangan centang jika NodeMCU yang polling langsung.

Klik Save Online Webhook. App akan mengirim config ke NodeMCU lewat USB serial.

Setting Manual NodeMCU via Serial

Jika tidak lewat app, kirim command ini dari Serial Monitor:

WIFI:nama_wifi,password
WEBHOOK:https://domain-kamu
KEY:secret123
MACHINE:default
W

Setelah sukses, Serial Monitor akan menampilkan:

WiFi Connected!
HTTP Server started!
Online Webhook: https://domain-kamu
Online Machine: default

Endpoint Trigger

GET

https://domain-kamu/fire?key=secret123&machineId=default&command=F

POST JSON ke /fire

POST https://domain-kamu/fire
Content-Type: application/json

{"key":"secret123","machineId":"default","command":"F"}

GET ke /webhook

GET https://domain-kamu/webhook?key=secret123&machineId=default&command=F

POST JSON ke /webhook

POST https://domain-kamu/webhook
Content-Type: application/json

{"key":"secret123","machineId":"default","command":"F"}

POST form-urlencoded

POST https://domain-kamu/webhook
Content-Type: application/x-www-form-urlencoded

key=secret123&machineId=default&command=F

Response sukses:

{"ok":true,"queued":true,"machineId":"default","job":{"id":"...","command":"F","createdAt":"..."}}

Endpoint Polling

Dipakai app lokal atau NodeMCU untuk mengambil queue.

https://domain-kamu/poll?key=secret123&machineId=default

Jika ada trigger:

{"ok":true,"machineId":"default","fire":true,"job":{"id":"...","command":"F","createdAt":"..."}}

Jika kosong:

{"ok":true,"machineId":"default","fire":false,"job":null}

Monitoring

Buka dashboard:

https://domain-kamu/

Isi field Key di dashboard agar bisa melihat event lengkap dan test Queue Fire.

Troubleshooting

GejalaCek
unauthorizedPastikan key di URL/app/NodeMCU sama dengan WEBHOOK_KEY.
Queue masuk tapi relay tidak hidupPastikan app lokal atau NodeMCU sedang polling machine ID yang sama.
NodeMCU print WEBHOOK_ERROR_...Cek URL server, koneksi internet WiFi, dan apakah server online aktif.
Dashboard pending terus bertambahTidak ada client yang polling, atau machineId tidak sama.