When building outbound calling workflows, one of the most common challenge is handling unanswered calls that get redirected to voicemail systems. Without proper detection, an AI agent may continue speaking unnecessarily or wait indefinitely, leading to wasted resources and poor user experience.
Voice Mail Detection in VideoSDK solves this problem by automatically identifying voicemail scenarios and allowing your agent to take the appropriate action such as leaving a message or ending the call gracefully.
What Problem This Solves
In outbound calling workflows, unanswered calls are often routed to voicemail systems. Without detection, agents may continue speaking or wait unnecessarily.
Voice Mail Detection lets you:
- Detect voicemail systems automatically
- Control how your agent responds
- End calls cleanly after voicemail handling
- Enabling Voice Mail Detection
- To use voicemail detection, import and add VoiceMailDetector to your agent configuration and register a callback that defines how voicemail should be handled.
from videosdk.agents import VoiceMailDetector
from videosdk.plugins.openai import OpenAILLM
async def voice_mail_callback(message):
print("Voice Mail message received:", message)
voicemail = VoiceMailDetector(
llm=OpenAILLM(),
duration=5,
callback=custom_callback_voicemail,
)
session = AgentSession(
voice_mail_detector=voicemail
)
Full Working Example
To set up incoming call handling, outbound calling, and routing rules, check out the Quick Start Example
import logging
from videosdk.agents import Agent, AgentSession, CascadingPipeline,WorkerJob,ConversationFlow, JobContext, RoomOptions, Options,VoiceMailDetector
from videosdk.plugins.deepgram import DeepgramSTT
from videosdk.plugins.openai import OpenAILLM
from videosdk.plugins.elevenlabs import ElevenLabsTTS
from videosdk.plugins.silero import SileroVAD
from videosdk.plugins.turn_detector import TurnDetector, pre_download_model
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", handlers=[logging.StreamHandler()])
pre_download_model()
class VoiceAgent(Agent):
def __init__(self):
super().__init__(
instructions="You are a helpful voice assistant that can answer questions."
)
async def on_enter(self) -> None:
await self.session.say("Hello, how can I help you today?")
async def on_exit(self) -> None:
await self.session.say("Goodbye!")
async def entrypoint(ctx: JobContext):
agent = VoiceAgent()
conversation_flow = ConversationFlow(agent)
pipeline=CascadingPipeline(
stt=DeepgramSTT(),
llm=OpenAILLM(),
tts=ElevenLabsTTS(),
vad=SileroVAD(),
turn_detector=TurnDetector()
)
async def voice_mail_callback(message):
print("Voice Mail message received:", message)
voice_mail_detector = VoiceMailDetector(llm=OpenAILLM(), duration=5.0, callback = voice_mail_callback)
session = AgentSession(
agent=agent,
pipeline=pipeline,
conversation_flow=conversation_flow,
voice_mail_detector = voice_mail_detector,
)
await session.start(wait_for_participant=True, run_until_shutdown=True)
def make_context() -> JobContext:
room_options = RoomOptions(name="Voice Mail Detector Test", playground=True)
return JobContext(room_options=room_options)
if __name__ == "__main__":
job = WorkerJob(entrypoint=entrypoint, jobctx=make_context, options=Options(agent_id="YOUR_AGENT_ID", max_processes=2, register=True, host="localhost", port=8081))
job.start()
Conclusion
Voice Mail Detection ensures your AI agent handles unanswered calls intelligently. By automatically detecting voicemail and triggering the right action, it prevents wasted time, improves call efficiency, and makes outbound workflows reliable and production-ready.
Resources and Next Steps
- Explore the voice mail detection implementation on github.
- Read voice mail detection docs.
- To set up inbound calls, outbound calls, and routing rules check out the Quick Start Example.
- Learn how to deploy your AI Agents.
- Explore more: Check out the VideoSDK documentation for more features.
👉 Share your thoughts, roadblocks, or success stories in the comments or join our Discord community ↗. We’re excited to learn from your journey and help you build even better AI-powered communication tools!
Top comments (0)