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
- End the call gracefully when the conversation is complete
Real-Time Integration
Connect your AI to your existing systems. No need to rebuild your infrastructure.
Natural Experience
Users don’t know the AI is calling APIs. It feels like talking to a human agent.
Flexible
Define functions with any parameters. Works with REST APIs, GraphQL, databases, and more.
Secure
Functions run on your servers with your credentials. TopCalls never stores your API keys.
How It Works
1. Configure Tools
Define the tools your AI agent can use when setting up a call or campaign through the TopCalls dashboard, or include them in your API call configuration.
2. AI Decides
During the conversation, the AI decides when to call a tool based on the user’s request.
3. Tool Execution
TopCalls sends a webhook to your server 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.end_call
Theend_call tool allows your AI agent to gracefully end the call when the conversation is complete.
The AI uses
end_call automatically when appropriate. 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
- Call is terminated
Custom Tools
Define custom tools to connect your AI agent to your systems. When the AI invokes a tool, TopCalls sends a webhook to your server.Tool Definition Example
Handling Tool Calls
When the AI wants to call a tool, TopCalls sends a webhook to your server:Your Server Response
Return the result as JSON:“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
Order Lookup
CRM Update
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
- Fast responses: Return results quickly (< 2 seconds) for natural conversation
Avoid This
- Vague descriptions: “Helper function” doesn’t help the AI decide when to use it
- Slow APIs: Don’t call slow external APIs synchronously
- Ignore errors: Always handle errors and return appropriate responses
- 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
Next Steps
Making Calls
Learn how to include tools when making calls.
Webhooks
Set up webhooks to receive tool call requests.