Skip to main content
Custom functions let you turn any REST API endpoint into a tool your AI agent can call during a live conversation. You define the endpoint URL, request type, authentication headers, and a plain-English description of when to use the function. The moment the caller’s words match the intent described, the agent calls the API, receives the response, and incorporates the result into what it says next — all while the caller waits.

What Custom Functions Enable

  • Look up customer account status, balance, or subscription tier from your database
  • Check live inventory levels or product pricing before quoting a customer
  • Create support tickets in your helpdesk system in real time
  • Send an SMS confirmation via Twilio while the caller is still on the line
  • Geocode a caller-provided address or check a delivery status
  • Verify appointment availability and confirm bookings
  • Retrieve order status using a dynamically extracted order ID

Creating a Custom Function

1

Go to Settings → Functions → Create Function

Open your VoiceInfra dashboard and navigate to Settings → Functions. Click Create Function.
2

Name your function

Enter a function name between 5 and 100 characters using alphanumeric characters and underscores only — for example, check_order_status or get_account_balance. This name is used internally by the LLM to identify the function.
3

Write an LLM-optimized description

Write a clear description (10–500 characters) that tells the AI exactly when to call this function. Be specific. For example: “Call this function when the user asks about their order status, delivery date, or shipping tracking. Requires the order ID.” The more precise your description, the more reliably the agent invokes the function at the right moment.
4

Set the endpoint URL

Enter the full URL of your API endpoint. Use curly-brace placeholders for dynamic path parameters — for example, https://api.yourbusiness.com/orders/{order_id}. The agent extracts the value from the conversation and substitutes it automatically.
5

Select the request type

Choose GET for data retrieval, POST for creating or updating data, or Async for fire-and-forget operations where you don’t need to block the conversation waiting for a response.
6

Add authentication headers

In the Request Headers section, add any headers your API requires — for example, Authorization: Bearer your-api-key or X-API-Key: your-key. These headers are encrypted before storage and never exposed in logs.
7

Define the request body (POST only)

For POST requests, define the JSON body structure. Use placeholders for values the agent will supply from the conversation.
8

Save and assign to your agent

Click Save. Then open your agent’s configuration, go to the Functions tab, and enable this function for the agent. Test it before going live.

Start From a Template

Speed up setup by starting from a pre-built template. Available templates include:
TemplateUse case
Basic REST API (GET)Read data from any GET endpoint
POST Request with BodySubmit data to a POST endpoint
Twilio Send SMSSend an SMS message mid-call
Mailjet Send EmailTrigger a transactional email
Geocode LocationConvert an address to coordinates
Check Appointment AvailabilityQuery your scheduling system
You can also import directly from a cURL command — paste any cURL command from your API docs and VoiceInfra parses the URL, headers, and body automatically.

Example Function Configuration

{
  "name": "check_order_status",
  "description": "Call this when the user asks about their order status or delivery. Requires the order ID.",
  "method": "GET",
  "url": "https://api.yourbusiness.com/orders/{order_id}",
  "headers": {
    "Authorization": "Bearer {{env.API_KEY}}"
  }
}
When a caller says “What’s the status of order 45892?”, the agent extracts 45892 as the order_id, calls your API, and responds with the live data returned — for example: “Your order is out for delivery and will arrive tomorrow by 3pm.”

Supported Request Types

TypeWhen to use
GETFetching data — account lookup, inventory check, appointment slots, order status
POSTCreating or updating — create a ticket, book an appointment, send a notification
AsyncFire-and-forget for slow operations — don’t block the conversation waiting for a result
Use Async for operations that take more than a few seconds or don’t need to return data to the conversation — for example, sending a notification or logging an event.

Testing Functions

Before assigning a function to a live agent, use the built-in test tool to verify it works:
  1. Open the function in Settings → Functions
  2. Click Test Function
  3. Enter sample parameter values (e.g., order_id: 45892)
  4. Review the API response
Confirm the response format is what you expect before deploying. If the API returns an error, the test tool shows the full HTTP response to help you debug.

Frequently Asked Questions

The agent reads the description you write for each function and decides whether the current moment in the conversation matches the described intent. Write specific, action-oriented descriptions — start with phrases like “Call this when the user asks about…” or “Use this to look up…”. Vague descriptions lead to missed or incorrect invocations.
There is no strict limit on the number of custom functions you can create or assign to an agent. Keep in mind that assigning many functions increases the LLM’s decision space — for best results, assign only the functions relevant to each agent’s purpose.
Add authentication headers in the function configuration (API key, Bearer token, etc.). VoiceInfra encrypts all stored credentials at rest. Your endpoint should also validate the token on every request to prevent unauthorized access.
Yes. The API response is passed back to the LLM and included in the agent’s context. The agent uses the returned data to form its next spoken response. Make sure your API returns structured JSON with clearly named fields for best results.
The agent receives the error response and handles it gracefully — informing the caller of the issue, retrying if appropriate, or escalating to a human agent. Configure your agent’s fallback behavior in the agent prompt.
Yes. Reference environment variables in header values using the {{env.VARIABLE_NAME}} syntax. Manage environment variables in Settings → Environment Variables to avoid hardcoding credentials in function configurations.