Expand description
Vendor-neutral call-bridge components.
Every contact-center connector — Twilio Media Streams, a raw SIP/RTP leg,
a platform’s gRPC virtual-agent slot — reduces to the same duties: move
audio frames both ways through voice::pump, land
caller keypresses and call identity in session state where flow guards
read them, and keep the caller’s ear busy while slow work runs. This
module holds those duties as small, connector-agnostic components, so a
new connector composes them instead of re-inventing them.
Nothing here owns a socket. Connectors own transport; these components own semantics.
Structs§
- Dtmf
Deduper - Deduplicates RFC 4733 end-of-event packets.
- Filler
Config - Configuration for
spawn_latency_filler. - Keypad
Guard - Keeps keypad tones and masked keypad entry away from the model.
Constants§
- KEY_
CALLER - State key holding the caller identity the transport presented
(SIP
From, a platform’s ANI field, …). - KEY_
CALL_ SID - State key holding the transport’s call identifier once known.
- KEY_
DTMF - State key holding the most recent DTMF digit pressed by the caller.
- KEY_
DTMF_ HISTORY - State key holding every DTMF digit pressed so far, concatenated in order.
- KEY_
KEYPAD_ DONE - Set to
truewhen the caller presses#while the keypad is masked. - KEY_
KEYPAD_ ENTRY - Digits keyed while the keypad was masked, in order. The key is marked
sensitive (
State::redact_keys): tools read the real value, while journals, exports and telemetry see it redacted. - KEY_
KEYPAD_ LEN - How many digits
KEY_KEYPAD_ENTRYholds. Not sensitive, so a flow can guard on it. - KEY_
KEYPAD_ MASK - Set this state key to
trueto mask the keypad: while it is set, the caller’s audio reaches neither the model nor the recording (it is replaced with silence), and keypresses go toKEY_KEYPAD_ENTRYinstead ofKEY_DTMF. This is the “pause and resume” pattern for taking card numbers and PINs by keypad. Set it back tofalseto resume. - KEY_
STREAM_ SID - State key holding the transport’s media-stream identifier once known.
Functions§
- keypad_
masked - Whether the keypad is masked (see
KEY_KEYPAD_MASK). - record_
dtmf - Record one DTMF keypress into session state under the shared keys.
- spawn_
latency_ filler - Keep the caller’s ear busy while the model is slow: when the caller stops
speaking (
LiveEvent::VadEnd) and no model audio arrives withinconfig.delay, inject the configured clip into the connector’s playback channel. Model audio or an interruption disarms the timer; aPlayback::Flushfrom a barge-in clears any queued filler exactly like any other queued audio.