Overview
Post-call functions execute after AI calls end. They process call data, update systems, and trigger workflows based on call outcomes. Common Use Cases:- Calculate next date of action (NDOA)
- Update CRM with call results
- Send follow-up emails
- Trigger webhooks
- Generate reports
- Schedule callbacks
Execution Timing
Basic Mode
Configure API integrations with JSON parameter mapping.
Configuration Fields
| Field | Required | Description |
|---|---|---|
| Name | Yes | Function name (no spaces) |
| API URL | Yes | Endpoint to call (supports variables) |
| Method | Yes | GET, POST, PUT, or DELETE |
| Headers | No | Authentication headers |
| Parameters | Yes | JSON with variable mapping |
| Condition | Yes | When to trigger this function |
URL Variable Mapping
Include variables in URL using double curly braces: Example:lead_idfrom call_metadatacall_statusfrom post_call variables
JSON Parameters
Define JSON structure with variables and map each to its source from call metadata or post-call analysis.Conditional Execution
Control when your post-call function runs by adding conditions. Call Type Filter:- All - Run for all calls (default)
- Connected - Only run for connected calls (duration > 0)
- Not Connected - Only run for missed/failed calls
- Call Metadata:
lead_sourceequals"website" - Post Call Variable:
interestedequalstrue - Call Type: Connected only
- Send confirmation email only when
confirmationis true - Update CRM only for connected calls
- Schedule callback only when
interestedis true and call was not connected
All conditions must match for the function to execute. This ensures precise control over when your post-call logic runs.
Advanced Mode (JavaScript)
Write custom JavaScript for complex business logic.
Function Signature
All post-call functions must follow this signature:- Must be
async function - Takes exactly ONE parameter:
context - Returns nothing (void)
- ALL variables accessed via
contextobject
Context Object
Thecontext object contains all call data and methods.
Available Variables:
Mutable Fields (You CAN Modify)
✅ These fields can be updated:context.conversion_status- Set to true/false for conversion trackingcontext.disposition_reason- Update call dispositioncontext.next_call_scheduled- Boolean flag for scheduling statuscontext.post_call.*- Add or update any field in post_call objectcontext.post_call_detail.*- Add details with value + comment formatcontext.functions_called- Push function execution logs
Read-Only Fields (Do NOT Modify)
🔒 These fields are immutable:context.agent- Agent ID (immutable)context.userId- User ID (immutable)context.call_duration- Call duration in secondscontext.hangup_reason- Hangup reason codecontext.call_metadata- Original call metadata (read-only)context.callSid- Call SIDcontext.recordingUrl- Call recording URLcontext.user_phone_number- Customer phone numbercontext.agent_phone_number- Agent phone number
Pre-Imported Modules
These modules are available without require(): axios - HTTP requestsExample: Calculate NDOA
Making API Calls
Logging Function Execution
MANDATORY SCHEMA - Only use these 5 fields:AI Generation
Click “Generate with AI” to create functions using natural language. Example Prompt:Security Rules
FORBIDDEN:process.env- No environment variablesprocess- No process objectrequire()- Use pre-imported modules onlyeval(),Function()- No dynamic codefs- No filesystem accesschild_process- No process execution
Best Practices
- Use context object - All variables via
context - Set timeouts - 10 seconds max for API calls
- Handle errors - Catch and log errors properly
- Log execution - Always log to
context.functions_called - Document changes - Use
post_call_detailwith comments - Test thoroughly - Verify with different scenarios