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:
Parameters are defined as a JSON Schema object. You can use the JSON editor to define complex nested structures.
5. Behavior Options
Testing Your API
You can test your function directly from the dashboard without creating a real conversation.1
Open the Function
Click on the function you want to test, or create a new one.
2
Open the Test Panel
Click the Test button at the bottom of the function modal.
3
Provide Test Arguments
The test panel auto-generates sample arguments based on your parameter schema. Edit them as needed.
4
Run the Test
Click Send Test Request. The panel will show:
- Status Code — HTTP response code.
- Response Body — The JSON response from your API.
- Duration — How long the request took.
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.