What Is Function Calling?
Function calling lets your AI agent execute actions during a call. Instead of just talking, your agent can:- Book appointments in your calendar
- Look up orders in your database
- Update CRM records
- Process payments
- Check inventory
- End the call gracefully when the conversation is complete
- And anything else your API can do
Real-Time Integration
Connect your AI to your existing systems. No need to rebuild your infrastructure.
Seamless Experience
Users don’t know the AI is calling APIs—it feels like talking to a human agent.
Flexible
Define any function with any parameters. Works with REST APIs, GraphQL, databases, and more.
Secure
Functions run on your servers with your credentials. TopCalls never stores API keys.
How It Works
1. Define Tools
When creating a call, provide tool definitions with names, descriptions, and parameters.
2. AI Decides
During the conversation, the AI decides when to call a tool based on the user’s request.
3. Tool Execution
TopCalls calls your webhook with the tool name and parameters. Your server executes the function.
Built-in Tools
TopCalls provides built-in tools that are automatically available during calls. You don’t need to define these—they’re ready to use.end_call
Theend_call tool allows your AI agent to gracefully end the call when the conversation is complete.
The AI will automatically use
end_call when appropriate—you don’t need to configure anything. The agent decides when to end based on context: user says goodbye, all questions answered, or clear conversation conclusion.- User says “goodbye”, “thanks, that’s all”, etc.
- All questions have been answered
- User explicitly asks to end the call
- Conversation naturally concludes
- AI decides to end the call
- AI speaks a contextual farewell message (e.g., “Thanks for calling! Your appointment is confirmed. Have a great day!”)
- Call is terminated
book_appointment
Automatically available for appointment scheduling. Updates the call record with the booked slot.Defining Custom Tools
Basic Tool Definition
Complete Example: Appointment Booking
Handling Tool Calls
When the AI wants to call a tool, TopCalls sends a webhook to your server:Your Server Response
Your server should return the result:“Great! I checked availability and we have slots at 9 AM, 10 AM, 11 AM, 2 PM, and 3 PM. Which works best for you?”
Real-World Examples
Example 1: Order Lookup
Example 2: CRM Update
Example 3: Payment Processing
Tool Execution Flow
Error Handling
If a tool call fails, return an error:“I’m sorry, that time slot is already booked. Let me check other available times…”
Best Practices
✅ Do This
- Clear descriptions: Write detailed tool descriptions so the AI knows when to use them
- Validate parameters: Always validate parameters on your server
- Return structured data: Use consistent response formats
- Handle errors gracefully: Return clear error messages
- Log everything: Keep logs of all tool calls for debugging
- Fast responses: Return results quickly (< 2 seconds) for natural conversation
❌ Don’t Do This
- Vague descriptions: “Helper function” doesn’t help the AI
- Slow APIs: Don’t call slow external APIs synchronously
- Ignore errors: Always handle errors and return appropriate responses
- Complex parameters: Keep parameter schemas simple
- Too many tools: Limit to 5-10 tools per call for best results
Security Considerations
- API Keys: Store API keys securely on your server, never in the call configuration
- Validation: Always validate tool parameters before execution
- Rate Limiting: Implement rate limiting on your tool endpoints
- Authentication: Use webhook signatures to verify requests are from TopCalls
- Authorization: Check permissions before executing tools

