AWS for Industries

Serverless Real-time Voice AI on AWS: A Pattern for Enterprise Sales Coaching

Enterprise sales organizations face a persistent challenge: delivering consistent, high-quality coaching to every field representative regardless of geography or manager availability. An AI-powered voice coach that reps can access on demand through natural conversation offers a compelling alternative—but building real-time voice AI introduces infrastructure complexity related to bidirectional audio streaming, WebSocket management, and scaling.

In this post, we introduce a fully serverless pattern that solves this problem using AWS AppSync Events, Amazon Nova Sonic, and Amazon Bedrock AgentCore. We show how this pattern is implemented in a production deployment of an AI sales coach for a large enterprise beverage CPG company, where field representatives use voice conversations to prepare for account visits with personalized product recommendations, cross-sell strategies, and objection handling. The result is enterprise-grade sales coaching at approximately $0.007 per five-minute session, with zero idle infrastructure costs.

This post focuses on the serverless audio streaming pattern itself, which is reusable in any application that needs real-time bidirectional communication between a web client and a backend container. For full-stack voice agent deployment tutorials, see Deploy a full stack voice AI agent with Amazon Nova Sonic and Building a multi-agent voice assistant with Amazon Nova Sonic and Amazon Bedrock AgentCore.

Solution overview

This solution enables field sales representatives to have natural voice conversations with an AI coach that understands their accounts, products, and selling scenarios. Under the hood, the architecture uses AWS AppSync Events as a serverless real-time audio transport layer between the rep’s browser and an Amazon Nova Sonic voice agent running on Amazon Bedrock AgentCore. The following sections walk through the architecture pattern, a cost comparison, the integration with AgentCore, and what we learned operating this solution in production. We also share a checklist for teams building similar solutions.

A diagram of a software company Description automatically generated

Figure 1: Serverless bidirectional audio streaming architecture with AppSync Events

The AppSync Events audio transport pattern

AWS AppSync Events is a serverless WebSocket API that enables real-time pub/sub messaging. Clients can publish events over HTTP or WebSocket and subscribe to channels using WebSocket connections. AppSync Events handles connection management, message routing, fan-out, and auto scaling without any server infrastructure to provision or manage.

For voice AI applications, this translates to a clean separation of concerns: the web client captures and publishes audio, the server container subscribes and processes it, and AppSync Events handles everything in between. The pattern uses two dedicated channels per session:

Upstream channel (client to container): The web client captures microphone audio, encodes it as base64 PCM chunks, and publishes each chunk to an upstream AppSync Events channel (for example, /session/{id}/audio-in) via HTTP POST. The AgentCore container subscribes to this channel over WebSocket and receives the audio stream in real time, forwarding each chunk to the Nova Sonic bidirectional streaming API.

Downstream channel (container to client): When Nova Sonic generates a speech response, the container publishes the synthesized audio to a downstream channel (for example, /session/{id}/audio-out) via HTTP POST. The web client subscribes to this channel over WebSocket and plays the audio through the browser’s speakers.

This pub/sub decoupling provides several architectural advantages: no WebSocket server to manage (AppSync handles all portions of the connection lifecycle), producer-consumer resilience to transient network issues, protocol flexibility (using HTTP POST for publishing and WebSocket for subscribing simplifies server-side integration), and built-in authentication via AWS Identity and Access Management (IAM), Amazon Cognito, API keys, or AWS Lambda authorizers.

Cost comparison

Approach Infrastructure to manage Cost model Idle cost
AppSync Events None (fully serverless) $1.00/M event ops $0.00
Fargate + ALB Application Load Balancer (ALB), Fargate, VPC, NAT Gateway Hourly compute + Load Balancer Capacity Unit (LCU) fees ~$50+/mo
API GW WebSocket Lambda, DynamoDB conn table Per message + conn mins $0.00
LiveKit/Pipecat Framework server, TURN/STUN Compute + overhead Varies

The most significant operational advantage of AppSync Events for audio transport is its pay-per-event pricing model with zero idle cost.

For a representative five-minute voice coaching session producing approximately 7,000 total event operations (upstream audio chunks, downstream audio responses, and WebSocket management operations), the AppSync Events cost is approximately $0.007. Having zero idle cost is particularly relevant in sales coaching, where usage is intermittent. A team of 50 reps averaging three sessions per day generates approximately $31.50/month in AppSync Events costs, compared to $50+/month in base infrastructure costs for an always-on AWS Fargate and ALB deployment before any sessions occur.

Note: AppSync Events charges $1.00 per million Event API operations. Messages are metered per 5 KB payload. A typical base64-encoded audio chunk from 16 kHz PCM at 20 ms intervals is approximately 850 bytes, well within the 5 KB threshold. See AWS AppSync pricing for current rates.

Integrating with Amazon Bedrock AgentCore

Amazon Bedrock AgentCore hosts the voice agent in a dedicated container with session isolation using microVMs. The container runs a Node.js application connecting AppSync Events channels to the Nova Sonic bidirectional streaming API. The container serves three functions:

  1. Health reporting: Responds to AgentCore’s GET/ping polls with Healthy or HealthyBusy status.
  2. Audio ingestion: Subscribes to the upstream channel via WebSocket, receives base64 audio chunks, and forwards them to the Nova Sonic InvokeModelWithBidirectionalStream API.
  3. Audio delivery: Receives synthesized speech from Nova Sonic and publishes it to the downstream channel via HTTP POST.

The following code shows the health check implementation:

// backend/agentcore-container/index.js

app.get('/ping', (req, res) => {
  const hasActiveSessions = activeSessions.size > 0;
  res.status(200).json({
    status: hasActiveSessions ? 'HealthyBusy' : 'Healthy',
    time_of_last_update: Math.floor(Date.now() / 1000),
    activeSessions: activeSessions.size,
  });
});

This endpoint reports HealthyBusy when at least one voice session is active, telling AgentCore to keep the container running.

Critical configuration: The API-specific DNS endpoint (https://<api-id>.appsync-api.<region>.amazonaws.com) must be used for WebSocket subscriptions. The generic regional URL (https://events.appsync-api.<region>.amazonaws.com) works for HTTP POST publishing because the API ID is included in the request path, but it fails silently for WebSocket subscriptions because the handshake protocol needs the API-specific endpoint to route the connection. This creates an asymmetric failure: the client can receive downstream audio, but the container never receives upstream audio. Use aws appsync get-api --api-id YOUR_API_ID to retrieve the correct endpoint.

Production operational guidance

During production deployment, we encountered a compound failure pattern: every voice session terminated at ~112 seconds. Two independent bugs needed fixing simultaneously:

Issue What happened Resolution
Missing /ping AgentCore sent SIGKILL after ~120s Added GET /ping returning Healthy/HealthyBusy
Wrong AppSync endpoint WebSocket handshake failed; no upstream audio Switched to API-specific DNS endpoint

Neither fix alone resolved the problem. The /ping issue was difficult to diagnose because SIGKILL bypasses all signal handlers, producing no error logs. The key diagnostic evidence came from Amazon CloudWatch session logs showing zero audio chunks received despite active client publishing.

During the investigation, five plausible hypotheses were tested and eliminated: Node.js HTTP/2 120-second timeout (setting timeouts to 0 did not help since the kill was external), missing protocolConfiguration (no effect; protocol was already inferred correctly), Bedrock stream timeout (keep-alive was working and Bedrock was healthy when container died), Lambda timeout (Lambda returned in ~8 seconds), and AppSync connection timeout (WebSocket was never established, making this a symptom rather than a cause).

The compound failure principle this illustrates is important for containerized deployments: health check failures can mask application-level bugs by killing the container before error handling has time to execute.

Deployment checklist

  1. Implement GET /ping. AgentCore terminates containers with SIGKILL after ~120s if /ping returns non-200.
  2. Use API-specific AppSync DNS for WebSocket subscriptions. Generic regional URL fails silently.
  3. Pass model IDs through environment variables to simplify version updates without container rebuilds.
  4. Disable HTTP/2 timeouts for long-running streams (requestTimeout: 0, sessionTimeout: 0).
  5. Force container updates after ECR push by bumping a BUILD_VERSION environment variable.
  6. Implement session-level telemetry. Log audio chunk counts per session for diagnostics.

Conclusion

In this post, we showed how to build a serverless AI voice coaching solution that scales across an entire sales organization at a fraction of the cost of traditional infrastructure. Using AWS AppSync Events as the real-time audio transport layer eliminates WebSocket server management, provides automatic connection lifecycle handling, and delivers pay-per-event pricing with zero idle cost, making it economically viable to offer every rep unlimited coaching sessions.

We also shared operational lessons from a production deployment, including a compound failure pattern common in containerized voice AI workloads. The deployment checklist captures these lessons as practical guidance for any team bringing real-time voice AI applications to production. While we demonstrated this pattern for sales coaching, the serverless audio transport architecture applies to any enterprise voice AI use case—customer service agents, clinical documentation, real-time transcription, field service assistants, and training simulations. Any application that needs low-latency bidirectional streaming between a web client and a backend container can use AppSync Events channels in the same way, without dedicated infrastructure.

To learn more:

Sriharsh Adari

Sriharsh Adari

Sriharsh Adari is a Principal Solutions Architect at Amazon Web Services (AWS), where he helps customers work backwards from business outcomes to develop innovative solutions on AWS. His core areas of expertise include Technology Strategy, Data Analytics, and Data Science. In his spare time, he enjoys playing sports, binge-watching TV shows, and playing Tabla.

Humberto Lobo

Humberto Lobo

Humberto Lobo is a Technical Account Manager at Amazon Web Services (AWS), where he helps enterprise customers architect and optimize their AWS workloads with a focus on AI/ML, serverless, and real-time applications. He specializes in voice AI and agentic architectures, working closely with customers to bring production-grade generative AI solutions to market.