Webhook events
When you turn on the Send webhook on event skill, Lexey sends an HTTP POST to your URL each time a subscribed event happens. Requests follow the Standard Webhooks specification, so you can verify them with an existing library in most languages.
Event types
conversation.escalated— The support agent passed a conversation to your team (the customer was frustrated, the question was outside its knowledge, or a configured escalation rule matched).
Payload
Every payload is JSON with the same envelope:
| 1 | { |
| 2 | "id": "msg_2f1c0a9d1b7e4c55a3d0f1e2b3c4d5e6", |
| 3 | "type": "conversation.escalated", |
| 4 | "timestamp": "2026-10-03T04:30:00.000Z", |
| 5 | "test": false, |
| 6 | "data": { |
| 7 | "conversation": { |
| 8 | "id": "550e8400-e29b-41d4-a716-446655440000", |
| 9 | "status": "escalated", |
| 10 | "customerIdentifier": "user@example.com", |
| 11 | "createdAt": "2026-10-03T04:00:00.000Z", |
| 12 | "channel": "api", |
| 13 | "source": { "channel": "api", "label": "API · Mobile app", "apiKeyLabel": "Mobile app" } |
| 14 | }, |
| 15 | "reason": "Customer requested a manager for a refund dispute", |
| 16 | "messages": [ |
| 17 | { "role": "user", "content": "I need to speak to a manager about my refund.", "createdAt": "2026-10-03T04:00:10.000Z" }, |
| 18 | { "role": "assistant", "content": "I've passed this to the team.", "createdAt": "2026-10-03T04:00:12.000Z" } |
| 19 | ], |
| 20 | "messagesTruncated": false |
| 21 | } |
| 22 | } |
id— The delivery's id. It is the same on every retry and replay, so use it to ignore duplicates.type— The event type.timestamp— When the event happened (UTC, ISO 8601), not when this request was sent.test—truefor test events sent from the Skills page.data.conversation.channel— Where the customer chatted:hosted(hosted page or widget),portal(Preview) orapi(Customer Chat API).data.conversation.source— The same, as a label:Widget,Portal, or for the Customer Chat APIAPI ·and the label of the API key that started the conversation.apiKeyLabelis that label on its own, ornull. No part of the key itself is ever sent.data.messages— The conversation's latest 100 messages, oldest first.messagesTruncatedistruewhen there were more.
Headers
| Header | Value |
|---|---|
webhook-id | The delivery's id, the same as id in the body |
webhook-timestamp | When this attempt was sent, in Unix seconds |
webhook-signature | v1, followed by the signature; several space-separated signatures during a secret rotation |
content-type | application/json |
user-agent | Lexey-Webhooks/2.0 (+https://lexey.ai/docs/webhook-events) |
Verifying signatures
Lexey creates a signing secret beginning whsec_ when you add your URL. An admin can copy it from Agent › Skills. The signature is a base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<raw body>, keyed with the secret after whsec_ (base64-decoded).
Check that the timestamp is within five minutes of your clock, so a captured request can't be replayed later, and compare the signature in constant time. The standardwebhooks library does both:
| 1 | import { Webhook } from "standardwebhooks"; |
| 2 | |
| 3 | const wh = new Webhook(process.env.LEXEY_WEBHOOK_SECRET); // "whsec_..." |
| 4 | |
| 5 | // Use the raw request body: re-serialised JSON won't match the signature. |
| 6 | const event = wh.verify(rawBody, { |
| 7 | "webhook-id": req.headers["webhook-id"], |
| 8 | "webhook-timestamp": req.headers["webhook-timestamp"], |
| 9 | "webhook-signature": req.headers["webhook-signature"], |
| 10 | }); // throws if the signature or timestamp is wrong |
Without the library:
| 1 | import { createHmac, timingSafeEqual } from "node:crypto"; |
| 2 | |
| 3 | function verify(rawBody: string, headers: Record<string, string>, secret: string): boolean { |
| 4 | const id = headers["webhook-id"]; |
| 5 | const timestamp = Number(headers["webhook-timestamp"]); |
| 6 | if (!id || Math.abs(Date.now() / 1000 - timestamp) > 300) return false; |
| 7 | const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64"); |
| 8 | const expected = Buffer.from( |
| 9 | "v1," + createHmac("sha256", key).update(id + "." + timestamp + "." + rawBody).digest("base64"), |
| 10 | ); |
| 11 | return headers["webhook-signature"].split(" ").some((candidate) => { |
| 12 | const actual = Buffer.from(candidate); |
| 13 | return actual.length === expected.length && timingSafeEqual(actual, expected); |
| 14 | }); |
| 15 | } |
When an admin rotates the secret, Lexey signs with both the new and the old secret for 24 hours, so update your server during that window.
Responses, retries and replays
Return a 2xx status within 10 seconds. Do slow work after responding. Any other status, a timeout or a redirect counts as a failed attempt; redirects are not followed.
A failed delivery is retried about 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, 14 hours, 24 hours and 24 hours later, ten attempts over about three and a half days. Admins can see every delivery and attempt on the Skills page, send a test event, and replay a delivery or everything that failed since a given time.
Webhooks are sent for real customer conversations and for Preview conversations with your live agent, so you can test your endpoint from the portal. They're never sent for shadow conversations, Preview against a draft or Test Lab runs. Webhooks aren't rate limited: every escalation is delivered or kept for replay.
Endpoints that keep failing
If every attempt has failed for five days, or your endpoint answers 410 Gone, Lexey turns the endpoint off and emails your admins. New events are kept while it is off. Once it's fixed, turn it back on from the Skills page and replay what it missed. Saving a new URL also turns it back on.
Requirements
- Your URL must use https and resolve to a public address. Private, loopback and link-local addresses are refused.
- Delivery history is kept for 30 days.