π Complete Integration Guide
π¦ Installation
Peer Dependencies
Ensure the following Angular packages are present in your project (they are usually already installed):| Package | Version |
|---|---|
@angular/core | >=15.0.0 |
@angular/common | >=15.0.0 |
@angular/animations | >=15.0.0 |
@angular/router | >=15.0.0 |
livekit-client | ^2.0.0 |
lottie-web | ^5.10.0 |
β οΈ Important: CSS Import (REQUIRED)
The CSS file MUST be imported for the widget to display correctly. Without it, the widget will appear unstyled.Option 1: angular.json / project.json (Recommended)
Add the path to thestyles array in your angular.json (or project.json for Nx workspaces):
Option 2: Global styles.css Import
Option 3: Component-Level Import
β‘ Setup
Three one-time steps are required before placing any widget component.Step 1 β Provide Animations
Angular animations must be enabled at the application level. Without this the widget transitions will not work. Standalone bootstrap (app.config.ts):
app.module.ts):
Step 2 β Initialize the SDK
CallEmbedInitService.initialize() once, as early as possible β in your root AppComponent. It validates your API key, fetches widget configuration from Revragβs backend, and caches the result for the session.
π― Basic Usage
Fixed Positioning (Default)
Embedded Positioning
π¨ Responsive Behavior
Fixed Positioning
- Desktop (> 500px): Widget stays at specified position
- Mobile (β€ 500px): Widget expands to full width with 1rem padding from edges
Embedded Positioning
- Wide parent (> 400px): Widget aligns to left/right based on
sideinput - Narrow parent (β€ 400px): Widget auto-centers with equal padding
π§ API Reference
EmbedButtonComponent Inputs
Selector:revrag-embed-button
EmbedProviderComponent Inputs
Selector:revrag-embed-provider
Use this component to declaratively control widget visibility based on the current route.
EmbedInitService
π‘ Event Management
The SDK provides a powerful event system for tracking user data, custom events, and listening to agent state changes. Use theembedEvent singleton (re-exported from @revrag-ai/embed-angular) β it has the same API as embed in the React SDK.
EventKeys
Available event types:USER_DATA, CUSTOM_EVENT and ANALYTICS_DATA are available for manual use. Agent connection events are automatically tracked by the SDK and can be listened to via callbacks.
Sending Events with embedEvent API
TheembedEvent object provides methods for sending events to track user data and custom application events.
Send User Data
Send Custom Events
Send Analytics Events
Event Method Signature
Listening to Agent Events
Monitor voice agent connection status in real-time. These events are automatically sent to your backend AND emitted locally for you to listen to.Available Event Types for Listening
- Agent events are automatically sent to your backend with
app_user_id - Events are also emitted locally for real-time UI updates
- Backend receives all event data including timestamps and metadata
- No manual API calls needed β itβs all handled automatically
Event Listener Methods
Basic Event Listening Example
Complete Agent Monitoring Example
Use Cases for Agent Events
AGENT_CONNECTED:- Show visual indicators (green dot, badge)
- Enable voice-related features in UI
- Start analytics timers
- Update user presence status
- Show notifications to user
- Pause background music/media
- Update UI to show agent unavailable
- Log analytics (call duration, success)
- Show feedback forms
- Resume background media
- Clean up resources
- Save conversation state
Handling Connection Errors
π± Mobile Optimization
The widget automatically adjusts for mobile devices:Extra Small Screens (β€ 375px)
- iPhone SE, small Android devices
- Reduced padding and font sizes
- Optimized button and text layouts
Small Screens (376px - 500px)
- Standard smartphones
- Balanced sizing for readability
π― Common Use Cases
1. Customer Support Widget with User Tracking
2. E-commerce with Purchase Tracking
3. Help Section Widget with Agent Status
4. With Bottom Navigation
5. Multi-Department Support
6. Contextual Events Based on User Actions
π Complete Integration Example
Hereβs a complete example showing initialization, user tracking, event listening, and the widget all working together:Key Points in This Example:
- β
CSS Import: Added to
angular.jsonstyles array - β
Animations:
provideAnimations()inapp.config.ts - β
SDK Initialization:
EmbedInitService.initialize()inngOnInit()with loading/error states - β User Data: Sent first before rendering the widget
- β
Event Listeners: Registered in
ngOnInit(), cleaned up inngOnDestroy() - β Custom Events: Tracked when user performs actions
- β Widget Rendering: Only rendered after successful initialization and user data sent
β‘ Angular-Specific Notes
Standalone Components (Recommended, Angular 15+)
ImportEmbedButtonComponent or EmbedProviderComponent directly into each componentβs imports array:
NgModule-based Apps
For applications that have not migrated to standalone components, importEmbedModule once in your root or feature module:
EmbedModule is imported.
Server-Side Rendering (SSR / Angular Universal)
The SDK usesPlatformService internally to detect the browser platform and skips all DOM operations during SSR. No additional configuration is needed β the widget renders nothing on the server and hydrates cleanly on the client.
Tailwind CSS Projects
β No conflicts! The library uses customembed-* prefixed classes
β
Your Tailwind styles wonβt affect the widget
β
Widget styles wonβt affect your app
π Troubleshooting
Widget appears unstyled
Solution: Make sure the CSS path is in yourangular.json styles array:
Widget not appearing
Solution: EnsureEmbedInitService.initialize() has completed before rendering the widget:
Widget overlaps with bottom navigation
Solution: Use thebottomOffset input:
Animations are broken or missing
Solution: EnsureprovideAnimations() (standalone) or BrowserAnimationsModule (NgModule) is present in your app config.
Events not being sent
Solution: Ensure youβve sentUSER_DATA event first with app_user_id:
Agent event listeners not firing
Solution: Make sure callbacks are registered inngOnInit() before the agent connects, and cleaned up in ngOnDestroy():
βUser identity not foundβ error
Solution: SendUSER_DATA event before any other events:
Custom events being blocked
Solution: OnlyUSER_DATA and CUSTOM_EVENT are allowed for manual sending. Agent events (AGENT_CONNECTED, AGENT_DISCONNECTED) are auto-tracked and can only be listened to, not manually sent.
Analytics event missing or rejected
Solution:event_name is a required field in every ANALYTICS_DATA event. Omitting it will cause the event to be dropped silently.
Widget appears behind other elements
Solution: Use theposition input to set a custom zIndex:
π Checklist
Before deploying, ensure: Basic Setup:- CSS path is in
angular.jsonstyles array -
provideAnimations()orBrowserAnimationsModuleis configured - API key is configured
-
isInitialized$is checked before rendering the widget - Parent container has
position: relative(for embedded mode) - Parent container has sufficient height (for embedded mode)
- Bottom offset is set if you have bottom navigation
-
USER_DATAevent sent first withapp_user_id -
USER_DATAsent before renderingrevrag-embed-button - Event listeners registered in
ngOnInit()before agent connection - Event listeners cleaned up in
ngOnDestroy() - Custom events include proper context (screen, flow)
- Error handling for failed event sends
- Loading states during SDK initialization (
isLoading$) - Agent connection status displayed to users
- Analytics tracking for agent events
- Proper cleanup of callbacks on component destroy
π Support
- π§ Issues: GitHub Issues
- π Docs: GitHub README
- π¬ Discussions: GitHub Discussions
π Youβre All Set!
The widget is now ready to use. Itβs:- β Fully responsive
- β Angular-native (standalone + NgModule)
- β Tailwind-compatible
- β Production-ready
- β Mobile-optimized
- β Real-time event tracking
- β Voice agent monitoring
- β User context aware
- β SSR-safe (Angular Universal)