agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/real-time-transcription/SKILL.md

real-time-transcription

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: real-time-transcription

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All claims backed by live testing (2026-03-24, account ACxx...xx).

    line 15
  2. Distinctive:

    Use Google or Deepgram as the STT engine

    line 25
  3. Very specific:

    Run concurrently with <Recording> on the same call

    line 27
  4. Very specific:

    REST API error: If the call is not in-progress, the API returns error 21220 ("Call is not in the expected state").

    line 73
  5. Very specific:

    Use inboundTrackLabel='customer' and outboundTrackLabel='agent'

    line 103
  6. Very specific:

    Error 21220: If the call is not in-progress (still ringing, already completed), the API returns this error.

    line 186
  7. Very specific:

    No callbacks without statusCallbackUrl: If omitted, transcription runs silently with no way to receive results (unless using …

    line 269
  8. Very specific:

    Default engine is Google, default model is telephony: If you omit both transcriptionEngine and speechModel, you get Google's telephony …

    line 273
  9. Distinctive:

    After the call: transcript is persisted to Voice Intelligence

    line 326

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: real-time-transcription description: Twilio Real-Time Transcription development guide. Use when adding live transcription to voice calls via <Start><Transcription> or the Transcriptions REST API — covers engine selection, callback format, track behavior, and Voice Intelligence integration.

Real-Time Transcription Skill

Decision-making guide for Twilio Real-Time Transcription (RTT). Load this skill when adding live transcription to voice calls, choosing between transcription approaches, configuring callback handlers, or integrating with Voice Intelligence.

All claims backed by live testing (2026-03-24, account ACxx...xx). See references/test-results.md for the evidence matrix with call SIDs.


Scope

What RTT CAN Do

  • Transcribe live voice calls in near real-time (1-2s latency)
  • Transcribe both sides of a call independently (inbound_track, outbound_track, or both_tracks)
  • Use Google or Deepgram as the STT engine
  • Deliver partial (interim) and final transcription results via webhooks
  • Run concurrently with <Recording> on the same call
  • Integrate with Voice Intelligence for post-call analysis via intelligenceService attribute
  • Be started via TwiML (<Start><Transcription>) or REST API mid-call
  • Be stopped via TwiML (<Stop><Transcription>) or REST API
  • Label tracks with custom names (inboundTrackLabel, outboundTrackLabel)
  • Filter profanity, add punctuation, and provide recognition hints

What RTT CANNOT Do

  • Cannot do TTS — RTT is speech-to-text only. Use Google, Amazon Polly, or ElevenLabs for text-to-speech.
  • Cannot run Language Operators in real-time — Voice Intelligence operators (summarization, PII detection, sentiment) execute post-call on the persisted transcript, not during the call.
  • Cannot transcribe encrypted recordings — Voice Intelligence batch transcription fails on encrypted recordings.
  • Cannot create Intelligence Services via API — Services must be created in the Twilio Console (Console → Voice → Voice Intelligence).
  • Cannot provide speaker diarization in callbacks — Track labels identify call legs (inbound/outbound), not individual speakers. For multi-speaker diarization, use Voice Intelligence post-call.
  • Cannot guarantee callback ordering — SequenceId is monotonically increasing, but callbacks can arrive out of order at your webhook. Use SequenceId to reorder.
  • Cannot share an STT session with <Gather> — <Gather> and RTT can run on the same call simultaneously (tested), but each uses an independent STT engine and produces independent results. RTT continues through and after Gather timeouts.

Quick Decision: When to Use RTT

NeedUseWhy
Live captioning / monitoringRTTNear real-time webhooks with 1-2s latency
Compliance recording with transcriptRTT + RecordingBoth run simultaneously; RTT gives live text, recording gives audio archive
AI agent conversationConversationRelayBuilt-in STT as part of WebSocket AI flow, sub-second latency
Post-call analysis at scaleVoice Intelligence batchProcess recordings after call ends, minutes latency, full operator support
Custom STT engine<Start><Stream>Raw audio WebSocket, bring your own STT
IVR speech input<Gather input="speech">Purpose-built for collecting spoken responses with action URL
Live + post-call analysisRTT with intelligenceServiceReal-time webhooks during call, operators run after

Decision Frameworks

TwiML vs REST API

ScenarioUseWhy
Transcription starts at call beginningTwiML <Start><Transcription>Natural fit — part of the call flow
Transcription starts mid-callREST API POST /Calls/{sid}/TranscriptionsCan start on any in-progress call without TwiML change
Transcription needs to stop before call endsREST API POST .../Transcriptions/{sid} with Status=stoppedTwiML <Stop> requires a TwiML transition; API is immediate
Supervisor starts monitoring live callREST APINo TwiML change needed on the active call

REST API response returns sid (GT-prefixed), status (in-progress or stopped), name, call_sid.

REST API error: If the call is not in-progress, the API returns error 21220 ("Call is not in the expected state").

Engine Selection: Google vs Deepgram

FactorGoogle (default)Deepgram
Default engineYes — used when transcriptionEngine is omittedMust specify transcriptionEngine="deepgram"
Default modeltelephonyAccount-dependent
Partial result extrasNo Stability fieldIncludes Stability field (0-1 float)
Multi-language detectionNot availablelanguageCode="multi" with Nova-3 (beta)
Model namingtelephony, shortnova-3, nova-2, nova-3-general, nova-2-general
Case sensitivityN/AtranscriptionEngine is case-insensitive (deepgram or Deepgram)
HIPAA eligibilityYes (with persisted transcripts)Yes (with persisted transcripts, GA since Oct 2025)

For full Deepgram model compatibility across products (ConversationRelay, Gather, RTT), load the Deepgram skill.

Track Selection

TrackWhat it capturesUse case
inbound_trackAudio from the party who received the callMonitor what the customer says
outbound_trackAudio from the party who initiated the callMonitor what the agent/system says
both_tracks (default)Both sides, as separate callbacks per trackFull conversation transcript

How both_tracks works: Callbacks arrive with Track: "inbound_track" or Track: "outbound_track" on each transcription-content event. They are NOT interleaved into a single stream — each utterance is labeled with its source track. Use SequenceId for global ordering across tracks.

Speaker Diarization via Dual-Track

For compliance use cases requiring WHO said WHAT:

  • Set track='both_tracks' on <Start><Transcription>
  • Use inboundTrackLabel='customer' and outboundTrackLabel='agent'
  • Callbacks include the track label, enabling per-speaker analysis
  • Combined with Voice Intelligence, this enables automated speaker-attributed compliance checks

TwiML Integration

Starting Transcription

const twiml = new Twilio.twiml.VoiceResponse();
const start = twiml.start();
start.transcription({
  statusCallbackUrl: `https://${context.DOMAIN_NAME}/callbacks/transcription-status`,
  transcriptionEngine: 'deepgram',        // 'google' (default) or 'deepgram'
  speechModel: 'nova-3',                  // engine-specific model name
  languageCode: 'en-US',                  // BCP-47 code (default: en-US)
  track: 'both_tracks',                   // inbound_track, outbound_track, both_tracks
  inboundTrackLabel: 'customer',          // custom label for inbound track
  outboundTrackLabel: 'agent',            // custom label for outbound track
  partialResults: 'false',                // 'true' for interim results (high webhook volume)
  profanityFilter: 'true',               // replaces profanity with asterisks (default: true)
  enableAutomaticPunctuation: 'true',     // adds punctuation (default: true)
  hints: 'Twilio, ConversationRelay',     // recognition hints
  // intelligenceService: 'GAxxxxxxxx',   // Voice Intelligence Service SID for post-call analysis
  // enableProviderData: 'false',         // include raw engine metadata in callbacks
  // name: 'my-transcription',            // identifier for API-based stop
});

// Call continues — transcription runs in the background
twiml.say('Your call is being transcribed for quality assurance.');

Stopping Transcription

const twiml = new Twilio.twiml.VoiceResponse();
twiml.stop().transcription({
  // Omit to stop all active transcriptions on the call
  // Or specify: sid: 'GTxxxxxxxx'
});

Transcription also stops automatically when the call ends.

RTT + Recording (Both Work Simultaneously)

const start = twiml.start();
start.transcription({
  statusCallbackUrl: `https://${context.DOMAIN_NAME}/callbacks/transcription-status`,
  transcriptionEngine: 'deepgram',
  speechModel: 'nova-3',
});
start.recording({
  statusCallbackUrl: `https://${context.DOMAIN_NAME}/callbacks/call-status`,
});
// Both run concurrently — no conflict

REST API Integration

Start Transcription on In-Progress Call

const transcription = await client.calls(callSid)
  .transcriptions
  .create({
    statusCallbackUrl: `https://${context.DOMAIN_NAME}/callbacks/transcription-status`,
    transcriptionEngine: 'deepgram',
    speechModel: 'nova-3',
    name: 'supervisor-monitor',           // optional, for referencing later
    track: 'both_tracks',
  });

console.log(transcription.sid);     // GTxxxxxxxx
console.log(transcription.status);  // 'in-progress'
console.log(transcription.name);    // 'supervisor-monitor'

Error 21220: If the call is not in-progress (still ringing, already completed), the API returns this error. Poll call status before starting.

Stop Transcription

await client.calls(callSid)
  .transcriptions(transcriptionSid)
  .update({ status: 'stopped' });

TwiML Attribute Reference

AttributeValuesDefaultNotes
statusCallbackUrlAbsolute URLnoneWhere transcription events are sent. Without this, no callbacks are delivered.
transcriptionEnginegoogle, deepgramgoogleCase-insensitive
speechModelEngine-specifictelephony (Google)Deepgram: nova-3, nova-2, nova-3-general, nova-2-general. Google: telephony, short
languageCodeBCP-47 code, or multien-USmulti = Deepgram Nova-3 multi-language detection (beta)
trackinbound_track, outbound_track, both_tracksboth_tracksWhich call leg(s) to transcribe
inboundTrackLabelAlphanumeric stringnoneCustom label for inbound track in callbacks
outboundTrackLabelAlphanumeric stringnoneCustom label for outbound track in callbacks
partialResultstrue, falsefalseInterim results. Dramatically increases webhook volume.
profanityFiltertrue, falsetrueReplaces profanity with asterisks
enableAutomaticPunctuationtrue, falsetrueAdds punctuation to transcript text
hintsComma-separated phrasesnoneRecognition hints for domain-specific terms
intelligenceServiceService SID or namenoneVoice Intelligence integration for post-call analysis
enableProviderDatatrue, falsefalseInclude raw engine metadata in callbacks
nameAlphanumeric stringnoneIdentifier for referencing via REST API

Callback Format

Callbacks arrive as form-encoded POST (application/x-www-form-urlencoded), NOT JSON. See references/callback-reference.md for the complete field reference.

Parsing Transcript Content

// In your callback handler (Twilio Function):
exports.handler = async function (context, event, callback) {
  const { TranscriptionEvent, TranscriptionData, Final, Track, SequenceId } = event;

  if (TranscriptionEvent === 'transcription-content') {
    const data = JSON.parse(TranscriptionData);    // JSON string, not object
    const text = data.transcript;                   // "Hello, how can I help?"
    const confidence = data.confidence;             // 0.99 (only on Final=true)
    const isFinal = Final === 'true';               // String, not boolean
    const track = Track;                            // 'inbound_track' or 'outbound_track'
  }
};

Event Lifecycle

transcription-started  →  transcription-content (repeated)  →  transcription-stopped
                           ↑                                    ↑
                           Partial and/or final utterances       Auto on call end,
                                                                 or via API/TwiML stop

Gotchas

Callback Format

  1. Callbacks are form-encoded, not JSON: Transcription callbacks arrive as application/x-www-form-urlencoded. Do not JSON.parse(event.body). In Twilio Functions, access fields directly: event.TranscriptionData, event.Final, etc.
  2. Transcript text is in TranscriptionData, not TranscriptionText: TranscriptionData is a JSON string containing {"transcript":"...","confidence":0.99}. The field TranscriptionText is used by Video transcription, not voice RTT. Parsing event.TranscriptionText yields undefined.
  3. Final is a string, not a boolean: The value is "true" or "false" (string). Checking if (event.Final) is always truthy. Check event.Final === 'true' instead.
  4. confidence is only present on final results: Partial results (Final="false") include transcript but not confidence. Only final results (Final="true") include both fields.
  5. Callbacks can arrive out of order: SequenceId is monotonically increasing, but network conditions can deliver seq 5 before seq 4. Use SequenceId to reorder if ordering matters.

Configuration

  1. statusCallbackUrl must be an absolute URL: The docs specify "absolute URL." Always use https://domain/path, not /path.
  2. No callbacks without statusCallbackUrl: If omitted, transcription runs silently with no way to receive results (unless using intelligenceService for post-call persistence).
  3. partialResults=true generates high webhook volume: A 13-second call produced 22 callbacks with partials vs 5 without. Budget callback handler capacity accordingly. Consider async queuing for high-volume deployments.
  4. Default engine is Google, default model is telephony: If you omit both transcriptionEngine and speechModel, you get Google's telephony model. The transcription-started callback confirms the engine and model in ProviderConfiguration.
  5. Deepgram model names differ from <Gather>: RTT uses bare names (nova-3). <Gather> requires the deepgram_ prefix (deepgram_nova-3-general). ConversationRelay uses nova-3-general. Using the wrong format for the wrong product causes silent failures. See the Deepgram skill for the cross-product attribute map.

Runtime

  1. Invalid engine produces error 32650, call continues: An invalid transcriptionEngine value generates debugger error 32650 but does NOT terminate the call. The transcription silently fails and no callbacks are delivered.
  2. REST API requires in-progress call: Starting transcription via REST API on a call that isn't in-progress returns error 21220 ("Call is not in the expected state"). Poll call status before attempting.
  3. transcription-stopped fires automatically on call end: You do not need to explicitly stop transcription before hangup. The stopped event fires with the same TranscriptionSid.
  4. RTT and <Recording> coexist without conflict: Both <Transcription> and <Recording> can run inside the same <Start> block. They operate independently — each sends callbacks to its own statusCallbackUrl.

Observability

  1. transcription-started includes engine confirmation: The ProviderConfiguration field (JSON string) shows {"profanityFilter":"true","speechModel":"telephony","enableAutomaticPunctuation":"true"}. Use this to verify the correct engine and model were selected.
  2. Deepgram partials include Stability field: Deepgram partial results include a Stability field (0-1 float) indicating how likely the partial will change. Google does not include this field.
  3. LanguageCode is present on all content callbacks: Both transcription-started and transcription-content events include the LanguageCode field.
  4. enableAutomaticPunctuation=false may not remove punctuation with Deepgram: Testing with Deepgram Nova-3 showed punctuation (periods, commas) still appearing in transcripts even with enableAutomaticPunctuation="false". The flag is confirmed in ProviderConfiguration but Deepgram's model may emit punctuation regardless. Test with your specific engine before relying on this flag.
  5. Transcription has the same consent requirements as recording: Real-time transcription captures call content. The same one-party/two-party consent laws that apply to call recording apply to transcription. Always notify callers when transcription is active.
  6. RTT and <Gather> run independently: <Start><Transcription> and <Gather input="speech"> can coexist on the same call. RTT continues transcribing through and after a Gather timeout. Gather's STT session is separate from RTT's — they use independent engines and produce independent results. No errors or interference observed.

Voice Intelligence Concurrent Processing

  1. Two Intelligence Services on the same recording produce undefined behavior: If two <Start><Transcription> blocks target the same call with different intelligenceService SIDs, or if a recording is submitted to multiple Intelligence Services via REST API, the result is unpredictable. Twilio does not enforce idempotency — you may get duplicate transcripts, conflicting operator results, or race conditions on transcript storage. Pattern: Use exactly one Intelligence Service per call. If you need multiple operator pipelines, configure multiple Language Operators on a single service rather than running multiple services.
  2. No idempotency on source_sid: Submitting the same recording SID to an Intelligence Service twice creates two separate transcripts. There is no deduplication. Pattern: Track processed recording SIDs in a Sync Map (key = recording SID, value = transcript SID). Before submitting, check the map. This prevents duplicate processing from webhook retries or concurrent handlers.
  3. Intelligence Service creation is Console-only: There is no REST API to create Intelligence Services (GA-prefixed SIDs). If your credential rotation process involves recreating resources programmatically, Intelligence Services are a manual step that can be missed.

Voice Intelligence Integration

RTT integrates with Voice Intelligence via the intelligenceService attribute. This is the bridge between real-time and post-call analysis.

start.transcription({
  transcriptionEngine: 'deepgram',
  speechModel: 'nova-3',
  intelligenceService: context.TWILIO_INTELLIGENCE_SERVICE_SID, // GA-prefixed SID
  statusCallbackUrl: callbackUrl,
});

What happens:

  1. During the call: webhooks deliver real-time transcript to your statusCallbackUrl
  2. After the call: transcript is persisted to Voice Intelligence
  3. Language Operators run on the persisted transcript (summarization, PII detection, sentiment, custom extraction)
  4. Results available via list_operator_results MCP tool or REST API

Intelligence Services (v2) must be created in the Twilio Console — there is no creation API. For the v3 Conversational Intelligence API (Language Operators, real-time analysis, cross-channel), see Conversational Intelligence v3 Skill.

Compliance Detection via Language Operators

For automated compliance monitoring (UDAAP violations, unauthorized commitments, disclosure omission):

  1. Real-time (in-call): Pattern match in transcription callback handler against keyword lists. Limited to text matching — no semantic analysis.
  2. Post-call (batch): Use Voice Intelligence with Language Operators:
    • text-generation operator: Summarize calls for compliance review
    • classification operator: Flag calls by compliance risk category
    • extraction operator: Pull specific regulatory phrases (disclosures, commitments)
  3. Hybrid: Real-time flags trigger immediate alerts; post-call operators produce structured compliance reports.

Language Operators require an Intelligence Service SID (created in Console — no API for creation).


Related Resources

  • Deepgram STT Skill — Cross-product model naming, Deepgram-specific config, tested model matrix
  • Voice Skill — Transcription Method Selection framework, broader voice context
  • Voice Use Case Map — Per-use-case product recommendations
  • Media Streams Skill — Alternative: raw audio WebSocket with custom STT
  • Voice CLAUDE.md — TwiML control model, background operations
  • MCP Tools: validate_transcript, get_transcript, list_transcripts, delete_transcript, create_transcript, list_sentences, list_operator_results, get_transcript_media, list_recording_transcriptions, get_transcription
  • Conversational Intelligence v3 Skill — v3 API: Language Operators, real-time/post-call analysis, cross-channel
  • Codebase: transcription-status.protected.js — RTT callback handler with Sync logging

Reference Files

TopicFileWhen to read
Callback fieldsreferences/callback-reference.mdParsing callbacks, building handlers, field-level details per event type
Test evidencereferences/test-results.mdFull test matrix with call SIDs, callback payloads, and discovery narratives
Conference + RTT/skills/conference/references/rtt-interaction.mdTrack semantics in conference, hold behavior, speaker labeling limits

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.