Skip to main content
Version: 0.9.14

Speech playback and hangup

Delphi treats speech output and call teardown as ordered work, not fire-and-forget audio. In pipeline flows (separate STT + LLM + TTS), multiple bot messages and runtime commands such as hangup are serialized so callers hear complete prompts before the line drops. Realtime flows stream audio from the vendor connection; hangup still respects configured wait-for-silence and disconnect delay settings on the call leg.

This page is the canonical reference for TTS queueing and hangup timing. Per-vendor field lists stay on each provider page; callback field names stay in Managed callback actions.

Pipeline mode — outbound speech queue

When the flow uses Pipeline mode, TelPhi runs a modular audio pipeline that connects STT → LLM → TTS. Every complete LLM or managed-bot text response enters an outbound queue before the next item runs.

BehaviorDetail
Multi-message playbackIf the bot sends several complete responses in quick succession (typical for TOBi managed LLM callbacks), each message is synthesized and played in order. Message 2 does not start until Message 1 has finished playing.
Queued runtime commandsCommands such as hangup, update_dtmf_config, or transfer submitted while speech is pending are held until earlier queue items finish. A hangup therefore runs only after prior queued speech has drained.
Playback waitAfter each queued speak item, TelPhi waits for the call session to report silence (with a timeout derived from text length). If the wait times out, the queue continues rather than blocking the call indefinitely.
TTS fallbackIf primary TTS synthesis fails, the pipeline may retry the same sentence on the configured fallback TTS provider before moving on.

Pipeline queueing applies regardless of which TTS vendor is configured (Azure, OpenAI, Inworld, …). Vendor pages document voices and endpoints only — not queue semantics.

Realtime mode — provider-native audio

Realtime providers (OpenAI Realtime, Azure Realtime, Gemini Live, Grok, Pythia) stream audio through a single vendor connection. They do not use the modular outbound queue above; playback timing follows the provider's own streaming model.

Hangup and transfer actions still go through the shared call action service on the TelPhi call leg, so Wait for silence and Delay bot disconnect apply the same way when a managed action or sandbox tool ends the call.

Hangup and disconnect timing

Managed hangup, failover hangup, sandbox hangup() tools, and TOBi explicit hangup callbacks all resolve through the same hangup pipeline.

Execution order

When a hangup action runs:

  1. SIP BYE headers are prepared (Reason, custom headers from flow rules or callback overrides).
  2. Farewell message — if configured and a speak path exists, Delphi plays it.
  3. Wait for silence — when enabled, TelPhi waits until active playback on the call leg has finished (so farewell or bot TTS is not cut off mid-sentence).
  4. Delay bot disconnect — optional extra grace period (delayBotDisconnectMs, 0–30000 ms) after the silence wait, before the Asterisk channel is hung up.
  5. Channel hangup — the SIP/PSTN leg is released.

Flow settings

Configure defaults on the Managed hangup child node or in Flow Settings → managed gateway actions.hangup:

SettingDefaultEffect
Wait for silencetrueWait for active TTS playback to finish before disconnecting. Set false only when the call must drop immediately (for example inbound-not-ready hangup).
Farewell messageemptyOptional text Delphi speaks before hangup when a TTS path exists.
Allow message overridetrueWhether a runtime/callback hangup may replace the configured farewell.
Delay bot disconnect (ms)0Additional pause after silence wait, before the channel hangup. Use when the carrier or bot leg needs extra time after audio ends. Maximum 30000.

Per-call overrides arrive through Managed callback actions (hangupReason, hangupSipHeaders, …) or runtime hangup commands on the managed gateway. Flow defaults fill in anything the callback omits.

UI reference: Managed hangup inspector and Managed hangup node.

Canvas tts_playback nodes

The TTS playback node plays fixed text through the flow's TTS provider (greetings, prompts, farewells in non-managed flows). It uses the same call-session playback tracking as pipeline TTS, so a subsequent hangup with Wait for silence enabled still waits for that node to finish.

Managed LLM (TOBi) specifics

TOBi managed LLM runs in pipeline mode with Vodafone as the LLM stage. That combination is where multi-message queueing matters most:

ScenarioBehavior
Several callback messagesEach TOBi text response is enqueued and played sequentially.
Explicit hangup callbackHangup is a runtime command; it runs after any earlier queued speech completes.
Phrase-detected hangupWhen TOBi ends a turn with a conversation-closing phrase and no explicit hangup action, TelPhi schedules hangup in the background; the hangup path still uses wait for silence so the farewell TTS finishes first.
Config / DTMF updates mid-callupdate_dtmf_config and similar commands queue behind pending speech the same way hangup does.

Callback schema and field names: Managed callback actions and Webhooks → Managed runtime commands.

Where each doc layer stops

LayerDocuments
This pageQueue semantics, hangup order, waitForSilence, delayBotDisconnectMs — shared across vendors and flow types.
Provider pagesVendor models, voices, API keys, custom URLs.
Managed callback actionsJSON fields bots send on transfer/hangup/failover callbacks.
Flow Designer nodes / inspectorsCanvas editing of managed actions, failover, and tts_playback.

Troubleshooting

SymptomLikely causeWhat to check
Call drops before the bot finishes speakingWait for silence off on managed hangup, or hangup not queued behind speechManaged hangup inspector; TOBi callback order (message before hangup in same batch still queues correctly, but immediate SIP BYE from carrier is upstream).
Long pause after speech before disconnectDelay bot disconnect setFlow delayBotDisconnectMs or callback override.
Second bot message talks over the firstPipeline queue bug or Realtime flow (no queue)Confirm flow mode; Realtime uses vendor streaming, not the modular queue.
Farewell never heardEmpty farewell, TTS failure, or override blockedFarewell message + Allow message override; TelPhi logs for TTS errors.
Inbound call hangs up instantly on bot timeoutInbound-not-ready path forces waitForSilence: falseBot readiness vs failover after answer.

See also