Create a new AI agent with behaviors in a pipe or table
Before You Begin
- Use the GraphQL Playground.
- Authenticate with a Service Account token.
Prerequisites
- You must have admin permission on the pipe or table where you want to create the agent.
- The organization must have the AI Agents feature enabled.
- You need the pipe or table UUID. See Get Resource IDs → Pipe UUID.
Create an AI Agent
Basic example (agent without behaviors)
Inputs
- agent.name: Display name for the agent (required).
- agent.repoUuid: UUID of the pipe or table the agent belongs to (required).
- agent.instruction: Agent-level system instruction (optional). Applies to all behaviors unless overridden at the behavior level.
- agent.dataSourceIds: IDs of knowledge bases the agent can query for additional context (optional). See Knowledge Bases.
- agent.disabledAt: Pass
nullto create the agent as enabled. If omitted, the agent is created in a disabled state.
mutation {
createAiAgent(input: {
agent: {
name: "Customer Support Agent"
repoUuid: "1cc2bce3-1ea3-4af0-8fe9-0b899c73ae84"
instruction: "You help customers with their inquiries. Be concise and accurate."
dataSourceIds: ["93779687-19d5-42dd-8b8a-e8b75e1c12dd"]
disabledAt: null
}
}) {
agent {
uuid
name
instruction
repoUuid
dataSourceIds
disabledAt
}
}
}
Response:
{
"data": {
"createAiAgent": {
"agent": {
"uuid": "bfcf25c0-afcf-40db-8a63-04094620c1e8",
"name": "Customer Support Agent",
"instruction": "You help customers with their inquiries. Be concise and accurate.",
"repoUuid": "1cc2bce3-1ea3-4af0-8fe9-0b899c73ae84",
"dataSourceIds": ["93779687-19d5-42dd-8b8a-e8b75e1c12dd"],
"disabledAt": null
}
}
}
}
Response explained
- agent.uuid: Unique identifier for the created agent.
- agent.name / instruction: Echoed from input.
- agent.repoUuid: UUID of the pipe or table.
- agent.dataSourceIds: Knowledge base IDs configured for this agent.
- agent.disabledAt:
nullmeans the agent is active; a timestamp means it is disabled.
Behaviors
Behaviors define when an AI agent acts and what it does. Each behavior is an automation-like object: it has a trigger event and an AI instruction that can reference card fields and call specific actions. The actionId for all behaviors is always "ai_behavior".
Behavior input structure
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the behavior. |
actionId | string | Yes | Always "ai_behavior". |
eventId | string | Yes | Trigger event ID. Same values as regular automations (e.g., "card_moved", "card_created"). |
active | boolean | No | Whether the behavior is enabled. Defaults to true. |
eventParams | object | No | Event configuration. Same structure as regular automation event params. See Event params. |
condition | object | No | Condition filter. Same structure as regular automations. Pass { expressions_structure: [], expressions: [] } for no filter. |
actionParams | object | Yes | Must contain aiBehaviorParams. See below. |
Note: Behaviors inherit the agent's
repoUuidas both the event and action repo. You do not need to specifyevent_repo_idoraction_repo_id.
actionParams.aiBehaviorParams
| Field | Type | Required | Description |
|---|---|---|---|
instruction | string | Yes | The AI prompt for this behavior. Supports field and action references — see Instruction syntax. |
referencedFieldIds | array of strings | No | IDs or slugs of fields referenced in the instruction via %{field:...}. Tells the agent which fields to read. |
dataSourceIds | array of strings | No | Knowledge base IDs for this specific behavior. Overrides the agent-level dataSourceIds. |
providerId | string | No | AI provider ID. |
actionsAttributes | array of objects | Yes | Actions the AI will execute. At least one action is required, and each action must be referenced in the instruction via %{action:UUID}. See Behavior actions. |
capabilitiesAttributes | array of objects | No | Optional capabilities for this behavior. See Capabilities. |
Instruction syntax
The instruction string supports two types of references:
Field references — %{field:FIELD_ID_OR_SLUG} — reads the value of a card field or attribute when the behavior runs:
%{field:413928300}— reads a pipe field by its internal ID%{field:all_comments}— reads a card attribute by its slug (e.g., all comments on the card)- See Automation Actions Parameters → Card Attributes for all available slugs
List each field ID or slug used in the instruction in referencedFieldIds as well.
Action references — %{action:REFERENCE_ID} — tells the AI to execute a specific action from actionsAttributes:
%{action:88eb26bc-c838-41a7-a8f7-4f6c3df337a4}— calls the action whosereferenceIdmatches this UUID- You can reference multiple actions in the same instruction
- The
referenceIdin each action entry is the UUID you define and use here
Event params
Behavior eventParams follow the exact same structure as regular automation events. See Automation Events Parameters for the full reference.
Conditions
The optional condition field works identically to automation conditions. Pass { expressions: [], expressions_structure: [] } for no filter. See Conditions for the full reference.
Behavior actions
Each entry in actionsAttributes defines one action the AI can perform. The actionType determines what the agent does and which metadata fields apply.
| Field | Type | Required | Description |
|---|---|---|---|
actionType | string | Yes | Action to perform. Supported values: "move_card", "update_card", "create_card", "create_connected_card", "create_table_record", "send_email_template". |
name | string | Yes | Display name for this action. |
referenceId | string | Yes | UUID you assign to this action. Must be a valid UUID format (e.g., "88eb26bc-c838-41a7-a8f7-4f6c3df337a4") and unique within the behavior. Used in %{action:UUID} instruction references. |
id | string | No | Existing action UUID (for update operations only). |
metadata | object | No | Action-specific configuration. See AI Behavior Actions for the full reference. |
Capabilities
Optional capabilities that can be enabled per behavior:
capabilityType | Description |
|---|---|
advanced_ocr | Document understanding (OCR) |
web_search | Ability to search the web |
web_scraping | Ability to scrape web pages |
math_operations | Numeric and mathematical reasoning |
capabilitiesAttributes: [
{ capabilityType: web_search, enabled: true }
]
capabilityTypeis a GraphQL enum — pass the value unquoted (e.g.,web_search, not"web_search").
Knowledge Bases
dataSourceIds accepts UUIDs of knowledge base data sources that provide additional context to the agent. Data sources can be configured at the agent level (applies to all behaviors) or at the behavior level (overrides the agent-level setting for that behavior).
Note: Mutations and queries to manage knowledge base data sources will be documented in a future update.
Create an agent with behaviors
mutation {
createAiAgent(input: {
agent: {
name: "Comments Summary Agent"
repoUuid: "1cc2bce3-1ea3-4af0-8fe9-0b899c73ae84"
instruction: "Summarize card comments and update fields."
dataSourceIds: ["93779687-19d5-42dd-8b8a-e8b75e1c12dd"]
disabledAt: null
behaviors: [
{
name: "Summarize comments when card moves"
actionId: "ai_behavior"
eventId: "card_moved"
active: true
eventParams: {
to_phase_id: "338796240"
}
condition: {
expressions_structure: []
expressions: []
}
actionParams: {
aiBehaviorParams: {
instruction: "Read the field %{field:all_comments} and update the card with the summary of those comments, executing the action %{action:63637099-d172-4196-b46a-1864ed61e685} and executing the action %{action:88eb26bc-c838-41a7-a8f7-4f6c3df337a4}"
referencedFieldIds: ["all_comments"]
dataSourceIds: ["93779687-19d5-42dd-8b8a-e8b75e1c12dd"]
actionsAttributes: [
{
name: "Move card"
actionType: "move_card"
referenceId: "88eb26bc-c838-41a7-a8f7-4f6c3df337a4"
metadata: {
destinationPhaseId: "338796241"
pipeId: "306422123"
fieldsAttributes: []
}
},
{
name: "Update card fields"
actionType: "update_card"
referenceId: "63637099-d172-4196-b46a-1864ed61e685"
metadata: {
pipeId: "306422123"
fieldsAttributes: [
{
fieldId: "421679209"
inputMode: "fill_with_ai"
value: ""
}
]
}
}
]
}
}
}
]
}
}) {
agent {
uuid
name
instruction
repoUuid
disabledAt
behaviors {
id
name
active
event_id
action_id
}
}
}
}
Error handling
{
"data": {
"createAiAgent": null
},
"errors": [
{
"message": "Record Not Saved - Validation failed: Name can't be blank",
"locations": [{ "line": 2, "column": 3 }],
"path": ["createAiAgent"]
}
]
}
- data.createAiAgent: Returns
nullwhen the operation fails. - errors[].message: Human-readable error description including validation details.
Tips
- Pass
disabledAt: nullto create an enabled agent. If omitted, the agent is created disabled. - Behaviors inherit the agent's
repoUuidas their repo — no need to specifyevent_repo_idoraction_repo_id. - Each action's
referenceIdis a UUID you choose. Use it in the instruction via%{action:UUID}to tell the AI when to call that action. - List every field ID or slug used in the instruction in
referencedFieldIdsas well. dataSourceIdson a behavior overrides the agent-leveldataSourceIdsfor that specific behavior.
