Eedesy
Book Demo
HomeProductsContact
AI Voice Agent
  • Introduction
  • Quick Start
  • Architecture
  • Core Concepts
  • Configuration
  • Creating an Agent
  • Using Templates
  • System Prompt Configuration
  • Language Selection
  • Settings Reference
  • Overview
  • Upload Files (PDF, DOCX)
  • Web Crawling (URLs & Sitemaps)
  • Document Processing
  • RAG Integration
  • Troubleshooting
  • Creating a Campaign
  • CSV Upload & Variables
  • Scheduling & Retry Logic
  • Campaign Analytics
  • Contact Management
  • Uploading Contacts
  • Managing Contacts
  • Call History Enrichment
  • Trial Numbers
  • Purchasing Numbers
  • BYOP Setup
  • Exotel Setup
  • Telephony Providers Guide
  • Credits System
  • Provider Costs Breakdown
  • Usage Analytics
  • Credit Packs
  • Overview
  • Finding Your Workspace ID
  • Common Issues
  • Audio Quality
  • Latency Optimization
  • Error Codes
  • Overview
  • Twilio
  • Exotel
  • Plivo
  • Telnyx
  • WhatsApp
  • WebRTC Browser
  • Overview
  • Deepgram
  • Google Chirp
  • Azure Speech
  • ElevenLabs Scribe
  • AssemblyAI
  • OpenAI Whisper
  • Overview
  • Cartesia
  • ElevenLabs
  • Google TTS
  • Azure Neural
  • OpenAI TTS
  • Deepgram Aura
  • Sarvam Bulbul
  • HeyPixa Luna
  • Overview
  • OpenAI GPT-4o
  • Gemini 2.0/2.5 Flash
  • Gemini Live (Native Audio)
  • OpenAI Realtime
  • Anthropic Claude
  • Azure OpenAI
  • Overview
  • VAD (Voice Activity Detection)
  • Interruption Handling
  • Turn Detection
  • Audio Processing
  • Function Calling
  • Call Transfer
  • DTMF Handling
  • Call Recording
  • Exporting Recordings
  • Transcripts
  • Webhooks
  • Variables & Templates
  • Multi-Language Support
  • Hindi
  • Tamil
  • Assamese
  • Other Indian Languages
  • Latency Optimization
  • Scaling & Performance
  • Error Handling
  • Monitoring & Logging
  • Security Best Practices
  • Trigger Call via API
  • REST API
  • WebSocket Protocol
  • Webhooks
  • Webhook Subscriptions
  • SDKs
  • Overview
  • Financial Services
  • E-commerce
  • Logistics
  • Hyperlocal
  • Healthcare
  • Education
  • Overview
  • Customer Support
  • Sales & Lead Conversion
  • Marketing Campaigns
  • Debt Collection
  • Overview
  • Customer Support Bot
  • Order Status IVR
  • Appointment Booking
  • Lead Qualification
  • Outbound Sales
  • Recruitment Screening
  • Overview
  • Migrate from Vapi
  • Migrate from Retell AI
  • Migrate from Traditional IVR

Related Products

  • AI Voice Agent
  • AI Voice Assistant
  • Try Free
AI Voice Agent
  • Introduction
  • Quick Start
  • Architecture
  • Core Concepts
  • Configuration
  • Creating an Agent
  • Using Templates
  • System Prompt Configuration
  • Language Selection
  • Settings Reference
  • Overview
  • Upload Files (PDF, DOCX)
  • Web Crawling (URLs & Sitemaps)
  • Document Processing
  • RAG Integration
  • Troubleshooting
  • Creating a Campaign
  • CSV Upload & Variables
  • Scheduling & Retry Logic
  • Campaign Analytics
  • Contact Management
  • Uploading Contacts
  • Managing Contacts
  • Call History Enrichment
  • Trial Numbers
  • Purchasing Numbers
  • BYOP Setup
  • Exotel Setup
  • Telephony Providers Guide
  • Credits System
  • Provider Costs Breakdown
  • Usage Analytics
  • Credit Packs
  • Overview
  • Finding Your Workspace ID
  • Common Issues
  • Audio Quality
  • Latency Optimization
  • Error Codes
  • Overview
  • Twilio
  • Exotel
  • Plivo
  • Telnyx
  • WhatsApp
  • WebRTC Browser
  • Overview
  • Deepgram
  • Google Chirp
  • Azure Speech
  • ElevenLabs Scribe
  • AssemblyAI
  • OpenAI Whisper
  • Overview
  • Cartesia
  • ElevenLabs
  • Google TTS
  • Azure Neural
  • OpenAI TTS
  • Deepgram Aura
  • Sarvam Bulbul
  • HeyPixa Luna
  • Overview
  • OpenAI GPT-4o
  • Gemini 2.0/2.5 Flash
  • Gemini Live (Native Audio)
  • OpenAI Realtime
  • Anthropic Claude
  • Azure OpenAI
  • Overview
  • VAD (Voice Activity Detection)
  • Interruption Handling
  • Turn Detection
  • Audio Processing
  • Function Calling
  • Call Transfer
  • DTMF Handling
  • Call Recording
  • Exporting Recordings
  • Transcripts
  • Webhooks
  • Variables & Templates
  • Multi-Language Support
  • Hindi
  • Tamil
  • Assamese
  • Other Indian Languages
  • Latency Optimization
  • Scaling & Performance
  • Error Handling
  • Monitoring & Logging
  • Security Best Practices
  • Trigger Call via API
  • REST API
  • WebSocket Protocol
  • Webhooks
  • Webhook Subscriptions
  • SDKs
  • Overview
  • Financial Services
  • E-commerce
  • Logistics
  • Hyperlocal
  • Healthcare
  • Education
  • Overview
  • Customer Support
  • Sales & Lead Conversion
  • Marketing Campaigns
  • Debt Collection
  • Overview
  • Customer Support Bot
  • Order Status IVR
  • Appointment Booking
  • Lead Qualification
  • Outbound Sales
  • Recruitment Screening
  • Overview
  • Migrate from Vapi
  • Migrate from Retell AI
  • Migrate from Traditional IVR
  1. Docs
  2. AI Voice Agent
  3. Features
  4. Function Calling

Function Calling

Extend your voice agent's capabilities with function calling - connect to APIs, databases, and external systems.

Function Calling

Function calling (also known as tool use) allows your voice agent to take actions beyond conversation - look up orders, schedule appointments, transfer calls, and more.

How It Works

User: "What's the status of my order 12345?"
         │
         ▼
┌─────────────────────────────────────────────────────────┐
│                         LLM                              │
│                                                          │
│  "I need to look up order 12345"                        │
│                                                          │
│  Function Call: get_order_status(order_id: "12345")     │
└─────────────────────────────────────────────────────────┘
         │
         ▼
┌─────────────────────────────────────────────────────────┐
│                    Tool Executor                         │
│                                                          │
│  HTTP GET https://api.example.com/orders/12345          │
│  Response: { status: "shipped", eta: "Dec 29" }         │
└─────────────────────────────────────────────────────────┘
         │
         ▼
┌─────────────────────────────────────────────────────────┐
│                         LLM                              │
│                                                          │
│  "Your order 12345 has been shipped and will            │
│   arrive by December 29th."                             │
└─────────────────────────────────────────────────────────┘
         │
         ▼
      TTS → User hears response

Defining Functions

Function Schema

{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_order_status",
        "description": "Get the current status of a customer order including shipping information",
        "parameters": {
          "type": "object",
          "properties": {
            "order_id": {
              "type": "string",
              "description": "The unique order identifier (e.g., ORD-12345)"
            }
          },
          "required": ["order_id"]
        }
      }
    }
  ]
}

Multiple Functions

{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_order_status",
        "description": "Get order status and shipping info",
        "parameters": {
          "type": "object",
          "properties": {
            "order_id": { "type": "string" }
          },
          "required": ["order_id"]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "schedule_callback",
        "description": "Schedule a callback from a human agent",
        "parameters": {
          "type": "object",
          "properties": {
            "preferred_time": {
              "type": "string",
              "description": "Preferred callback time (e.g., 'tomorrow morning')"
            },
            "phone_number": {
              "type": "string",
              "description": "Phone number to call back"
            },
            "reason": {
              "type": "string",
              "description": "Reason for callback"
            }
          },
          "required": ["preferred_time", "reason"]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "transfer_to_agent",
        "description": "Transfer the call to a human agent",
        "parameters": {
          "type": "object",
          "properties": {
            "department": {
              "type": "string",
              "enum": ["sales", "support", "billing"],
              "description": "Department to transfer to"
            },
            "reason": {
              "type": "string",
              "description": "Reason for transfer"
            }
          },
          "required": ["department"]
        }
      }
    }
  ]
}

Function Types

HTTP Functions

Call external APIs:

{
  "name": "get_order_status",
  "implementation": "http",
  "httpMethod": "GET",
  "httpUrl": "https://api.example.com/orders/{{order_id}}",
  "httpHeaders": {
    "Authorization": "Bearer {{API_KEY}}",
    "Content-Type": "application/json"
  },
  "responseMapping": {
    "status": "$.data.status",
    "eta": "$.data.estimated_delivery"
  }
}

Built-in Functions

Pre-defined functions that don't require external calls:

Function Description
end_call End the call with disposition
transfer_call Transfer to another number
send_dtmf Send DTMF tones
play_audio Play an audio file
set_variable Set a session variable

Custom Functions

Implement your own function handler:

// Register custom function
tools.RegisterFunction("check_inventory", func(ctx context.Context, args map[string]any) (any, error) {
    productID := args["product_id"].(string)

    // Your custom logic
    inventory, err := inventoryService.Check(productID)
    if err != nil {
        return nil, err
    }

    return map[string]any{
        "in_stock":  inventory.Quantity > 0,
        "quantity":  inventory.Quantity,
        "warehouse": inventory.Location,
    }, nil
})

Implementation

Tool Executor

type ToolExecutor struct {
    functions map[string]FunctionConfig
    httpClient *http.Client
}

func (e *ToolExecutor) Execute(ctx context.Context, call ToolCall) (any, error) {
    fn, ok := e.functions[call.Name]
    if !ok {
        return nil, fmt.Errorf("unknown function: %s", call.Name)
    }

    switch fn.Type {
    case "http":
        return e.executeHTTP(ctx, fn, call.Arguments)
    case "builtin":
        return e.executeBuiltin(ctx, fn, call.Arguments)
    case "custom":
        return fn.Handler(ctx, call.Arguments)
    default:
        return nil, fmt.Errorf("unknown function type: %s", fn.Type)
    }
}

func (e *ToolExecutor) executeHTTP(ctx context.Context, fn FunctionConfig, args map[string]any) (any, error) {
    // Build URL with variable substitution
    url := substituteVariables(fn.HTTPUrl, args)

    // Build request
    req, err := http.NewRequestWithContext(ctx, fn.HTTPMethod, url, nil)
    if err != nil {
        return nil, err
    }

    // Add headers
    for key, value := range fn.HTTPHeaders {
        req.Header.Set(key, substituteVariables(value, args))
    }

    // Execute request
    resp, err := e.httpClient.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    // Parse response
    var result map[string]any
    json.NewDecoder(resp.Body).Decode(&result)

    // Apply response mapping
    return applyMapping(result, fn.ResponseMapping), nil
}

Integration with LLM

func (p *Pipeline) processWithFunctions(ctx context.Context, transcript string) string {
    messages := append(p.context.Messages, Message{
        Role:    "user",
        Content: transcript,
    })

    for {
        // Generate response (may include function calls)
        response := p.llm.Generate(ctx, messages, p.tools)

        if len(response.ToolCalls) == 0 {
            // No function calls, return text response
            return response.Content
        }

        // Execute function calls
        for _, call := range response.ToolCalls {
            result, err := p.toolExecutor.Execute(ctx, call)

            // Add function result to context
            messages = append(messages, Message{
                Role:       "assistant",
                ToolCalls:  []ToolCall{call},
            })
            messages = append(messages, Message{
                Role:      "tool",
                ToolCallID: call.ID,
                Content:   formatResult(result, err),
            })
        }

        // Continue generation with function results
    }
}

Best Practices

1. Clear Function Descriptions

// ❌ Vague description
{
  "name": "get_data",
  "description": "Gets data"
}

// ✅ Clear description
{
  "name": "get_order_status",
  "description": "Retrieves the current status of a customer order including: order status (processing, shipped, delivered), estimated delivery date, and tracking number if available. Use when customer asks about their order."
}

2. Handle Errors Gracefully

func (e *ToolExecutor) Execute(ctx context.Context, call ToolCall) (any, error) {
    result, err := e.doExecute(ctx, call)

    if err != nil {
        // Return user-friendly error message
        return map[string]any{
            "error": true,
            "message": "I wasn't able to look that up right now. Let me try something else.",
        }, nil
    }

    return result, nil
}

3. Timeout Configuration

// Set appropriate timeouts
httpClient := &http.Client{
    Timeout: 5 * time.Second, // Don't block the call too long
}

4. Validate Arguments

func validateOrderID(orderID string) error {
    if orderID == "" {
        return errors.New("order ID is required")
    }
    if !regexp.MustCompile(`^ORD-\d+$`).MatchString(orderID) {
        return errors.New("invalid order ID format")
    }
    return nil
}

5. Mute Audio During Execution

// Prevent STT from processing while function executes
func (p *Pipeline) executeFunction(ctx context.Context, call ToolCall) {
    p.user.SetExecutingFunction(true)
    defer p.user.SetExecutingFunction(false)

    // Optional: Play hold music or "one moment please"
    p.playHoldMessage()

    result := p.toolExecutor.Execute(ctx, call)
    // ...
}

Common Function Patterns

Order Lookup

{
  "name": "get_order_status",
  "httpMethod": "GET",
  "httpUrl": "https://api.store.com/orders/{{order_id}}",
  "responseMapping": {
    "status": "$.status",
    "eta": "$.estimated_delivery",
    "tracking": "$.tracking_number"
  }
}

Appointment Scheduling

{
  "name": "book_appointment",
  "httpMethod": "POST",
  "httpUrl": "https://api.calendar.com/appointments",
  "httpBody": {
    "date": "{{date}}",
    "time": "{{time}}",
    "customer_phone": "{{phone_number}}",
    "service": "{{service_type}}"
  }
}

CRM Integration

{
  "name": "log_interaction",
  "httpMethod": "POST",
  "httpUrl": "https://crm.example.com/api/interactions",
  "httpHeaders": {
    "Authorization": "Bearer {{CRM_API_KEY}}"
  },
  "httpBody": {
    "customer_phone": "{{caller_phone}}",
    "summary": "{{interaction_summary}}",
    "sentiment": "{{sentiment}}",
    "call_sid": "{{call_sid}}"
  }
}

Next Steps

  • Call Transfer - Transfer to human agents
  • Webhooks - Post-call integrations
  • Variables - Dynamic content
Previous
Audio Processing
Next
Call Transfer

On this page

  • How It Works
  • Defining Functions
  • Function Schema
  • Multiple Functions
  • Function Types
  • HTTP Functions
  • Built-in Functions
  • Custom Functions
  • Implementation
  • Tool Executor
  • Integration with LLM
  • Best Practices
  • 1. Clear Function Descriptions
  • 2. Handle Errors Gracefully
  • 3. Timeout Configuration
  • 4. Validate Arguments
  • 5. Mute Audio During Execution
  • Common Function Patterns
  • Order Lookup
  • Appointment Scheduling
  • CRM Integration
  • Next Steps

Stay Updated

Get the latest updates on AI voice technology, product releases, and exclusive resources.

Get Started

Try our products for free
AI Voice Agent
Build voice AI for calls
WhatsApp AI Bot
Automate WhatsApp chats
Website Chatbot
AI chat for websites
Edesy CRM
Manage leads & customers
Book a DemoCall UsEmail Us
Eedesy

Your all-in-one platform for digital innovation. We build AI-powered solutions that transform how businesses operate.

[email protected]+91 95475 31359

Products

  • AI Voice Assistant
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products

Solutions

  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases

Services

  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services

Resources

  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo

Company

  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service

Products

  • AI Voice Assistant
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products

Solutions

  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases

Services

  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services

Resources

  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo

Company

  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service
  • AI Voice Assistant
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products
  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases
  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services
  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo
  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service

Popular Free Tools

Compress PDFMerge PDFPDF to WordGST CalculatorEMI CalculatorSIP CalculatorJSON FormatterBase64 EncoderImage CompressorQR Code GeneratorVoice AI ROI CalculatorAmazon FBA CalculatorAI Email WriterVideo to GIFPrivacy Policy GeneratorCRM ROI CalculatorMeeting Cost Calculator
Categories:PDF ToolsDeveloper ToolsFinance CalculatorsImage ToolsVideo ToolsAI Writing ToolsAudio ToolsWhatsApp ToolsDocument GeneratorsVoice AI ToolsE-commerce ToolsView All Tools

© 2026 Edesy Technology Labs Pvt Ltd

SSL Secured
99.9% Uptime