How Custom Functions Work
- Definition: You define a function in the dashboard with a name, description, and required parameters.
- Detection: When a user asks a question that requires the function (e.g., “What is my order status?”), the AI detects that it needs to call that function.
- Execution: The system sends a request to your configured API endpoint with the extracted parameters.
- Response: Your API responds with the data.
- Answer: The AI uses that data to provide a final answer to the user.
Configuring a Function
Navigate to your agent’s editor page and scroll to the Custom Functions section.1. Basic Info
- Function Name — A descriptive identifier (e.g.,
get_order_status). - Description — Tell the AI when to use this function (e.g., “Retrieves the status of a customer’s order using their order ID”). The more specific, the better.
2. API Endpoint
- Method —
GET,POST,PUT, orDELETE. - URL — The full webhook URL on your server.
- Timeout — How long to wait for a response (in seconds) before timing out.
3. Headers & Query Params
Add custom headers (e.g., authentication tokens) and query parameters using the key-value editors:4. Parameters
Define the inputs the AI needs to extract from the user’s message:| Field | Description |
|---|---|
| Name | Parameter identifier (e.g., order_id) |
| Type | string, number, boolean, integer, array, or object |
| Description | What this parameter represents (helps the AI extract it) |
| Required | Whether the AI must collect this before calling the function |
5. Behavior Options
| Option | Description |
|---|---|
| Speak During | Show a message to the user while the API call is in progress (e.g., “Let me check that for you…”) |
| Speak After | Let the AI formulate a response using the API result |
| Payload Args Only | Send only the extracted parameters in the request body (no extra metadata) |
Testing Your API
You can test your function directly from the dashboard without creating a real conversation.Provide Test Arguments
The test panel auto-generates sample arguments based on your parameter schema. Edit them as needed.
Response safety (what your API may return)
To keep agents predictable and safe, Deflect applies guardrails to responses from your custom API before the model consumes them:- Content type — Only text and JSON responses are accepted; binary downloads (PDFs, images, executables, etc.) are blocked so the model never ingests unexpected payloads.
- Size limit — Responses are capped (with streaming where applicable) so a misbehaving endpoint cannot overwhelm the assistant or your bill.
Example use cases
- E-commerce: Check order status, track shipments, or check inventory.
- SaaS: Reset passwords, upgrade plans, or fetch usage stats.
- Booking: Check availability, book appointments, or cancel reservations.
- CRM: Look up customer profiles or update records.