Skip to content

Commit 877d951

Browse files
authored
docs: add transcriptType and turnId fields to WebSocket message docs (#978)
1 parent ff44ad8 commit 877d951

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

fern/customization/custom-transcriber.mdx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,22 @@ You'll learn how to:
4343
Your server forwards the audio to Deepgram (or your chosen transcriber) using its SDK. Deepgram processes the audio and returns transcript events that include a `channel_index` (e.g. `[0, ...]` for customer, `[1, ...]` for assistant). The service buffers the incoming data, processes the transcript events (with debouncing and channel detection), and emits a final transcript.
4444
</Step>
4545
<Step title="Response">
46-
The final transcript is sent back to Vapi as a JSON message:
46+
The transcript is sent back to Vapi as a JSON message:
4747
```json
4848
{
4949
"type": "transcriber-response",
5050
"transcription": "The transcribed text",
51-
"channel": "customer" // or "assistant"
51+
"channel": "customer",
52+
"transcriptType": "final"
5253
}
5354
```
55+
56+
The optional `transcriptType` field controls how Vapi handles the transcript:
57+
58+
- **`"final"`** (default) — the transcription is definitive.
59+
- **`"partial"`** — the transcription is provisional and may be superseded by a later message. Each partial replaces the previous one until a `"final"` arrives.
60+
61+
If omitted, `transcriptType` defaults to `"final"` for backward compatibility.
5462
</Step>
5563
</Steps>
5664

@@ -362,6 +370,7 @@ You'll learn how to:
362370
type: "transcriber-response",
363371
transcription: text,
364372
channel,
373+
transcriptType: "final",
365374
};
366375
ws.send(JSON.stringify(response));
367376
logger.logDetailed("INFO", "Sent transcription to client", "Server", {
@@ -423,12 +432,13 @@ You'll learn how to:
423432
- The `"start"` message initializes the Deepgram session.
424433
- PCM audio data is forwarded to Deepgram.
425434
- Deepgram returns transcript events, which are processed with channel detection and debouncing.
426-
- The final transcript is sent back as a JSON message:
435+
- The transcript is sent back as a JSON message:
427436
```json
428437
{
429438
"type": "transcriber-response",
430439
"transcription": "The transcribed text",
431-
"channel": "customer" // or "assistant"
440+
"channel": "customer",
441+
"transcriptType": "final"
432442
}
433443
```
434444
</Step>
@@ -444,6 +454,8 @@ You'll learn how to:
444454
The solution buffers PCM audio and performs simple validation (e.g. ensuring stereo PCM data length is a multiple of 4). If the audio data is malformed, it is trimmed to a valid length.
445455
- **Channel detection:**
446456
Transcript events from Deepgram include a `channel_index` array. The service uses the first element to determine whether the transcript is from the customer (`0`) or the assistant (`1`). Ensure Deepgram's response format remains consistent with this logic.
457+
- **Partial transcripts:**
458+
Set `transcriptType` to `"partial"` to send progressive transcription updates. Each partial supersedes the previous one until a `"final"` message arrives. This is useful for STT providers that emit fast, low-latency partials that get refined over time (e.g. ElevenLabs Scribe). If `transcriptType` is omitted, Vapi treats the message as `"final"`.
447459

448460
---
449461

fern/server-url/events.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,14 @@ For final-only events, you may receive `type: "transcript[transcriptType=\"final
289289

290290
### Model Output
291291

292-
Tokens or tool-call outputs as the model generates.
292+
Tokens or tool-call outputs as the model generates. The optional `turnId` groups all tokens from the same LLM response, so you can correlate output with a specific turn.
293293

294294
```json
295295
{
296296
"message": {
297297
"type": "model-output",
298-
"output": { /* token or tool call */ }
298+
"output": { /* token or tool call */ },
299+
"turnId": "abc-123"
299300
}
300301
}
301302
```
@@ -339,10 +340,13 @@ Fires whenever a transfer occurs.
339340

340341
### User Interrupted
341342

343+
Sent when the user interrupts the assistant. The optional `turnId` identifies the LLM turn that was interrupted, matching the `turnId` on `model-output` messages so you can discard that turn's tokens.
344+
342345
```json
343346
{
344347
"message": {
345-
"type": "user-interrupted"
348+
"type": "user-interrupted",
349+
"turnId": "abc-123"
346350
}
347351
}
348352
```

0 commit comments

Comments
 (0)