Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

TAC overview


Twilio Agent Connect (TAC) is an SDK that connects your LLM application to Twilio's communication channels, Conversation Memory, and Conversation Orchestrator. TAC works with any LLM provider or agent framework, including OpenAI, AWS Bedrock, and Microsoft Foundry.

You can use TAC to build applications in Python or TypeScript.

TAC is not an agent runtime. It acts as middleware, enabling your existing LLM application to use Twilio Platform services without managing the underlying infrastructure.


Why use TAC

why-use-tac page anchor

TAC handles the integration complexity between your AI agent and Twilio's platform so you can focus on your agent's intelligence:

  • Unified channel access: Connect your agent to Twilio's communication channels through a single interface. TAC handles WebSocket connections for Voice and webhook processing for messaging.
  • Built-in memory and context: Retrieve customer profiles, conversation history, and trait data from Conversation Memory with each interaction. Your agent can personalize responses without building its own memory layer.
  • Custom tools and knowledge: Define custom tools your agent can call at runtime, and use built-in tools for Enterprise Knowledge search, memory retrieval, and escalation to human agents.
  • Escalation to human agents: Transfer conversations from your AI agent to a human agent in Twilio Flex when the situation requires it, with full context preserved.
  • LLM-agnostic: TAC works with any LLM provider. Use the dedicated AWS Bedrock or Microsoft Foundry integration packages, the built-in OpenAI adapter, or integrate with any other provider through the MemoryPromptBuilder.

What TAC automates

what-tac-automates page anchor

Without TAC, connecting an AI agent to Twilio channels requires building and maintaining:

  • Webhook infrastructure: HTTP server with endpoints for each channel, Twilio signature validation, payload parsing, and channel-based routing logic.
  • Conversations API coordination: Parsing conversation lifecycle events (COMMUNICATION_CREATED, PARTICIPANT_ADDED, CONVERSATION_UPDATED), managing participants, and handling conversation state.
  • Memory API integration: Profile lookup by phone number, memory retrieval with queries, observation storage, conversation summaries, and graceful degradation when the Memory API is unavailable.
  • Voice-specific complexity: WebSocket server for Conversation Relay, TwiML generation, speech-to-text message parsing, and call lifecycle management.
  • Session management: Tracking active conversations per channel, mapping conversation IDs to profile IDs, and cleaning up sessions on conversation end.

TAC automates all of this. You register channels, define a message callback, and start the server:

PythonTypeScript
1
tac = TAC(config=TACConfig.from_env())
2
voice_channel = VoiceChannel(tac, config=VoiceChannelConfig(memory_mode="always"))
3
sms_channel = SMSChannel(tac, config=SMSChannelConfig(memory_mode="always"))
4
5
async def handle_message(message, context, memory):
6
response = await your_llm(message, memory)
7
return response # TAC routes the response to the correct channel automatically
8
9
tac.on_message_ready(handle_message)
10
11
# TACFastAPIServer registers webhook and WebSocket routes for configured channels
12
server = TACFastAPIServer(tac=tac, voice_channel=voice_channel, messaging_channels=[sms_channel])
13
server.start()

You focus on your agent's business logic — TAC handles the infrastructure.


TAC uses a modular architecture with the following components:

  • TAC Core: Central orchestration layer that coordinates with Conversation Memory and Conversations, handles callback registration, and provides helper methods for memory retrieval and profile fetching.
  • Conversation Orchestration: Conversation orchestration and management through Conversation Orchestrator.
  • Conversation Memory: Memory retrieval and trait-based user profiles through Conversation Memory.
  • Channels: Voice and messaging (SMS, WhatsApp, RCS, Chat) channel abstraction layer. Voice uses Conversation Relay WebSocket connections for real-time streaming. Messaging channels process events from Conversations.
  • Tools: Function-based tool system that your agent can call at runtime, including built-in tools for knowledge search, memory management, and escalation.
  • ConversationSession: Session context with profile, memory, channel, and conversation state passed to every callback.

Production deployment considerations

production-deployment-considerations page anchor

TAC tracks active conversations in instance-local memory. This works perfectly for single-instance deployments but has implications for multi-instance deployments behind a load balancer.

The issue: Webhooks may route to a different instance than the one that handled the initial connection or message. This prevents proper conversation cleanup and can cause memory leaks.

Recommended solutions:

For production deployments with multiple instances, implement one of these solutions before going live.

  • API credentials: Store TWILIO_API_KEY and TWILIO_API_SECRET in a secrets manager (AWS Secrets Manager, Azure Key Vault, HashiCorp Vault) rather than environment variables.
  • Webhook signature validation: Enable Twilio webhook signature validation in production to prevent unauthorized requests.
  • TLS/SSL: All webhook endpoints must use HTTPS in production.

Monitoring and observability

monitoring-and-observability page anchor

TAC provides built-in logging. Enable debug logging during development:

TWILIO_LOG_LEVEL=DEBUG

For production monitoring, track:

  • Conversation latency (time between user message and agent response)
  • Memory retrieval time
  • Channel-specific error rates
  • WebSocket connection failures (Voice)

Supported programming languages

supported-programming-languages page anchor


  • Quickstart: Build and test a TAC application from scratch.
  • Add TAC to your agent: Connect your existing agent and configure channels, tools, knowledge, and memory.
  • Core concepts: Understand TAC's architecture and component relationships.