Sviluppatori

Webhook

Avvisa i tuoi sistemi quando succede qualcosa in una conversazione.

I webhook sono un’azione dei workflow. Quando il workflow viene eseguito, Shopxare invia una richiesta POST con JSON al tuo indirizzo.

Contenuto

{
  "event": "conversation_closed",
  "workflow": { "id": "…", "name": "Tell the CRM" },
  "conversation": {
    "id": "…", "status": "closed", "channel": "widget", "priority": "normal",
    "assignee_id": 3, "team_id": null, "tags": ["vip"],
    "last_message": "Thanks!", "url": "https://app.shopxare.com/w/…/inbox/…"
  },
  "contact": { "id": "…", "name": "Ada", "email": "[email protected]", "type": "user", "attributes": {} },
  "sent_at": "2026-10-08T12:00:00+00:00"
}

event è l’attivatore del workflow: conversation_started, customer_replied, teammate_replied, conversation_closed, tag_added, unanswered_for o customer_idle_for. L’intestazione X-Shopxare-Event porta lo stesso valore.

Verificare la firma

Ogni richiesta ha un’intestazione come questa:

X-Shopxare-Signature: t=1760000000,v1=5f2b…

v1 è un HMAC-SHA256 su "<t>.<raw body>" con il segreto di firma del workflow (mostrato nell’editor del workflow). Calcolalo tu e confrontalo; rifiuta i timestamp vecchi.

[$t, $v1] = sscanf($header, 't=%d,v1=%s');
$ok = hash_equals(hash_hmac('sha256', $t.'.'.$rawBody, $secret), $v1) && abs(time() - $t) < 300;

Consegna

  • L’indirizzo deve essere pubblico; le reti private e locali vengono rifiutate.
  • Timeout di 5 secondi, nessun reindirizzamento.
  • Fino a 3 tentativi, attendendo 30 e poi 120 secondi.
  • Rispondi con qualsiasi stato 2xx.

Ancora dubbi? Contatti