
How to Build a Multichannel AI Agent with Twilio Agent Connect and AWS Bedrock AgentCore
Build a multichannel AI agent that carries context across voice and SMS, using OwlAir as a practical Twilio Agent Connect and Amazon Bedrock AgentCore demo.
Imagine starting a conversation with an AI agent over the phone, continuing it through a text message, and never having to repeat the context.
That is the multichannel experience I wanted to explore in this project. To make the pattern concrete, we'll build OwlAir: a demo airline customer service agent that works across voice and SMS, remembers the customer, and can take real actions on a reservation. The agent runs on AWS Bedrock AgentCore, uses Strands Agents, and connects to Twilio through Twilio Agent Connect.
By the end of this post, you'll understand how to build and deploy a multichannel AI agent using OwlAir as our example. You can reuse the same architecture for support, scheduling, commerce, and plenty of other use cases. Let's dive in and make it happen!
What we'll build: the OwlAir demo
OwlAir is a serverless airline support agent that can:
- Look up a reservation using the customer's phone number
- Change a seat assignment
- Add checked bags
- Talk naturally over a phone call using Twilio ConversationRelay
- Reply over SMS using the same agent and tools
- Carry customer context and reservation state across channels
- Deploy the agent, webhook proxy, and database with one command
Prerequisites
To follow along, you'll need:
- A Twilio account and a voice- and SMS-capable Twilio phone number
- Access to Twilio Agent Connect and a Conversation Configuration
- An AWS account with access to Amazon Bedrock, Bedrock AgentCore, AWS Lambda, Amazon DynamoDB, AWS CloudFormation, and IAM
- The AWS CLI
- Docker running locally so AWS CDK can package the Lambda function
I used
us-east-1 for this demo. If you choose another region, confirm that the Bedrock model and AgentCore features used by the project are available there.Understanding the architecture
Here is the high-level flow:
Think of the Lambda function as an air traffic controller. It doesn't answer the customer's question itself. It validates the incoming Twilio request, identifies whether the request belongs to voice or messaging, and routes it to the correct AgentCore session.
There are also three kinds of state in this project, and the distinction matters:
- Customer memory comes from Twilio and gives the agent useful context about the person across interactions.
- Conversation history is managed by the Strands
FileSessionManageron AgentCore's session storage.
- Reservation state lives in DynamoDB and is keyed by phone number, so a seat changed on a call is still changed when the customer follows up over SMS.
That final layer is important. An AI agent's memory can help it recall that a customer prefers a window seat, but a database should remain the source of truth for whether the customer is actually assigned seat 23A.
How the voice and SMS paths work
Voice and SMS enter through different paths, but both end at the same agent.
Voice path
When a customer calls the Twilio number, Twilio sends a signed request to the Lambda function's
/twiml endpoint. Lambda validates the signature, extracts the CallSid , and asks AgentCore for a presigned WebSocket URL.Lambda then returns Twilio Markup Language (TwiML) that connects the call to Twilio ConversationRelay . ConversationRelay handles the speech interface while the text exchange travels over the WebSocket to the agent running in AgentCore.
The
CallSid becomes the AgentCore session ID. That gives each call an isolated runtime session instead of mixing two callers together.SMS path
For SMS, Twilio Conversation Orchestrator sends events to Lambda's
/webhook endpoint. Lambda validates the request, accepts the event types that the SDK handles, and forwards the payload to AgentCore.The Twilio conversation ID becomes the AgentCore runtime session ID. This gives events from the same conversation sticky routing to the same AgentCore session.
Twilio Agent Connect takes it from there: it processes the webhook, retrieves the configured memory context, invokes the agent, and sends the response back through the customer's channel.

Build the OwlAir agent
The agent itself is intentionally compact. Most of the channel plumbing lives in Twilio Agent Connect, which leaves the application code focused on the model, instructions, and tools.
Open agent/main.py and you'll find the agent factory:
def create_agent(context: ConversationSession) -> Agent: return Agent( model=BedrockModel(model_id="amazon.nova-pro-v1:0"), system_prompt=SYSTEM_PROMPT, tools=[lookup_reservation, change_seat, add_bag], session_manager=FileSessionManager( session_id=context.conversation_id, storage_dir="/mnt/workspace/.sessions", ), )Let's break down what this does:
-
BedrockModelconnects the Strands agent to Amazon Nova Pro through Amazon Bedrock.
-
SYSTEM_PROMPTtells OwlAir to respond naturally, keep voice responses short, and use tools rather than guessing reservation details.
-
toolsgives the model a narrow set of actions it can take.
-
FileSessionManagerpersists the conversation history in AgentCore's session storage using the Twilio conversation ID.
The prompt also tells the agent to avoid narrating every action with phrases such as “Let me check that.” That sounds like a small detail, but it makes a voice agent feel much faster. Silence while a tool runs is often better than repeatedly announcing what the customer already asked it to do.
Next, the
StrandsConnector connects the agent to both channels:connector = StrandsConnector( tac=tac, agent_factory=create_agent, voice_config=VoiceChannelConfig(memory_mode="once"), sms_config=SMSChannelConfig(memory_mode="always"),)For voice, the project retrieves memory once at the start of the call. For SMS, it retrieves memory on every turn, which is useful because messages can arrive minutes or days apart.
Give the agent tools that change real state
The OwlAir tools are regular Python functions decorated with the Strands
@tool decorator. Here is the seat-changing tool from agent/airline_tools.py:@tooldef change_seat(phone_number: str, new_seat: str) -> dict: res = _get_reservation(phone_number) seat_upper = new_seat.upper()
if seat_upper in AVAILABLE_SEATS: old_seat = res["seat"] res["seat"] = seat_upper res["seat_class"] = AVAILABLE_SEATS[seat_upper] _save_reservation(res)
return { "success": True, "old_seat": old_seat, "new_seat": seat_upper, "reservation": _reservation_summary(res), }
return { "success": False, "message": f"Seat {seat_upper} is not available.", }The tool description and typed arguments help the model decide when and how to call it. The function still owns the actual business rule: only a seat in
AVAILABLE_SEATS can be selected.Reservations are stored in DynamoDB with the customer's phone number as the partition key:
resp = _table.get_item(Key={"phone_number": phone_number})item = resp.get("Item")
if item: return item
item = {**DEFAULT_RESERVATION, "phone_number": phone_number}_table.put_item(Item=item)return itemFor the demo, the first interaction seeds a sample reservation from San Francisco to Seattle. After that, voice and SMS read and write the same DynamoDB item.

The DynamoDB scan projects only the reservation fields needed for the demo; customer identifiers are intentionally omitted.
The best part?_ We don't need separate business logic for every channel. The phone call and text message both reach the same
change_seat , add_bag , and lookup_reservation tools.Route Twilio webhooks through Lambda
AgentCore hosts the agent, but Twilio still needs public webhook endpoints. The project uses an AWS Lambda Function URL as a lightweight proxy.
Every request is validated before it is routed:
def lambda_handler(event, context): if not signature_validator.validate(event): return { "statusCode": 403, "headers": {"Content-Type": "application/json"}, "body": json.dumps({"error": "Invalid webhook signature"}), }
request_path = event.get("rawPath", event.get("path", "/"))
if request_path.startswith("/twiml"): return handle_voice_twiml(event) if request_path.startswith("/webhook"): return handle_conversation_webhook(event)
return {"statusCode": 404, "body": json.dumps({"error": "Not found"})}The voice handler creates a short-lived WebSocket URL and returns TwiML. The messaging handler forwards relevant events to AgentCore. Keeping this proxy small makes it easier to reason about, test, and secure.
Security note: The Lambda Function URL is public, so Twilio signature validation is essential. The current demo validates the HTTP webhooks. The AgentCore WebSocket path still contains a TODO for validating the initial ConversationRelay handshake because the required header isn't currently available to the handler in this implementation. Review that limitation before using this pattern beyond a demo.
Deploy the project
Start by cloning the repository:
git clone https://github.com/rishabkumar7/twilio-agent-connect-aws-owlair.gitcd twilio-agent-connect-aws-owlairThe repository includes iam-policy.json, which contains the deployment permissions used by this project. Create an IAM policy from that file, attach it to the user or role you'll deploy with, and configure an AWS CLI profile:
aws configure --profile your-profile-nameConfirm that the profile works:
aws sts get-caller-identity --profile your-profile-nameNow copy the environment template:
cp .env.example .envAdd your AWS and Twilio values to .env:
AWS_PROFILE=your-profile-nameAWS_ACCOUNT_ID=123456789012AWS_REGION=us-east-1
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTWILIO_AUTH_TOKEN=your_auth_tokenTWILIO_API_KEY=SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTWILIO_API_SECRET=your_api_secretTWILIO_PHONE_NUMBER=+1234567890TWILIO_CONVERSATION_CONFIGURATION_ID=WRxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxKeep this file out of source control. The repository's .gitignore already excludes it.
Bootstrap AWS Cloud Development Kit (CDK) in the account and region once:
make bootstrapThen build and deploy both CloudFormation stacks:
make deployThis command packages the Python application, builds the TypeScript CDK project, deploys the AgentCore runtime and DynamoDB table, and then deploys the Lambda proxy.

CloudFormation separates the AgentCore resources from the Lambda webhook proxy, and both stacks are healthy.

The
tac_tac_agent runtime is active in AgentCore, with observability available from the same console view.When deployment finishes, copy the two URLs from the stack output:
TacLambdaStack.VoiceWebhookUrl = https://xxxxx.lambda-url.us-east-1.on.aws/twimlTacLambdaStack.ConversationWebhookUrl = https://xxxxx.lambda-url.us-east-1.on.aws/webhook

The deployed stack exposes separate URLs for voice and messaging. The endpoint values are redacted in this screenshot.
Voila! The AWS side of OwlAir is live.
Connect the Twilio phone number
In the Twilio Console, open Phone Numbers → Manage → Active Numbers, and select your number.
Under Voice Configuration, set A Call Comes In to Webhook, paste the
VoiceWebhookUrl , select HTTP POST, and click Save.
The OwlAir phone number sends incoming calls to the Lambda voice webhook with an HTTP
POST . The endpoint value is redacted in this screenshot.Next, open your Conversation Configuration in Conversation Orchestrator. Set its webhook URL to the
ConversationWebhookUrl , use HTTP POST, and save the configuration.The exact Console navigation can evolve, but the two connections remain the same: incoming calls request TwiML from
/twiml , and conversation events are delivered to /webhook .Test the cross-channel experience
Call your Twilio number and ask:
What flight am I on?OwlAir should find the sample reservation and tell you about flight 543 from SFO to SEA.
Now say:
Change my seat to 23A.The agent calls the seat tool, updates DynamoDB, and confirms the new reservation details.
Hang up, then send an SMS to the same Twilio number:
What seat do I have now?TING TING! OwlAir should reply with seat 23A. The channel changed, but the reservation did not reset.
You can inspect the AgentCore and Lambda log groups in Amazon CloudWatch if a request doesn't behave as expected. Search for log groups beginning with
/aws/bedrock-agentcore/runtimes/tac_tac_agent- and /aws/lambda/TacLambdaStack- .Take it further
This demo uses a small, fixed reservation model so the multichannel architecture stays clear. From here, you could:
- Replace the demo reservation table with an airline or travel API
- Add identity verification before allowing changes
- Add human handoff for refunds or complex itinerary changes
- Support WhatsApp or another messaging channel
- Store credentials in AWS Secrets Manager instead of deployment environment variables
- Add conditional DynamoDB writes so concurrent seat changes can't claim the same seat
- Add tracing, alarms, retries, and dead-letter handling
- Write automated tests for webhook validation and tool behavior
Production note: The CDK stack uses aDESTROYremoval policy for the demo table, and the available-seat list is held in process memory. Those choices make a demo convenient, but they aren't appropriate for a production reservation system. Use durable inventory, concurrency controls, backups, stricter retention policies, and a complete security review.
Conclusion
Congratulations! You've built a voice and SMS airline agent that runs on AWS, uses one set of tools across both channels, and keeps business state in a proper database. Twilio Agent Connect handles the channel and memory integration, ConversationRelay powers the voice experience, Strands gives the model tools, and Bedrock AgentCore provides the managed runtime. This is just the beginning—swap in your own tools and data, and the same pattern can power support, scheduling, commerce, or internal help desk experiences. I can't wait to see what you build!
Rishab Kumar is a Developer Evangelist at Twilio and a cloud enthusiast. Follow his cloud, DevOps, and DevRel adventures at blog.rishabkumar.com .
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article