AI Voice Agents에서 SIP Telephony를 사용하여 통화 전환하는 방법

발행: (2025년 12월 29일 오후 07:47 GMT+9)
5 min read
원문: Dev.to

Source: Dev.to

개요

발신자가 기업에 전화를 걸면 빠르고 명확한 해결을 기대합니다. AI 음성 에이전트는 언제 지원하고 언제 인간에게 전화를 넘겨야 하는지 알아야 합니다. VideoSDK의 콜 전송 기능을 사용하면 AI 에이전트가 발신자를 끊지 않고 활성 SIP 전화를 다른 전화번호로 이동시켜 원활한 대화 흐름을 보장합니다.

Source:

How Call Transfer Works

  • AI 에이전트는 발신자의 의도를 평가하여 전환이 필요한지 판단합니다.
  • 전환이 필요할 경우, 에이전트는 함수 도구를 트리거합니다.
  • 함수 도구는 시스템에 현재 진행 중인 SIP 전화를 지정된 번호로 즉시 전달하도록 지시하며, 발신자가 다시 전화를 걸 필요가 없습니다.
  • 발신자 입장에서는 전환이 자동으로 이루어지며, 통화가 끊기거나 어색한 멈춤 없이 계속됩니다.

콜 전송 에이전트 설정

아래는 transfer_call 도구를 사용해 전화를 전송할 수 있는 에이전트의 최소 예시입니다.

import os
import logging

from videosdk.agents import (
    Agent, AgentSession, CascadingPipeline, function_tool,
    WorkerJob, ConversationFlow, JobContext, RoomOptions, Options
)
from videosdk.plugins.deepgram import DeepgramSTT
from videosdk.plugins.google import GoogleLLM
from videosdk.plugins.cartesia import CartesiaTTS
from videosdk.plugins.silero import SileroVAD
from videosdk.plugins.turn_detector import TurnDetector, pre_download_model

# Set up basic logging
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    handlers=[logging.StreamHandler()]
)

# Pre‑download the turn‑detector model
pre_download_model()


class CallTransferAgent(Agent):
    def __init__(self):
        super().__init__(
            instructions=(
                "You are the Call Transfer Agent. "
                "Help transfer ongoing calls to a new number using the transfer_call tool."
            )
        )

    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, and thank you for calling!")

    @function_tool
    async def transfer_call(self) -> None:
        """Transfer the call to the provided number."""
        token = os.getenv("VIDEOSDK_AUTH_TOKEN")
        transfer_to = os.getenv("CALL_TRANSFER_TO")
        return await self.session.call_transfer(token, transfer_to)


async def entrypoint(ctx: JobContext):
    agent = CallTransferAgent()
    conversation_flow = ConversationFlow(agent)

    pipeline = CascadingPipeline(
        stt=DeepgramSTT(),
        llm=GoogleLLM(),
        tts=CartesiaTTS(),
        vad=SileroVAD(),
        turn_detector=TurnDetector()
    )

    session = AgentSession(
        agent=agent,
        pipeline=pipeline,
        conversation_flow=conversation_flow
    )

    await session.start(wait_for_participant=True, run_until_shutdown=True)


def make_context() -> JobContext:
    room_options = RoomOptions(name="Call Transfer Agent", 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",
            register=True,
            host="localhost",
            port=8081
        )
    )
    job.start()

코드의 주요 포인트

  • transfer_call 함수 도구: 환경 변수에서 VideoSDK 인증 토큰과 대상 전화번호를 가져와 self.session.call_transfer를 호출합니다.
  • 파이프라인 구성 요소: Deepgram은 음성‑텍스트 변환, Google LLM은 언어 이해, Cartesia는 텍스트‑음성 변환, Silero VAD는 음성 활동 감지, TurnDetector는 화자 턴 관리를 담당합니다.
  • 작업 구성: 원하는 agent_id, 호스트 및 포트를 지정해 WorkerJob을 설정합니다.

에이전트 실행

  1. 환경 변수 VIDEOSDK_AUTH_TOKENCALL_TRANSFER_TO를 정의합니다.
  2. 스크립트를 실행합니다 (python your_script.py).
  3. 에이전트는 인바운드 참가자를 기다리며 대화를 처리하고, transfer_call 도구가 호출될 때 전화를 전환합니다.

콜 전송의 이점

  • 원활한 전환: 발신자는 끊김 없이 전화를 유지하고 다시 걸 필요가 없습니다.
  • 향상된 사용자 경험: 대화가 자연스럽게 진행되어 좌절감을 줄입니다.
  • 확장 가능한 지원: AI 에이전트가 일상적인 문의를 처리하고 복잡한 문제는 자동으로 인간 상담원에게 전달합니다.

Additional Resources

  • Quick Start Example – 인바운드/아웃바운드 콜 처리 및 라우팅 규칙에 대한 자세한 가이드.
  • Call‑Transfer Implementation on GitHub – 샘플 프로젝트가 포함된 전체 리포지토리.
  • VideoSDK Documentation – 모든 SDK 기능에 대한 포괄적인 참고 자료.
Back to Blog

관련 글

더 보기 »