conversation.analysis

The conversation analysis webhook is triggered when conversation analysis completes.

Webhook payload

Here is an example of the POST request JSON payload:

1{
2 "event_type": "conversation.analysis",
3 "data": {
4 "conversation": {
5 "id": "conv_550e8400-e29b-41d4-a716-446655440000",
6 "latencies_ms": [3179, 935, 595],
7 "interruptions_count": 1
8 },
9 "call_info": {
10 "from_phone_number": "+17124583766",
11 "to_phone_number": "+19189397081"
12 }
13 },
14 "created_at": "2025-07-14T11:36:33.767Z"
15}

Payload fields

event_type
stringRequired

Always "conversation.analysis"

created_at
stringRequired

ISO 8601 timestamp of when the event was created

data.conversation.id
stringRequired

The ID of the conversation analysis

data.conversation.latencies_ms
integer[]Required

Array of response latencies in milliseconds for each assistant turn

data.conversation.interruptions_count
integerRequired

Number of times the user interrupted the assistant

data.call_info
CallInfo | null

Phone call metadata (present for telephony conversations, null for web). Contains from_phone_number, to_phone_number, and optionally twilio_call_sid.

Example usage

Here’s an example of how to handle the webhook:

1import { Hono } from "hono";
2import { Webhook } from "svix";
3
4const app = new Hono();
5
6app.post("/webhooks/phonic", async (c) => {
7 if (!process.env.PHONIC_WEBHOOK_SECRET) {
8 return c.text("Bad Request", 400);
9 }
10
11 const wh = new Webhook(process.env.PHONIC_WEBHOOK_SECRET);
12 const rawBody = await c.req.text();
13
14 try {
15 const payload = wh.verify(rawBody, {
16 "svix-id": c.req.header("svix-id") ?? "",
17 "svix-timestamp": c.req.header("svix-timestamp") ?? "",
18 "svix-signature": c.req.header("svix-signature") ?? "",
19 }) as ConversationAnalysisWebhookPayload;
20
21 const { latencies_ms, interruptions_count } = payload.data.conversation;
22 console.log(`Latencies: ${latencies_ms}, Interruptions: ${interruptions_count}`);
23
24 return c.text("OK", 200);
25 } catch (error) {
26 console.error("Failed to verify webhook:", error);
27
28 return c.text("Bad Request", 400);
29 }
30});
31
32export default app;