Overview
In-call functions execute during active AI calls when triggered by the AI agent. These allow your agent to perform real-time actions based on conversation context. Common Use Cases:- Check product availability
- Book appointments (custom systems)
- Validate customer information
- Query databases
- Call external APIs for live data
Execution Timing
Basic Mode
Configure API integrations with parameters that AI can fill.
Configuration Fields
| Field | Required | Description |
|---|---|---|
| Name | Yes | Function name (no spaces) |
| Description | Yes | When AI should call this function |
| API URL | Yes | Endpoint to call |
| Method | Yes | GET, POST, PUT, or DELETE |
| Headers | No | Authentication headers |
| Parameters | Yes | Typed parameters with descriptions |
Description (AI Trigger)
The description tells the AI when to call this function. Example:Parameters Configuration
Each parameter needs:- Key Name - Parameter name
- Type - string or number
- Description - What this parameter represents
Advanced Mode (Python)
Write custom Python code with full control.
Function Signature
- Must be
async def - First parameter must be
ctx: RunContext - All parameters must have type annotations
- Must include detailed docstring
- Must return dict with
statusfield
Return Schema
Always return a dictionary with at least astatus field:
Example: Check Weather
AI Generation
Click “Generate with AI” to create functions using natural language. Example Prompt:Allowed Types
- Allowed ✅
- Forbidden ❌
Parameter Types:
str,int,float,boolNonedict,list- JSON-serializable types
Security Requirements
- ✅ Input Validation - Always validate inputs
- ✅ No Filesystem - Never read/write files
- ✅ No OS/Process - Avoid subprocess, os.system
- ✅ No Eval - Never use eval() or exec()
- ✅ Timeouts - Set timeouts for external calls
- ✅ Error Handling - Catch and return errors properly
Best Practices
- Keep functions focused - One function, one purpose
- Validate inputs - Check all parameters before use
- Set timeouts - Don’t let API calls hang
- Return clear errors - Help AI understand what went wrong
- Log important events - Use logger for debugging
- Handle edge cases - Test with various inputs