Ready to build better conversations?
Simple to set up. Easy to use. Powerful integrations.
Get free accessReady to build better conversations?
Simple to set up. Easy to use. Powerful integrations.
Get free accessAs real-time applications become essential for user engagement, the need for scalable and secure event broadcasting is more critical than ever. AWS AppSync Events offers a serverless solution that handles real-time events, ideal for applications such as conversational assistants and notification systems. Here, we explore how AppSync Events powers our scalable real-time platform, and how you can leverage it for your own needs.
What Are AWS AppSync Events?
AWS AppSync Events provides event-driven APIs capable of managing millions of concurrent WebSocket connections. These APIs handle event publishing, subscription management, and secure real-time communication, enabling a smooth experience for large-scale applications.
Core Components:
Event: A data message sent from publishers to subscribers.
Channel: A pathway that events travel through.
Channel Namespace: A logical grouping for related event channels.
Event Handlers: Custom logic that runs during subscription or publication.
To get started, visit AWS AppSync Event API documentation.
Choosing AWS AppSync Events: Key Benefits
We evaluated several solutions and selected AWS AppSync Events for its robust feature set. Here’s how it aligns with our real-time application needs:
1. Scalability
AppSync can handle millions of connections concurrently. This scalability is critical for large user-based applications, ensuring that event delivery remains fast even during peak usage.
2. Serverless Architecture
Being serverless, AppSync handles infrastructure scaling, connection management, and fault tolerance. This reduces the operational burden, allowing us to focus on delivering new features without worrying about backend complexities.
3. Low Latency
AWS guarantees low-latency event broadcasting, which is vital for applications like live chat, notifications, or collaborative platforms where timely updates enhance user engagement.
4. Flexible Authentication and Authorization
AWS AppSync supports various authentication methods:
API Key Authentication: A straightforward key-based approach where AppSync generates keys to control access.
Lambda-Based Authorization: Allows custom security logic by validating requests through an AWS Lambda function.
IAM Authorization: Leverages AWS Signature Version 4 signing, enabling precise access control through IAM policies.
OpenID Connect (OIDC) Authorization: Supports authentication via external OIDC-compliant identity providers.
Amazon Cognito User Pools: Provides user authentication and role-based access control through Cognito’s built-in identity management features.
Cost Management
AWS AppSync is priced based on usage, offering:
$1.00 per million operations (e.g., event publications, subscriptions, and message transmissions).
$0.08 per million connection minutes.
This pricing model supports both scalability and cost-efficiency for high-volume applications.
Putting It All Together: A Practical Example
Now that we’ve explored the fundamentals of AWS AppSync Events, let’s dive into a practical implementation.
In this section, we’ll go step by step to build a real-time agent presence system. This system will instantly update and broadcast agent availability to subscribed users, ensuring everyone stays informed in real-time.
We will define an AppSync Event API using AWS CloudFormation, ensuring a scalable, secure, and well-structured event-driven architecture.
🔹 What we will implement:
✅ An AppSync Event API to handle real-time updates.
✅ A Channel Namespace to organize agent presence events.
✅ Secure authentication with IAM for publishing and Cognito for subscriptions.
✅ A backend function to publish presence updates securely using AWS IAM authentication.
✅ A React-based UI to receive real-time presence updates via WebSockets.
1. Setting Up an AppSync Event API with CloudFormation
To create our AppSync Event API, we define it in CloudFormation. This provides an automated and repeatable way to deploy the API with consistent configurations.
What this does:
✅ Creates an AppSync Event API named real-time-agent-presence.
✅ Uses IAM authentication for publishing events (only trusted services can update agent status).
✅ Uses Cognito authentication for subscribing (only authorized users can listen to agent status changes).
This provides a secure and scalable foundation for real-time agent updates.

2. Organizing Agent Presence Updates with a Channel Namespace
To ensure a structured approach, we use Channel Namespaces. This allows us to group real-time agent presence updates under a dedicated namespace.
CloudFormation Definition for the Channel Namespace
Why use a Channel Namespace?
✅ Groups all agent presence updates under agent-presence.
✅ Restricts publishing to authorized backend services using IAM.
✅ Ensures only authenticated users can subscribe to presence updates via Cognito.

3. Implementing Secure Authentication for Agent Presence Updates
Security is crucial to ensure that:
✔ Only internal services (e.g., agent management system) can publish presence updates.
✔ Only authenticated users (agents, supervisors) can subscribe to presence events.
Instead of exposing our internal authorization logic, we use a simplified security check inside the event CodeHandlers.
Here’s a sample event handler that enforces authorization during subscription:
This code snippet can be included in our ChannelNamespace CodeHandlers property:
How this improves security:
✅ Checks Cognito user groups instead of exposing internal authorization rules.
✅ Allows only users in the support_agents group to subscribe.
✅ Ensures only authorized services can publish events.
✅ Enhances logging for better monitoring of subscription attempts.
4. Publishing Agent Presence Updates
Now that we have set up our AppSync Event API, Channel Namespace, and WebSocket Subscription, it’s time to publish real-time agent presence updates from the backend.
This step ensures that whenever an agent changes their availability status (e.g., available, busy, offline), it is instantly broadcast to all subscribed users.
We will implement a TypeScript-based backend function using AWS Signature v4 authentication and Axios to securely send presence updates to AppSync Events.
Backend Function for Publishing Events
How This Works
✅ Authenticates requests securely using AWS Signature v4 (IAM-based authentication).
✅ Publishes presence updates (available, busy, offline) for a given agent.
✅ Sends a signed HTTP request to AWS AppSync Events using axios.
✅ Logs success/failure messages to track real-time updates.
5. Connecting the Frontend UI to Receive Agent Presence Updates
The frontend application needs to connect to AppSync Events via WebSockets to receive real-time agent status changes.
React Component for Subscribing to Agent Presence Events
How this works:
✅ Opens a WebSocket connection to AppSync.
✅ Sends an initial connection request (type: "connection_init").
✅ Listens for real-time agent presence updates.
This ensures that supervisors and agents can see live status changes without needing to refresh the page.
A Scalable and Secure Real-Time Agent Presence System
With AWS AppSync Events, we’ve built a scalable, secure, and event-driven real-time agent presence system.
✔ AppSync Event API: Deployed with CloudFormation for consistency.
✔ Channel Namespace: Organizes agent presence updates efficiently.
✔ Security Model: IAM for publishing, Cognito for subscription control.
✔ UI Integration: WebSockets enable real-time presence streaming.
This approach ensures low latency, high reliability, and strong security, making it ideal for customer support and call center environments.
Want to learn more about what goes on in the engine room of Aircall? Take a look at more of our Tech Team Stories.
Published on February 18, 2025.