API integration allows your voice agents to interact with external systems, fetch data, and perform actions beyond conversation. Hamsa’s tool system makes it easy to connect to any HTTP API, enabling powerful workflows like looking up customer data, creating tickets, sending notifications, and more.
Tools are reusable API configurations that your agents can call during conversations. Think of them as functions your agent can execute.Tool Components:
Let’s create a tool to look up customer information.
1
Navigate to Tools
Go to Tools in the sidebar and click Add New Tool
2
Configure Basic Info
Name: "Lookup Customer by Phone"Description: "Retrieves customer account information by phone number. Returns name, account number, tier, and recent orders. Use when caller asks about their account or needs verification."
Add tools to your conversation flow using Tool Nodes.Example: Customer Lookup Flow
Node 1: Collect_Phone Message: "Can I get your phone number to look up your account?" Extract Variables: - phone_number: "Extract 10-digit phone number"Node 2: Lookup_Customer (Tool Node) Tool: "Lookup Customer by Phone" Parameters: phone_number: {{phone_number}} # Tool executes API call # Returns: customer_name, account_number, tier, last_order_dateNode 3: Greet_Customer Message: "Welcome back, {{customer_name}}! I see you're a {{tier}} member. How can I help you today?" Transitions: Based on conversation intent
Tool Node Configuration:
Tool Node Settings: Tool Template: Select from tool library Parameters: Map variables to tool inputs Path Parameters: Override URL path variables Headers: Override HTTP headers (optional) Messages: Custom messages for this use (optional)
Add tools to configuration, agent decides when to call them.
1
Open Agent Configuration
Navigate to your Single Prompt Agent settings
2
Add Tools
Go to Configuration → Tools → Add Tool
3
Select Tools
Choose tools from your library
4
Configure Overrides (Optional)
Override parameters or headers for this specific agent
5
Update Prompt
Mention tools in your preamble:
## Available ToolsYou have access to these tools:- lookup_customer: Look up customer info by phone number- create_ticket: Create support tickets- check_order: Get order statusUse these tools when appropriate to help the caller.
Fetch information from your systems.Example: Get Order Status
{ "name": "Get Order Status", "description": "Retrieves order status, tracking info, and estimated delivery. Use when caller asks about their order or delivery.", "methodType": "GET", "url": "https://api.yourstore.com/orders/:orderId", "authType": "jwtAuth", "authToken": "Bearer sk_live_123", "pathParameters": [ { "name": "orderId", "defaultValue": "ORD-12345" } ], "parameters": { "type": "object", "properties": { "orderId": { "type": "string", "description": "Order ID (format: ORD-XXXXX)" } }, "required": ["orderId"] }}
Response Handling:
Tool returns: { 'order_id': 'ORD-12345', 'status': 'shipped', 'tracking_number': '1Z999AA10123456784', 'estimated_delivery': '2024-01-18', 'items': [...], }Agent can use in response: "Your order {{order_id}} has been {{status}}. It's tracking number is {{tracking_number}} and should arrive by {{estimated_delivery}}."
Node: Call_API (Tool) Tool: Lookup Customer Parameters: phone: {{phone_number}} Transitions: # Success path - API returns 200 → Success_Node # Error paths - API returns 404 → Customer_Not_Found - API returns 500 → Retry_Or_Fallback - Timeout → Retry_Or_FallbackCustomer_Not_Found: Message: "I couldn't find an account with that phone number. Would you like to create a new account?"Retry_Or_Fallback: Type: Router Conditions: - {{retry_count}} < 2 → Retry_API_Call - {{retry_count}} >= 2 → "I'm having trouble accessing the system right now. Let me transfer you to someone who can help." → Transfer_To_Agent
Agent behavior: "I'm generating your report now. This usually takes about a minute. Feel free to ask me anything else while we wait." [Agent can continue conversation] [Tool completes in background] "Your report is ready! I'm sending it to {{email_address}} now."
Node: Greet_Customer Message: "Welcome back, {{customer.name}}! I see you're a {{customer.tier}} member with an account balance of ${{customer.balance}}."Node: Order_Status Message: "Your most recent order {{orders[0].id}} is {{orders[0].status}}."
Tool Node: Lookup_Customer Tool: Get Customer Info # Returns customer data or errorValidation Router: Conditions: # Success case - {{api_response_status}} == 200 → Use_Customer_Data # Customer not found - {{api_response_status}} == 404 → "I couldn't find an account with that information. Would you like to create a new account?" # Server error - {{api_response_status}} >= 500 → "I'm having trouble accessing the system right now. Let me try again." → Retry_Or_Transfer # Any other error - Always → "Something went wrong. Let me connect you with someone who can help." → Transfer_To_Agent
Flow: Schedule_AppointmentNode 1: Identify_Customer Message: "What's your phone number?" Extract: phone_numberNode 2: Get_Available_Slots (Tool) Tool: Check Availability Tool Config: Method: GET URL: https://api.scheduler.com/slots/available Auth: Bearer {{SCHEDULER_API_KEY}} Parameters: service_type: {{service_type}} start_date: {{current_date}} days_ahead: 14 Returns: available_slots (array)Node 3: Present_Options Message: "I have availability on: - {{available_slots[0].date}} at {{available_slots[0].time}} - {{available_slots[1].date}} at {{available_slots[1].time}} - {{available_slots[2].date}} at {{available_slots[2].time}} Which works best for you?" Extract: preferred_slotNode 4: Book_Appointment (Tool) Tool: Create Appointment Tool Config: Method: POST URL: https://api.scheduler.com/appointments Auth: Bearer {{SCHEDULER_API_KEY}} Parameters: customer_phone: {{phone_number}} slot_id: {{selected_slot_id}} service_type: {{service_type}} notes: {{appointment_notes}} Returns: - appointment_id - confirmation_codeNode 5: Send_Confirmation (Tool) Tool: Send SMS Confirmation Tool Config: Method: POST URL: https://api.sms.com/send Auth: Bearer {{SMS_API_KEY}} Parameters: to: {{phone_number}} message: "Your appointment is confirmed for {{appointment_date}} at {{appointment_time}}. Confirmation code: {{confirmation_code}}"Node 6: Verbal_Confirmation Message: "Perfect! You're all set for {{appointment_date}} at {{appointment_time}}. I've sent a confirmation to your phone. Is there anything else I can help with?"