# Building post-call transcripts with ElevenLabs Agents and Hookdeck

When an ElevenLabs voice agent finishes a call, the outcome usually has to reach your own systems, such as a booking in a calendar or a lead in a CRM, along with the transcript and recording for later review. ElevenLabs sends that data in webhooks after the call, so a lost webhook means the call's outcome never reaches those systems or triggers additional workflows.

In this tutorial you build an app that keeps a record of every call an [ElevenLabs Agents](https://elevenlabs.io/agents) voice agent takes. After each call, ElevenLabs sends two webhooks: `post_call_transcription`, with the transcript and ElevenLabs' analysis (a summary, a success evaluation and the data you asked it to collect), and `post_call_audio`, with the recording. The app stores both and shows each conversation.

The webhooks go through [Hookdeck Event Gateway](/event-gateway), which verifies the `ElevenLabs-Signature`, drops duplicates and retries a delivery when your app fails, so the app stores each event once. The full code is in the [post-call-transcripts demo](https://github.com/hookdeck/hookdeck-demos/tree/main/elevenlabs/post-call-transcripts) on GitHub.

## How the webhooks reach your app

**Diagram:** A voice agent's call ends. ElevenLabs posts the transcript webhook to an Event Gateway source, Event Gateway verifies and stores it and answers 200, then delivers it to your app over HTTPS with its own signature, which your app verifies. The audio webhook follows the same path.

1. When a call ends, ElevenLabs sends two webhooks: the transcript, then the audio. Event Gateway sits between ElevenLabs and your app, which runs at an HTTPS URL.
2. ElevenLabs posts `post_call_transcription` (53 KB) to the Event Gateway source.
3. Event Gateway checks the `ElevenLabs-Signature`, stores the request and answers ElevenLabs with a 200.
4. Event Gateway delivers the event to your app over HTTPS and signs the delivery. Your app verifies the Hookdeck signature and stores the conversation.
5. `post_call_audio` (3.5 MB) follows a second later and takes the same path.

During development, the [Hookdeck CLI](/docs/cli) tunnels the webhooks to the app running on your machine. The diagrams in the steps below show that local setup.

ElevenLabs sends up to three kinds of post-call events, all with a `type`, a `data` object and an `event_timestamp`. The `data.conversation_id` field identifies the conversation in all three.

| Event | Contains |
| --- | --- |
| `post_call_transcription` | Transcript, metadata, analysis (`call_successful`, `transcript_summary`, evaluation and data collection results) |
| `post_call_audio` | The full conversation as a base64 MP3 |
| `call_initiation_failure` | `failure_reason` (`busy`, `no-answer` or `unknown`) for a call that never started |

A call that connects produces two webhooks, the transcription and the audio, about a second after hang-up. See the [ElevenLabs post-call webhook documentation](https://elevenlabs.io/docs/eleven-agents/workflows/post-call-webhooks) for the payloads, and the [guide to ElevenLabs webhooks](/webhooks/platforms/guide-to-elevenlabs-webhooks-features-and-best-practices) for the full reference.

## What you'll need

* An [ElevenLabs account](https://elevenlabs.io) and an API key that can create agents and workspace webhooks
* A [Hookdeck account](https://dashboard.hookdeck.com/signup), a project API key and the project signing secret
* Node.js 22 or later, and a microphone for a voice call (or use the demo's text-only `npm run call`)

Clone the demo and install it:

```bash
git clone https://github.com/hookdeck/hookdeck-demos.git
cd hookdeck-demos/elevenlabs/post-call-transcripts
npm install
cp .env.example .env

```

Add three keys to `.env`:

* `ELEVENLABS_API_KEY`: in the ElevenLabs dashboard, open the profile menu, then **API keys** ([API keys page](https://elevenlabs.io/app/settings/api-keys)). The key needs access to agents and workspace webhooks.
* `HOOKDECK_API_KEY`: in the Hookdeck dashboard, open **Project settings**, then [**Secrets**](https://dashboard.hookdeck.com/settings/project/secrets), and copy the project API key. Setup uses it to call the Hookdeck API.
* `HOOKDECK_SIGNING_SECRET`: copy the project signing secret from the same page. The app uses it to verify the `x-hookdeck-signature` header on each delivery, and it doesn't start without it.

You don't need an ElevenLabs agent of your own, because `npm run setup` creates one.

## Step 1: Create the ElevenLabs agent

Run `npm run setup`. It creates a hair salon booking agent named `Hookdeck demo: post-call transcripts` and writes its ID to `.env`, and it doesn't change your other agents. Two settings decide what the analysis contains, `dataCollection` and `evaluation`:

```ts
const AGENT_CONFIG = {
  conversationConfig: {
    agent: {
      firstMessage: 'Hi, this is the Hookdeck Hair booking line. How can I help?',
      // ...prompt
    },
    turn: { turnTimeout: 10 },
  },
  platformSettings: {
    dataCollection: {
      caller_name: { type: 'string', description: "The caller's name, if they gave it." },
      requested_service: { type: 'string', description: 'The service the caller wants.' },
      requested_time: { type: 'string', description: 'The day and time the caller agreed to.' },
    },
    evaluation: {
      criteria: [{
        id: 'booking_made',
        name: 'booking_made',
        type: 'prompt',
        conversationGoalPrompt: 'The agent confirmed an appointment with a service, a day and time, and the caller name.',
      }],
    },
  },
};

```

ElevenLabs runs the [data collection and evaluation criteria](https://elevenlabs.io/docs/eleven-agents/customization/agent-analysis) after the call, and their results arrive in the `analysis` object of the `post_call_transcription` webhook. The app shows them next to the transcript.

> The block also sets `firstMessage` and `turnTimeout`. Give the agent a first message, because an agent with no first message stays silent until the caller speaks, and after the turn timeout the first thing the caller hears is the "are you still there?" nudge.

## Step 2: Create the source and connection

The Event Gateway side takes two [Hookdeck API](/docs/api) calls, one here and one in step 3. The setup script sends them with a small `hookdeck()` helper (`scripts/hookdeck-api.ts` in the demo). The helper sends each request with your project API key from `HOOKDECK_API_KEY` as a bearer token, so the calls run against the project that key belongs to:

```ts
const HOOKDECK_API_BASE = 'https://api.hookdeck.com/2026-09-01';

async function hookdeck(method: string, route: string, body?: unknown) {
  const response = await fetch(`${HOOKDECK_API_BASE}${route}`, {
    method,
    headers: { authorization: `Bearer ${process.env.HOOKDECK_API_KEY}`, 'content-type': 'application/json' },
    body: body === undefined ? undefined : JSON.stringify(body),
  });
  const text = await response.text();
  if (!response.ok) throw new Error(`Hookdeck API ${method} ${route} -> ${response.status}: ${text.slice(0, 300)}`);
  return text ? JSON.parse(text) : undefined;
}

```

The deduplication and retry rules, which steps 6 and 7 explain, are a constant in the setup script:

```ts
const RULES = [
  {
    type: 'deduplicate',
    window: 60 * 60 * 1000,
    include_fields: ['body.type', 'body.data.conversation_id'],
  },
  { type: 'retry', strategy: 'linear', count: 5, interval: 10 * 1000 },
];

```

One `PUT /connections` call creates or updates the source, the destination and the connection, matched by name, so running setup again is safe. The source uses the `ELEVENLABS` source type, so Event Gateway knows how ElevenLabs signs requests. The destination is a CLI destination, which delivers to your machine through `hookdeck listen`:

```ts
const connection = await hookdeck('PUT', '/connections', {
  name: CONNECTION_NAME,
  source: { name: SOURCE_NAME, type: 'ELEVENLABS' },
  destination: { name: DESTINATION_NAME, type: 'CLI', config: { path: CLI_PATH } },
  rules: RULES,
});
const source_url = connection.source.url;

```

`connection.source.url` is the URL ElevenLabs sends webhooks to. `npm run setup` makes this call for you, and does the ElevenLabs side as well.

## Step 3: Create the ElevenLabs webhook and verify its signature

ElevenLabs shows a webhook's signing secret once, when you create the webhook, and the webhook needs the Event Gateway source URL. The setup script creates the webhook with the ElevenLabs API, passing the source URL, and gets the secret back:

```ts
const created = await elevenlabs.webhooks.create({
  settings: { authType: 'hmac', name: WEBHOOK_NAME, webhookUrl: source_url },
});
const id = created.webhookId;
const secret = created.webhookSecret;

```

Then set that secret on the source with `PUT /sources`. The `ELEVENLABS` source type fixes the header name, algorithm and timestamp format, so `config.auth` needs only the secret. `npm run setup` also writes the secret to `.env`:

```ts
await hookdeck('PUT', '/sources', {
  name: SOURCE_NAME,
  type: 'ELEVENLABS',
  config: { auth: { webhook_secret_key: secret } },
});

```

From then on Event Gateway checks the `ElevenLabs-Signature` header on every request to the source URL. The header has the form `t=<timestamp>,v0=<signature>`, where the signature is an HMAC-SHA256 of `<timestamp>.<raw body>`. See [how to secure and verify ElevenLabs webhooks with Hookdeck](/webhooks/platforms/how-to-secure-and-verify-elevenlabs-webhooks-with-hookdeck) for the details.

Finally the script attaches the webhook to the agent, so the agent sends the transcript, audio and failure events to it:

```ts
await elevenlabs.conversationalAi.agents.update(agent_id, {
  platformSettings: {
    workspaceOverrides: {
      webhooks: { postCallWebhookId: id, events: ['transcript', 'audio', 'call_initiation_failure'] },
    },
  },
});

```

You can do this part in the ElevenLabs dashboard instead. Create the webhook as described in the [ElevenLabs webhooks documentation](https://elevenlabs.io/docs/eleven-api/resources/webhooks), then open the agent's **Settings** and choose it under **Post-call webhooks**. The demo README lists the steps.

### See what a rejected request looks like

A request with a signature that doesn't verify gets a `200` response, so the sender sees nothing unusual. Event Gateway records the request as rejected with the cause `VERIFICATION_FAILED` and creates no event, so nothing reaches your app. Check the request list in the Hookdeck dashboard, and not the response status, to see whether a request verified.

The demo's `npm run probe` sends one correctly signed request and one badly signed request to the source, and reads both outcomes back from the request records.

**Diagram:** A request signed with the wrong secret reaches the Event Gateway source. Event Gateway accepts it, fails the signature check, records VERIFICATION_FAILED, creates no event and still answers 200, so the app is never called.

1. A request claims to come from ElevenLabs, but its signature was made with the wrong secret.
2. Event Gateway accepts the request, then checks its signature.
3. Verification of `ElevenLabs-Signature` fails. The request is recorded as `VERIFICATION_FAILED` and no event is created.
4. The sender still gets a 200, and your app is never called.

### Verify Hookdeck's signature in your handler

Event Gateway signs every delivery with an `x-hookdeck-signature` header, the base64 HMAC-SHA256 of the raw request body, keyed with the project signing secret. The handler recomputes the signature from the raw body and compares it with the header:

```ts
import { createHmac, timingSafeEqual } from 'crypto';

function verifyHookdeckSignature(raw_body: Buffer, signature_header: string | undefined, secret: string | undefined): boolean {
  if (!secret || !signature_header) return false;
  const expected = Buffer.from(createHmac('sha256', secret).update(raw_body).digest('base64'), 'utf8');
  const received = Buffer.from(signature_header, 'utf8');
  // timingSafeEqual throws when the lengths differ, so check the length first
  return expected.length === received.length && timingSafeEqual(expected, received);
}

```

The signature has no timestamp. Event Gateway verified the `ElevenLabs-Signature` when it accepted the request, so a retry or a replay hours later is a legitimate delivery and still passes. The handler answers `401` when the header is missing or wrong, and step 4 shows that check.

While you roll the signing secret, Event Gateway also sends `x-hookdeck-signature-2`, signed with the previous secret. The demo's `src/hookdeck-signature.ts` accepts either header.

The handler doesn't use the ElevenLabs SDK's `constructEvent`, because it rejects a signature with a timestamp older than 30 minutes, so a late retry or a replay would fail. See [Hookdeck webhook signature verification](/docs/authentication#hookdeck-webhook-signature-verification) for the header format.

## Step 4: Store the conversation

The handler first verifies Hookdeck's signature on the raw body and answers `401` when it doesn't match. It then skips an event it has already stored and passes the rest to `store.apply`:

```ts
router.post('/webhooks/elevenlabs', async (req, res) => {
  if (!verifyHookdeckSignature(req.rawBody, req.header('x-hookdeck-signature'), process.env.HOOKDECK_SIGNING_SECRET)) {
    return res.status(401).json({ error: 'invalid Hookdeck signature' });
  }

  const event = req.body as ElevenLabsEvent;

  if (store.hasProcessed(event)) {
    return res.status(200).json({ duplicate: true });
  }

  store.apply(event, req.rawBody.length);
  res.status(200).json({ received: true });
});

```

`store.apply` branches on `type` and merges each event into the conversation it belongs to, because the audio can arrive before the transcript. A `post_call_transcription` sets the transcript, summary, outcome and data collection results. A `post_call_audio` decodes the base64 MP3 to a file. A `call_initiation_failure` marks the conversation as failed to start.

## Step 5: Run the app and make a call

Start the app and the CLI in two terminals. `npm run listen` runs the Hookdeck CLI, which `npm install` added to the demo. It logs the CLI in with `HOOKDECK_API_KEY`, using its own config so your own `hookdeck login` isn't changed, then runs `hookdeck listen 4000 elevenlabs-post-call`.

```bash
npm run listen
npm start

```

Open `http://localhost:4000` and select **Call Hookdeck Hair**. The page asks for microphone access, then you talk to the booking agent from the browser. Ask for a haircut on Friday at 3pm and give a name. You can also hold a text-only conversation from the terminal:

```bash
npm run call

```

About a second after the call ends, the transcription and audio webhooks arrive and the conversation appears in the app with its summary, outcome, transcript, the data your agent collected and a player for the recording.

If the agent confirmed a booking, the appointment diary on the same page fills a slot from the call's `requested_time`. The collapsed **Deliveries received** section lists the latest requests the app received, each with its time, type, size, result, status code and attempt number.

The **Data flow** pane at the bottom of the page reads the requests, events and delivery attempts from the Hookdeck API and shows each webhook moving from ElevenLabs through Event Gateway and `hookdeck listen` to the app. Select a webhook's packet or a node to see its detail, including the event ID and each delivery attempt with its status code. A request that failed verification shows as rejected, with no event and no delivery.

## Step 6: Deduplicate on the event type and the conversation ID

A webhook can arrive more than once, for example when a delivery is retried. The post-call events for one conversation share a `conversation_id`, so deduplicating on the conversation ID alone would drop the audio event after the transcription arrived. The deduplication rule uses the event type and the conversation ID together:

```ts
{
  type: 'deduplicate',
  window: 60 * 60 * 1000,
  include_fields: ['body.type', 'body.data.conversation_id'],
}

```

The signature covers a timestamp, so a request that is sent again later can have a different `ElevenLabs-Signature`. That is why the rule compares named fields and not the whole request.

Event Gateway [deduplicates](/docs/deduplication) within a window of up to an hour. The app also keeps a `type:conversation_id` record and answers a repeat with `200`, so a duplicate outside the window is stored once as well.

**Diagram:** ElevenLabs sends the same transcript webhook a second time. Event Gateway matches the event type and conversation ID inside the deduplication window, drops the repeat, still answers 200, and forwards nothing to the app.

1. Your app has stored this call's transcript once.
2. ElevenLabs sends the same `post_call_transcription` again, because senders can deliver an event more than once.
3. Event Gateway sees the same `type + conversation_id` inside the dedup window and drops it. ElevenLabs still gets a 200.
4. Nothing is forwarded: your app is not called a second time.

To see it work without a call, run `npm run send -- --duplicate`. It sends the same signed `post_call_transcription` twice. In the demo's test, Event Gateway accepted both requests and the app received one delivery.

## Step 7: Retry failed deliveries

The `RULES` constant from step 2 also has a retry rule, five linear retries ten seconds apart:

```ts
{ type: 'retry', strategy: 'linear', count: 5, interval: 10 * 1000 }

```

**Diagram:** The app answers a delivery with a 500. Event Gateway keeps the event and retries every ten seconds, up to five times, and the second attempt succeeds once the app recovers.

1. Your app is down: it answers every delivery with a 500.
2. A `post_call_transcription` arrives. Event Gateway verifies it and stores it, as it always does.
3. Event Gateway delivers it through `hookdeck listen`. Attempt 1 gets a 500 from your app.
4. Event Gateway keeps the event and retries on a schedule: every 10 seconds, up to 5 times.
5. Your app recovers. Attempt 2 succeeds, and the event is delivered once.

The demo app can fail on request, so you can watch a retry. With the app and the CLI from step 5 still running, open `http://localhost:4000`. In the retry card, set **Fail the next** to `1` delivery and select **Apply**, then make another call.

The next delivery gets a `500`, and the retry about ten seconds later gets a `200` and stores the conversation. In the demo's test, attempt #1 was a `500` and attempt #2 was a `200` about 12 seconds later. Both attempts appear in the **Data flow** pane with their status codes.

If you exhaust the retries, open the event in the Hookdeck dashboard and replay it once the app is fixed. See [retries](/docs/retries) and [event replay](/docs/events).

## Check the payload sizes

The two webhooks differ a lot in size. These are the request bodies Event Gateway delivered in the demo's test calls:

| Webhook | Body size |
| --- | --- |
| `post_call_transcription`, voice call | about 53 KB |
| `post_call_transcription`, short text-only call | 6 to 18 KB |
| `post_call_audio`, voice call | about 3.5 MB |
| `post_call_audio`, text-only call | 435 bytes (no audio) |

The audio webhook contains the whole conversation as a base64 MP3, so its size grows with the length of the call. Event Gateway accepted a signed 8 MB `post_call_transcription` (sent with `npm run send -- --large 8`) and delivered it to the app. Write the audio to disk or object storage as soon as it arrives, and keep the database row to the transcript and analysis.

## Going to production

* **Storage:** replace the JSON file with your database, and enqueue the work in the handler instead of doing it inline
* **Fan-out:** add a second connection on the same source to send `call_initiation_failure` events to a Slack channel
* **Webhook health:** ElevenLabs [disables a webhook](https://elevenlabs.io/docs/eleven-api/resources/webhooks) after 10 or more consecutive failures when its last successful delivery was more than 7 days ago. Event Gateway accepts each request and retries delivery to your app, so an outage at your destination doesn't count against the webhook

Read the [guide to ElevenLabs webhooks](/webhooks/platforms/guide-to-elevenlabs-webhooks-features-and-best-practices) for the reference, and [get started with Hookdeck](https://dashboard.hookdeck.com/signup).