Core Concepts
Functions for Agents
Functions are additional capabilities that you can integrate into your voice agents to enhance their utility and interaction dynamics.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Functions are additional capabilities that you can integrate into your voice agents to enhance their utility and interaction dynamics.
interface FunctionCall { // Main structure for defining a function.
name: string; // Function name, formatted as a valid identifier (no spaces, begins with a letter)
description: string; // Detailed description to help the agent understand when to use the function
webhook: string; // The URL of the webhook to which the request will be sent
header: object; // Any necessary headers for the webhook request
params: Param[]; // Array of `Param` objects, defining the parameters needed by the function
}
interface Param {
name: string; // Valid parameter name, no spaces, starts with a letter, can use underscores or camelCase
type: ParamType; // The data type of the parameter (e.g., string, number, boolean)
description: string; // Detailed description of the parameter
required: boolean; // Whether this parameter is mandatory
}
export interface WebFormFunction {
name: string; // Function name, formatted as a valid identifier
description: string; // Detailed description to help the agent understand the function's purpose
type: "web_form"; // Specify this as 'web_form' for web form functions
data: { // Define the parameter to collect from the web form
param: Param;
};
}
// Webhook
{
name: "getUserInfo",
description: "Retrieves user information from the database using their email.",
webhook: "https://api.example.com/user",
header: {
"Content-Type": "application/json",
"Authorization": "Bearer your_access_token"
},
params: [
{
name: "email",
type: "string",
description: "The user's email that you collect during the conversation.",
required: true
}
]
};
// Web Form
{
name: "open_email_form",
description: "Trigger a web form for user to enter contact details.",
type: "web_form",
data: {
param: {
name: "email",
type: "string",
description: "Collect user's email info.",
required: true
}
}
};
{
"tools": [
{
name: "getUserInfo",
// the rest of the function definition
}
]
}