lib/ttai/ module.
Module Structure
Scenario Configuration
Define your scenarios inlib/ttai/constants.ts:
Building Embed URLs
Theclient.ts file provides URL builder functions:
URL Builder Implementation
Iframe Event Handling
The template provides a helper for listening to iframe events:Event Listener Implementation
TTAIIframe Component
Thecomponents/TTAIIframe.tsx component wraps the iframe with proper permissions:
Component Implementation
allow attribute grants:
- microphone: Voice conversations
- camera: Video features (if enabled)
- display-capture: Screen sharing (if enabled)
Server-Side API Client
Theapp/api/ttai/client.ts file handles server-side API calls:
API Routes
The starter provides these API routes:| Route | Method | Description |
|---|---|---|
/api/sessions | GET | List sessions (with scenario filter) |
/api/sessions/[id] | GET | Get session details |
/api/sessions/analyze | POST | Analyze a completed session |
/api/balance | GET | Get account balance |
Example: Analyze Route
Dynamic Variables
Pass context to scenarios using URL parameters:{{userName}} and {{userPersonalityAssessment}}
in the AI instructions.
Next Steps
State & Auth
State management and authentication
Deployment
Deploy to production