Inbound Call의 경우 Agent 샘플코드를 보여줘.
# ask-ai
l
Inbound Call의 경우 Agent 샘플코드를 보여줘.
t
Thanks for reaching out, Dan(송희웅). I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you get started with implementing an inbound call agent in LiveKit, here’s a simple Python sample code you can use as a foundation:
Copy code
from livekit.agents import JobContext, WorkerOptions, cli

async def entrypoint(ctx: JobContext):
    # Start the agent in the room
    await ctx.connect()

    # Greet the caller after picking up
    initial_message = "Hello, how can I help you today?"
    await ctx.agent.say(initial_message, allow_interruptions=True)

if __name__ == "__main__":
    # Start the agent worker
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
This example shows you how to connect an agent to a room and respond to an inbound SIP call. From here, you can easily build on it by adding features like speech-to-text (STT) and text-to-speech (TTS) using plugins such as OpenAI. If you’d like, I’m here to walk you through more details on setting up SIP trunks, dispatch rules, or handling DTMF inputs. Just let me know, and I’ll gladly help you with the next steps! Sources: examples/warm-transfer/README.md | Create and configure a Plivo SIP trunk | LiveKit Docs | Using Wavix to accept and make calls | LiveKit Docs | App templates | LiveKit Docs | SIP inbound trunk | LiveKit Docs
l
cli.run_app( WorkerOptions( entrypoint_fnc=entrypoint, agent_name="inbound-demo-test", ) )
agent_name
은 지정하는게 아니야?
t
Hi there! I wanted to share a little insight about the
agent_name
parameter in
WorkerOptions
. While it’s not absolutely required for your code to run, it plays a really important role when you’re using explicit agent dispatch. By setting the
agent_name
, you make sure that only the specific agent you want will handle incoming calls, which is especially helpful for telephony integrations. To make sure inbound calls are handled smoothly, the
agent_name
needs to match in two key places: • In
WorkerOptions
when you’re creating the agent. • In the dispatch rule configuration (like
RoomAgentDispatch
). If you’re working with explicit dispatch, double-checking that the
agent_name
is set correctly in both spots can save you some headaches. And if you’d like, I’m here to help you with this setup—just let me know! Sources: Agents telephony integration | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs
l
전화를 하면 Agent에 연결은 되는데 왜 전화가 Agent와 연결은 안되지?
t
If your inbound SIP call connects to the agent but you’re not hearing any communication, don’t worry—let’s walk through some important areas to check together: • Media Tracks: Make sure the agent is publishing audio tracks to the room. Until someone publishes media, the SIP caller might just hear a dial tone. • Agent Dispatch: Double-check that the
agent_name
matches exactly in both the
WorkerOptions
and the dispatch rule configuration. This little detail can make a big difference! • Audio Quality: Turning on background noise cancellation (BVC) and client-side echo cancellation can really help improve the clarity of your calls. • SIP Call Status: It’s helpful to look at the SIP call status codes and signaling messages to spot any errors that might be happening during call setup. • Logs: Checking the logs from your SIP trunk provider and the LiveKit Cloud dashboard can reveal network or configuration issues that might be affecting the call. • Media Encryption and Codecs: Be sure that your SIP trunk and LiveKit are compatible when it comes to media encryption and audio codecs. Please feel free to reach out if you want me to guide you through any of these steps or if you need help troubleshooting further—I’m here to help! Sources: Accepting inbound calls | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | Create and configure a Plivo SIP trunk | LiveKit Docs | SIP overview | LiveKit Docs | livekit-protocol/livekit/protocol/sip.py
l
2025-10-23 072327,479 - ERROR livekit.agents - Error in _stt_task Traceback (most recent call last): File "/home/ubuntu/outbound-project/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/outbound-project/.venv/lib/python3.12/site-packages/livekit/agents/voice/audio_recognition.py", line 474, in _stt_task async for ev in node: File "/home/ubuntu/outbound-project/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py", line 339, in stt_node raise RuntimeError( RuntimeError: The STT (livekit.plugins.openai.stt.STT) does not support streaming, add a VAD to the AgentTask/VoiceAgent to enable streamingOr manually wrap your STT in a stt.StreamAdapte 이 에러 메세지의 원인은 뭐야?
t
It looks like the error happens because the STT model you're using (like OpenAI Whisper) doesn’t support streaming on its own. But don’t worry! You can fix this by adding a Voice Activity Detection (VAD) instance to your agent. The VAD helps by wrapping the non-streaming STT with a
StreamAdapter
, so it can handle audio in smaller segments smoothly. Here’s a simple way to get it working:
Copy code
from livekit.agents import VoiceAgent
from livekit.plugins import silero, openai

# Load VAD
vad = silero.VAD.load()

# Create non-streaming STT
stt = openai.STT()

# Create agent with both STT and VAD
agent = VoiceAgent(stt=stt, vad=vad)
For the best experience, try loading the VAD during the prewarm phase. If you’d like, I’m here to help you set this up or troubleshoot any other issues you might have—just let me know! Sources: plugins/silero/src/vad.ts | examples/voice_agents/timed_agent_transcript.py | Speech-to-text (STT) models | LiveKit Docs
l
eerror: failed to fetch server settings: http status: 404 connected to room inbound-_01030982011_5zRismyjtXKB with participant sip_01030982011 2025-10-23 072602,264 - ERROR livekit - livekit_ffi:serverroom149livekit ffiserver:room - audio filter cannot be enabled: LiveKit Cloud is required {"pid": 934674, "job_id": "AJ_cjyEgEHAb88L"} not authenticated 2025-10-23 072602,526 - DEBUG livekit.agents - input stream attached {"participant": null, "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"], "pid": 934674, "job_id": "AJ_cjyEgEHAb88L"} 2025-10-23 072602,532 - ERROR livekit - livekit_ffi:serveraudio stream123livekit ffiserver:audio_stream - failed to initialize the audio filter. it will not be enabled for this session 이건 왜그런거야?
t
Hi there! The error message "audio filter cannot be enabled: LiveKit Cloud is required" is letting you know that audio filtering features, like noise cancellation, are available only when you're using LiveKit Cloud. If you're self-hosting the LiveKit Server, these features unfortunately won't be supported. As for the "failed to fetch server settings: http status: 404" error, this happens because the client is trying to reach a LiveKit Cloud-specific endpoint (like
/settings/regions
) that isn’t available on self-hosted setups. This usually means the server URL might not be set up correctly, or the client is trying to use features meant just for the Cloud. Here are a few steps that might help you get things running smoothly: • If audio filtering is important for your use case, you might want to consider moving over to LiveKit Cloud, where these features are fully supported. • Double-check that your server URL is correctly configured and points to the right LiveKit Cloud domain if you’re using the Cloud service. • If you’re self-hosting, try disabling any client-side code that tries to enable audio filters or fetch region settings, since those won’t be available. Please feel free to reach out if you’d like me to walk you through any of these steps or if you have any other questions—I’m here to help! Sources: livekit-ffi/src/server/room.rs | src/room/RegionUrlProvider.ts | Noise & echo cancellation | LiveKit Docs | regionurlprovider.go