voicemail

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package voicemail provides ClassificationProcessor for voicemail vs conversation detection.

Package voicemail provides VoicemailDetector for outbound call classification.

Package voicemail provides voicemail detection for outbound calls (human vs voicemail).

Index

Constants

View Source
const ClassifierResponseInstruction = `Respond with ONLY "CONVERSATION" if a person answered, or "VOICEMAIL" if it's voicemail/recording.`

ClassifierResponseInstruction is the required suffix for custom prompts.

View Source
const DefaultClassifierPrompt = `You are a voicemail detection classifier for an OUTBOUND calling system. A bot has called a phone number and you need to determine if a human answered or if the call went to voicemail based on the provided text.

HUMAN ANSWERED - LIVE CONVERSATION (respond "CONVERSATION"):
- Personal greetings: "Hello?", "Hi", "Yeah?", "John speaking"
- Interactive responses: "Who is this?", "What do you want?", "Can I help you?"
- Conversational tone expecting back-and-forth dialogue
- Questions directed at the caller: "Hello? Anyone there?"
- Informal responses: "Yep", "What's up?", "Speaking"
- Natural, spontaneous speech patterns
- Immediate acknowledgment of the call

VOICEMAIL SYSTEM (respond "VOICEMAIL"):
- Automated voicemail greetings: "Hi, you've reached [name], please leave a message"
- Phone carrier messages: "The number you have dialed is not in service", "Please leave a message", "All circuits are busy"
- Professional voicemail: "This is [name], I'm not available right now"
- Instructions about leaving messages: "leave a message", "leave your name and number"
- References to callback or messaging: "call me back", "I'll get back to you"
- Carrier system messages: "mailbox is full", "has not been set up"
- Business hours messages: "our office is currently closed"

` + ClassifierResponseInstruction

DefaultClassifierPrompt is the default system prompt for voicemail classification.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassificationProcessor

type ClassificationProcessor struct {
	*processors.BaseProcessor
	// contains filtered or unexported fields
}

ClassificationProcessor aggregates LLM classification responses and triggers gate notifiers and event handlers for CONVERSATION vs VOICEMAIL.

func NewClassificationProcessor

func NewClassificationProcessor(name string, gateNotifier, conversationNotifier, voicemailNotifier *notifier.Notifier, voicemailResponseDelaySecs float64) *ClassificationProcessor

NewClassificationProcessor creates a processor that classifies CONVERSATION vs VOICEMAIL from LLM output.

func (*ClassificationProcessor) Cleanup

func (p *ClassificationProcessor) Cleanup(ctx context.Context) error

Cleanup cancels the delay goroutine.

func (*ClassificationProcessor) OnConversationDetected

func (p *ClassificationProcessor) OnConversationDetected(fn func())

OnConversationDetected sets the callback when CONVERSATION is classified.

func (*ClassificationProcessor) OnVoicemailDetected

func (p *ClassificationProcessor) OnVoicemailDetected(fn func())

OnVoicemailDetected sets the callback when VOICEMAIL is classified (after delay).

func (*ClassificationProcessor) ProcessFrame

ProcessFrame aggregates LLM text and classifies on LLMFullResponseEndFrame.

func (*ClassificationProcessor) Setup

Setup starts the delayed voicemail handler goroutine.

type ClassifierGate

type ClassifierGate struct {
	*NotifierGate
	// contains filtered or unexported fields
}

ClassifierGate closes when the gate notifier signals; when closed, still forwards UserStartedSpeakingFrame/UserStoppedSpeakingFrame only if conversation was not detected (voicemail case).

func NewClassifierGate

func NewClassifierGate(name string, gateNotifier, conversationNotifier *notifier.Notifier) *ClassifierGate

NewClassifierGate creates a classifier gate. gateNotifier signals when classification is done; conversationNotifier signals when conversation (not voicemail) was detected.

func (*ClassifierGate) Cleanup

func (g *ClassifierGate) Cleanup(ctx context.Context) error

Cleanup cancels the conversation wait.

func (*ClassifierGate) ProcessFrame

func (g *ClassifierGate) ProcessFrame(ctx context.Context, f frames.Frame, dir processors.Direction) error

ProcessFrame when closed allows UserStarted/StoppedSpeaking only if conversation not detected.

func (*ClassifierGate) Setup

func (g *ClassifierGate) Setup(ctx context.Context) error

Setup starts the parent gate and a goroutine to wait for conversation detection.

type ConversationGate

type ConversationGate struct {
	*NotifierGate
}

ConversationGate closes when voicemail is detected (blocks conversation flow).

func NewConversationGate

func NewConversationGate(name string, voicemailNotifier *notifier.Notifier) *ConversationGate

NewConversationGate creates a gate that closes when voicemailNotifier signals.

type NotifierGate

type NotifierGate struct {
	*processors.BaseProcessor
	// contains filtered or unexported fields
}

NotifierGate is a base gate that starts open and closes permanently when the notifier signals. When closed, only system/end frames are forwarded.

func NewNotifierGate

func NewNotifierGate(name string, n *notifier.Notifier) *NotifierGate

NewNotifierGate creates a gate that closes when n signals.

func (*NotifierGate) Cleanup

func (g *NotifierGate) Cleanup(ctx context.Context) error

Cleanup cancels the wait goroutine.

func (*NotifierGate) ProcessFrame

func (g *NotifierGate) ProcessFrame(ctx context.Context, f frames.Frame, dir processors.Direction) error

ProcessFrame forwards all frames when open; when closed, only system/end frames.

func (*NotifierGate) Setup

func (g *NotifierGate) Setup(ctx context.Context) error

Setup starts a goroutine that waits for the notifier and then closes the gate.

type TTSGate

type TTSGate struct {
	*processors.BaseProcessor
	// contains filtered or unexported fields
}

TTSGate buffers TTS-related frames until conversation or voicemail notifier signals. On conversation: release buffered frames. On voicemail: clear buffer.

func NewTTSGate

func NewTTSGate(name string, conversationNotifier, voicemailNotifier *notifier.Notifier) *TTSGate

NewTTSGate creates a TTS gate. Conversation notifier releases frames; voicemail notifier clears them.

func (*TTSGate) Cleanup

func (g *TTSGate) Cleanup(ctx context.Context) error

Cleanup cancels the wait goroutines.

func (*TTSGate) ProcessFrame

func (g *TTSGate) ProcessFrame(ctx context.Context, f frames.Frame, dir processors.Direction) error

ProcessFrame gates TTS frames; releases or clears on notifier signal.

func (*TTSGate) Setup

func (g *TTSGate) Setup(ctx context.Context) error

Setup starts goroutines waiting for conversation or voicemail.

type VoicemailDetector

type VoicemailDetector struct {
	// DetectorBranch is the parallel pipeline to insert after STT (classification branch + conversation gate branch).
	DetectorBranch *pipeline.ParallelPipeline
	// GateProcessor is the TTS gate to insert after TTS in the main pipeline.
	GateProcessor *TTSGate
	// contains filtered or unexported fields
}

VoicemailDetector builds a parallel pipeline for voicemail vs conversation classification and a TTS gate. Use Detector() in the main pipeline (e.g. after STT) and Gate() after TTS.

func NewVoicemailDetector

func NewVoicemailDetector(llm services.LLMService, voicemailResponseDelaySecs float64) *VoicemailDetector

NewVoicemailDetector creates a detector that uses the given LLM for classification. voicemailResponseDelaySecs is the delay before firing on_voicemail_detected (0 = 2.0).

func NewVoicemailDetectorWithPrompt

func NewVoicemailDetectorWithPrompt(llm services.LLMService, voicemailResponseDelaySecs float64, systemPrompt string) *VoicemailDetector

NewVoicemailDetectorWithPrompt creates a detector with a custom classifier prompt. The prompt should instruct the LLM to respond with exactly "CONVERSATION" or "VOICEMAIL".

func (*VoicemailDetector) Detector

Detector returns the parallel pipeline processor to add to the main pipeline (e.g. after STT).

func (*VoicemailDetector) Gate

func (d *VoicemailDetector) Gate() *TTSGate

Gate returns the TTS gate processor to add after TTS in the main pipeline.

func (*VoicemailDetector) OnConversationDetected

func (d *VoicemailDetector) OnConversationDetected(fn func())

OnConversationDetected sets the callback when CONVERSATION is classified.

func (*VoicemailDetector) OnVoicemailDetected

func (d *VoicemailDetector) OnVoicemailDetected(fn func())

OnVoicemailDetected sets the callback when VOICEMAIL is classified (after delay).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL