Settings

Webhook URLs, env vars, and integration guide.

Webhook endpoints

Required environment variables

Add these in your backend project secrets so edge functions can authenticate.

  • OPENAI_API_KEYUsed for GPT-4o (agent) and GPT-4o-mini (stage detection).
  • GHL_WEBHOOK_SECRETShared secret. Send as x-webhook-secret header from GHL.
  • HANDOFF_WEBHOOK_URLSlack-style incoming webhook for human-handoff alerts (optional).
  • SUPABASE_SERVICE_ROLE_KEYAuto-provisioned. Used internally.

GHL setup checklist

  1. In GHL, create a sub-account and grab its Location ID and an API key. Paste into the Clients page.
  2. Inbound trigger — workflow on Customer Replied (or Inbound Message). Action: Webhook, URL above, method POST.
  3. Outbound trigger — second workflow on Outbound Message (when you/staff send from GHL or IG). Same webhook URL. This is what makes your manual replies show up in the chat thread here.
  4. Send these fields in the body: contactId, message, locationId, contactName, phone, email, type, direction. For the outbound workflow set direction: "outbound".
  5. Add a custom header: x-webhook-secret: <your secret>.
  6. Optional: add a Contact Created trigger pointing at the contact-created URL to fire opening DMs automatically.
  7. Schedule the follow-up endpoint to be hit every 5 min via cron (cron-job.org, Railway, or pg_cron).

Security note

Auth is currently disabled on the dashboard — anyone with this URL can read and write data. Add login + RLS before going to production.