Elena Avatar Frontend Integration ✅
Status: ✅ Integration Complete
Date: January 2026
Feature: Foundry Avatar Video Display in Engram Website
Overview
Elena’s Foundry avatar is now integrated into the Engram website. When users interact with Elena, they see her photorealistic video avatar speaking with natural voice and expressions.
Implementation
Backend Changes
- FoundryElenaWrapper (
backend/agents/foundry_elena_wrapper.py)- Updated
run()method to return(response_text, context, avatar_video_url) - Added
_run_foundry_agent_with_avatar()method - Uses Foundry’s responses API with avatar enabled
- Extracts
avatar_video_urlfrom response
- Updated
- Agent Router (
backend/agents/router.py)- Updated
route_and_execute()to return(response, context, agent_id, avatar_video_url) - Handles Foundry Elena wrapper’s avatar video URL
- Updated
- Chat Router (
backend/api/routers/chat.py)- Updated
ChatResponsemodel to includeavatar_video_url - Extracts avatar video URL from agent response
- Returns avatar video URL in API response
- Updated
Frontend Changes
- Message Interface (
frontend/src/components/ChatPanel/ChatPanel.tsx)- Added
avatarVideoUrl?: stringtoMessageinterface - Extracts
avatar_video_urlfrom API response - Displays video in message avatar when available
- Added
- AvatarDisplay Component (
frontend/src/components/AvatarDisplay/AvatarDisplay.tsx)- Added
avatarVideoUrl?: stringprop - Shows video when available, falls back to static image
- Maintains existing animation and viseme support
- Added
- ChatPanel Component (
frontend/src/components/ChatPanel/ChatPanel.tsx)- Updated message avatar to show video when
avatarVideoUrlis present - Falls back to static image if video fails or not available
- Maintains circular avatar styling
- Updated message avatar to show video when
- CSS Updates
- Added styles for
.avatar-videoin bothChatPanel.cssandAvatarDisplay.css - Maintains circular shape and proper sizing
- Added styles for
How It Works
Flow
User sends message
↓
Backend: FoundryElenaWrapper.run()
↓
Foundry Responses API (with avatar enabled)
↓
Foundry generates avatar video
↓
Backend extracts avatar_video_url from response
↓
API returns ChatResponse with avatar_video_url
↓
Frontend receives response
↓
ChatPanel displays video in message avatar
↓
User sees Elena's avatar video speaking
Avatar Video Display
In Chat Messages:
- When Elena responds, if
avatar_video_urlis present, a<video>element is shown - Video auto-plays, loops once, and is muted by default
- Falls back to static image if video fails to load
In AvatarDisplay Component:
- Can receive
avatarVideoUrlprop - Shows video when available
- Maintains all existing animations and viseme support
Configuration
Backend
The avatar is automatically enabled when:
USE_FOUNDRY_ELENA=trueELENA_FOUNDRY_AGENT_IDis set- Elena agent has avatar configured in Foundry (Version 3)
Frontend
No additional configuration needed. The frontend automatically:
- Detects
avatar_video_urlin API responses - Displays video when available
- Falls back gracefully if video is not available
User Experience
When Avatar Video is Available
- User sends message to Elena
- Elena responds with text and avatar video URL
- Avatar video displays in the message avatar
- Video plays showing Elena speaking
- Natural experience with photorealistic avatar
When Avatar Video is Not Available
- User sends message to Elena
- Elena responds with text only
- Static avatar image displays (existing behavior)
- No degradation in user experience
Testing
Test Avatar Display
- Enable Foundry Elena:
export USE_FOUNDRY_ELENA=true export ELENA_FOUNDRY_AGENT_ID=Elena -
Send a message to Elena in the Engram website
- Verify:
- Avatar video displays in message
- Video plays automatically
- Falls back to image if video fails
Verify Avatar Video URL
Check the API response:
curl -X POST "https://engram.work/api/v1/chat" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "Hello Elena!",
"agent_id": "elena"
}'
Response should include:
{
"content": "...",
"avatar_video_url": "https://...", // If available
...
}
Fallback Behavior
Video Fails to Load
- Frontend detects error via
onErrorhandler - Replaces video with static image
- User sees static avatar (no broken video)
Avatar Not Configured
- Backend returns response without
avatar_video_url - Frontend displays static image (existing behavior)
- No errors or broken UI
Foundry Not Enabled
- Backend uses LangGraph Elena (no avatar)
- Frontend displays static image
- Normal operation continues
Performance Considerations
Video Loading
- Lazy Loading: Videos load when message is displayed
- Error Handling: Graceful fallback to static image
- Caching: Browser caches videos for reuse
Bandwidth
- 1080p Resolution: Good balance of quality and size
- Transparent Background: Smaller file size
- Optimization: Consider CDN for video delivery
Future Enhancements
Potential Improvements
- Video Caching: Cache avatar videos for common responses
- Progressive Loading: Show static image while video loads
- Loading States: Show loading indicator while video generates
- Video Controls: Allow users to replay avatar videos
- Emotion Control: Adjust avatar emotion based on message tone
Summary
✅ Avatar Integration Complete
- Backend returns
avatar_video_urlfrom Foundry - Frontend displays video in chat messages
- Graceful fallback to static image
- No breaking changes to existing functionality
Elena’s avatar now appears in the Engram website when users interact with her, providing a more engaging and immersive experience.
Last Updated: January 2026