AI Agent Management
Custom actions: connect your AI agent to any API
Call your own API, run code in the browser, or show an interactive widget, all from inside the conversation
Custom actions connect your QwryAI agent to anything you can reach over an HTTPS API. The agent calls your endpoint, gets the JSON response back, and uses that data in its reply, so it can answer questions and do tasks that live in your own systems. A Custom action can also run code in the customer's browser or show an interactive widget in the chat.
Best for: anything QwryAI doesn't have a built-in Action for: looking up records in your own systems, triggering a workflow, or showing a custom interface in the chat.
Common use cases:
- "Do you deliver to my postcode?"
- "What's the status of my booking?"
- "Look up my account balance"
Action types
When you create a Custom action, you pick a type that sets how it behaves:
| Type | What it does | Channels |
|---|---|---|
| Call API | Calls your API and gives the response to the agent, which uses it in its reply. | Every channel, including WhatsApp, Messenger, Instagram, Email, Slack, API and Phone |
| Run client-side code | Runs custom code on the client, through the website embed or the mobile SDKs. Tick Wait for response to have the agent wait for the result. | Chat bubble, Help page, Center Stage, Android SDK, iOS SDK |
| Call API + show widget | Calls your API and shows the results in a widget in the chat. | Chat bubble, Help page, Center Stage |
| Show widget | Shows a widget with fixed data or with data from the conversation, without calling an API. | Chat bubble, Help page, Center Stage |
How to create the Action
- Open Actions
In your QwryAI dashboard, select your agent and click Build › Actions in the sidebar.
- Create the Action
Click Create Action, then the Custom actions card, and Start customizing. Create Custom Action opens with its sections: General, Action type, API, Test response, Data access and Channels.
The Custom actions dialog. - Configure General
See General, then click Continue.
- Pick the Action type
Call API is selected by default, so Continue in General takes you straight to API. To use another type, open Action type and select it.
- Configure the API
Add the data inputs the agent collects and the request it sends. See API, then click Continue.
- Test the response
Check that the endpoint returns what you expect. See Test response, then click Continue.
- Set Data access
Choose how much of the response the agent can see. See Data access, then click Continue.
- Choose Channels and save
Turn the Action on or off for each configured channel, then click Save. The Action is saved to your agent's draft; click Publish in the top-right corner to make it live for customers. See Drafts and publishing.
General
Action name: a descriptive name, such as Get_Order_Status. The agent sees this name, so it helps it know when to use the Action. Names need 3 to 63 characters and can contain only letters, numbers, underscores and hyphens, with no spaces.
When to use: a detailed description of when the agent should use this Action. Include the data it provides and example customer questions it helps answer.
When not to use (optional): cases where the agent should leave the Action alone, such as Don't use this for delivery times or shipping costs.
To run the Action only as a Procedure step, turn on Only use in Procedures. When to use is then hidden.
API
Collect data inputs for action
The information the agent needs to perform the Action. The agent can find it in the chat history, ask the customer for it, or take it from the customer's details if they're available. Click Add data input for each one:
- Name: the input's name. Use it in the request as
{{name}}. - Type: text, number, boolean, date or email.
- Description: a short sentence that tells the agent what to ask for.
- Array: tick it to accept a list of values instead of one.
API request
The endpoint the agent calls to get data or send updates. You can use the data inputs in the URL or the request body.
- Method:
GET,POST,PUT,PATCHorDELETE. - HTTPS URL: the URL of your API.
- Add Variable: inserts a variable. See Variables.
Below the URL, tabs hold the request's Parameters, Headers and Body. Use Add key value pair to add a parameter or header. The body must be JSON.
Variables
Add Variable lists four groups. You can use them in the URL, Parameters, Headers and Body:
| Group | Variables |
|---|---|
| Input Variables | Your data inputs, by Name, such as {{postcode}} |
| Static Variables | {{conversationId}}, the current conversation; {{userId}}, for identified users; {{callerPhone}}, the caller's number on phone calls |
| Contact Data | {{contact.id}}, {{contact.external_id}}, {{contact.email}}, {{contact.name}}, {{contact.phonenumber}}, {{contact.stripe_accounts}}, {{contact.created_at}}, {{contact.updated_at}} |
| Attributes | The current contact's or conversation's attribute value, sent without asking the customer |
For example, a Get_Order_Status Action could call https://api.example.com/orders/{{orderNumber}}?email={{contact.email}}, where orderNumber is a data input the agent asks the customer for.
Authentication
Authenticate with static Headers or Parameters, such as Authorization: Bearer <your API key> or x-api-key: <your API key>.
Test response
Pick how to test, then click Continue:
- Live response: test with live data from the API to make sure it's set up correctly. Enter a test value for each input and click Test response.
- Example response: paste example JSON if the API isn't ready yet.
Data access
- Full data access: the agent can use everything in the response, for complete replies.
- Limited data access: the agent sees only the fields you pick, for more controlled replies that protect sensitive data. A table lists every field in the test response with its size; tick the fields the agent may see. The selected response size is shown against the 20 KB limit.
Example: check a delivery area
A Check_delivery_area Action that tells customers which suburbs a postcode covers, using the free Zippopotam postcode API.
- General: named
Check_delivery_area, with a When to use that covers questions about delivery areas and postcodes. - Action type: Call API.
- API: one data input,
postcode, of type text, described as the customer's 4-digit Australian postcode. The request isGET https://api.zippopotam.us/au/{{postcode}}. - Test response: Live response with
2000as the postcode returns the Sydney suburbs. - Data access: Full data access.
Now the agent can answer delivery-area questions:
How the AI agent handles the response
- Success: the response, filtered by Data access, goes to the agent, which writes its reply from it.
- Not JSON: a successful response that isn't JSON is passed to the agent as an error.
- Too large: if the response is over 20 KB, the agent gets "Response is too large. Please limit the number of fields returned."
- Error or no answer: the agent gets an error and writes its own reply. Failed requests aren't retried.
The agent doesn't ask the customer to confirm before it calls the Action. For Actions that change data, such as cancelling a booking, tell it in When to use to confirm the details with the customer first.
Limitations
- The maximum response size is 20 KB. Use Limited data access or return fewer fields to stay under it.
- Requests and responses must be JSON.
- No retries. A failed request isn't sent again.
- Static authentication only. Headers and parameters only, with no OAuth or token refresh.
- Client-side and widget types work on fewer channels. Run client-side code works on the Chat bubble, Help page, Center Stage and the mobile SDKs. Call API + show widget and Show widget work on the Chat bubble, Help page and Center Stage.
Best practices
Clear Action triggers
Name the data this Action provides and the questions it answers in When to use.
Describe every input
The description is how the agent decides what to ask for. Vague descriptions produce wrong values.
Limit data access
Use Limited data access when the response holds anything the agent shouldn't repeat.
Keep responses small
Return only the fields the agent needs to stay under 20 KB and keep replies accurate.
Frequently asked questions
How do I authenticate a Custom action with my API?
Add your API key or token as a static header, for example Authorization: Bearer <your API key>, or as a parameter. OAuth flows and token refresh aren't supported.
Can I pass the customer's email or the conversation ID to my API?
Yes. Use {{contact.email}}, {{conversationId}} and the other variables in the URL, parameters, headers or body.
What happens when my API returns an error?
The agent gets an error instead of data and writes its own reply to the customer. The request isn't retried.
Can a Custom action run on WhatsApp, email or phone calls?
Only the Call API type. The other types need the Chat bubble, Help page or Center Stage, and Run client-side code also runs in the mobile SDKs.
Does the AI agent ask the customer before calling the API?
No. It calls the Action as soon as it decides to. To require a confirmation, for example before a refund, say so in When to use.
My response is over 20 KB. What can I do?
Switch to Limited data access and tick only the fields the agent needs, or return fewer fields from your endpoint.