šļø VAPI Conversational AI
LogLife uses VAPI to enable voice conversations with users. This document explains the three different approaches for implementing conversational AI with VAPI.
š Overview
| Approach | Status | Description |
|---|---|---|
| Static | ā Supported | AI-driven conversations with no assistant updates (permanent or during call). Only uses assistantOverrides for temporary per-call configuration. |
| Mixed/Hybrid | ā Supported | AI-driven with server tools for user-specific data. Uses assistantOverrides for temporary per-call updates. No permanent or during-call assistant updates. |
| Dynamic | ā Not Yet Supported | Full AI-driven with server tools, assistantOverrides, plus real-time assistant updates during calls (system messages, final messages, etc.) |
š Dynamic Prompt Injection
LogLife supports dynamic system prompt injection that personalizes the VAPI assistant with user-specific context (habits/goals) before each call via assistantOverrides.
š Static Approach
AI-driven conversations with fixed assistant configuration. Only assistantOverrides can temporarily modify settings per-call.
Key Points:
- ā
AI-driven, no backend integration
- ā
Fixed configuration, no permanent or during-call updates
- ā
assistantOverrides for per-call customization
- ā Cannot fetch user-specific data
š Mixed/Hybrid Approach (Current Implementation)
AI-driven conversations with server tools to fetch user-specific data. Assistant can call backend APIs to retrieve dynamic information.
Key Points:
- ā
AI-driven with server tools
- ā
Can fetch user-specific data via tool calls
- ā
assistantOverrides for per-call context injection
- ā No permanent or during-call assistant updates
Current Implementation:
- Server tools configured to call backend endpoints
- assistantOverrides injects user habits/goals before call
- AI uses tool results for personalized responses
š¤ Dynamic Approach (Not Yet Supported)
Extends Hybrid approach with real-time assistant updates during calls. Includes all Hybrid features plus ability to modify assistant configuration mid-conversation.
Key Points: - ā Everything from Hybrid - ā Real-time assistant updates during calls (system messages, final messages, configuration) - ā Adaptive behavior based on conversation progress
š§ Technical Details
Voice Turn Endpoint
Endpoint: POST /voice-turn
Headers: x-api-key: my-super-secret-123
Request:
{
"external_user_id": "user_token_or_phone",
"user_text": "What are my habits?",
"mode": "daily_checkin"
}
Response:
{
"reply_text": "You have 3 habits:\n⢠š Read 30 mins\n⢠šŖ Exercise\n⢠š§ Meditate"
}
End Call: Include endCall=true in response text.
Supported Modes
daily_checkin- Daily habit check-ingoal_setup- Goal setup and configurationtemptation_support- Support during temptation momentsonboarding- New user onboarding
Additional Endpoints
Token Validation
Endpoint: GET /validate-token?token=<token>
Response:
{
"valid": true,
"phone_number": "923325727426"
}
User Habits Retrieval
Endpoint: GET /user-habits?token=<token>
Response:
{
"habits": "User's current habits:\n- šÆ Read 30 minutes daily\n..."
}
Assistant Prompt Modification
Endpoint: GET /api/vapi/assistant/[assistantId]?token=<token>
Fetches assistant's system prompt and returns modified version with user habits prepended.
Response:
{
"originalPrompt": "You are LogLife Coach...",
"modifiedPrompt": "User's current habits:\n...\nYou are LogLife Coach..."
}
VAPI Assistant Admin Panel
Endpoint: GET /vapi-admin
Web-based admin panel for managing VAPI assistant configurations. Accessible from emulator page.
API Endpoints:
- GET /vapi-admin/api/assistant/<assistant_id> - Fetch assistant config
- PATCH /vapi-admin/api/assistant/<assistant_id> - Update assistant config
Editable Fields: name, firstMessage, voicemailMessage, endCallMessage, endCallPhrases, model, voice, transcriber, clientMessages, serverMessages
Read-Only Fields: id, orgId, createdAt, updatedAt, isServerUrlSecretSet, backgroundDenoisingEnabled, compliancePlan, hipaaEnabled
Frontend Integration
The frontend call page (website/app/call/[number]/[token]/page.tsx):
- Maps call numbers to VAPI assistant IDs
- Validates user tokens
- Injects user habits via assistantOverrides before call
- Passes external_user_id to VAPI
- Handles call events
Dynamic Prompt Injection Flow
- Validate user token
- Fetch user habits from database
- Inject habits into system prompt via
assistantOverrides.model.messages - Start call with personalized configuration
Example Modified Prompt:
User's current habits:
- šÆ Read 30 minutes daily
- šŖ Exercise 3 times per week
[Original system prompt continues...]
š Related Documentation
- Core Architecture: Understanding the overall system architecture
- WhatsApp Flow: How WhatsApp integration works
- API Reference - Routes: Detailed API documentation