Skip to content

Webhook signing

The assistant calls your systems for three things, all signed with the signing secret from Settings → Escalation webhook:

Call Event Set in
Your own tools tool.invoke Settings → Remote tools
Order look-ups account.orders.list, account.orders.get Settings → Signed-in visitors
Hand-over conversation.escalated Settings → Escalation webhook
POST <your url>
Content-Type: application/json
x-helpvane-timestamp: 1791500000
x-helpvane-signature: sha256=<hex HMAC-SHA256(secret, "<timestamp>.<raw body>")>
  1. Read the raw body; do not re-serialise parsed JSON.
  2. Reject timestamps more than 5 minutes away from now.
  3. Compute the HMAC and compare in constant time.
// Node.js / Express
import crypto from 'node:crypto';
import express from 'express';
app.post('/chat/webhook', express.text({ type: 'application/json' }), (req, res) => {
const timestamp = req.header('x-helpvane-timestamp') ?? '';
const signature = req.header('x-helpvane-signature') ?? '';
const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) <= 300;
const expected = 'sha256=' + crypto.createHmac('sha256', process.env.CHAT_WEBHOOK_SECRET!)
.update(`${timestamp}.${req.body}`).digest('hex');
const valid = fresh && expected.length === signature.length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
if (!valid) return res.status(401).end();
const payload = JSON.parse(req.body);
// …
});
// PHP
$raw = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_HELPVANE_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_HELPVANE_SIGNATURE'] ?? '';
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $raw, getenv('CHAT_WEBHOOK_SECRET'));
if (abs(time() - (int) $ts) > 300 || !hash_equals($expected, $sig)) { http_response_code(401); exit; }
$payload = json_decode($raw, true);
Call Timeout When it fails
Your tools per tool, 0.5–10 s (default 5 s) The assistant is told the tool is unavailable
Order look-ups 0.5–10 s (default 5 s) It apologises and offers your team
Hand-over 10 s The conversation is still marked as handed over, without a ticket

Calls are not retried. Respond quickly; do slow work in the background.