Add Autotask Special Operation
Use this skill when
- •Adding a new non-CRUD operation to an existing resource (e.g.
slaHealthCheckon tickets,searchByDomainon companies,whoAmIon resources) - •The operation needs to be exposed as an AI tool in
AutotaskAiTools.node.ts - •The operation has custom parameters, logic, or output formatting that differs from standard get/getMany/create/update/delete/count
Do NOT use this skill when
- •Adding a new standard CRUD entity or child entity — use the
add-autotask-child-entityskill instead - •The operation follows the standard CRUD pattern and is auto-derived from entity metadata
End-to-end workflow
Phase 1: Resource-level implementation
- •
Add operation to resource
description.ts- •Add the operation to the
operationOptionsarray - •Add any new input fields (with appropriate
displayOptions) - •If the operation reuses existing fields (e.g.
id), update theirdisplayOptions.show.operationarrays
- •Add the operation to the
- •
Implement logic in resource
execute.ts- •Add a
casefor the new operation in the execute function's switch - •Implement the business logic (API calls, data transformation, etc.)
- •Use
processOutputModeif the operation should support picklist/reference label enrichment
- •Add a
- •
Update picklist/reference label visibility (if applicable)
- •
operations/common/picklist-labels/description.ts— add operation to theoperationarray indisplayOptions.show - •
operations/common/reference-labels/description.ts— same
- •
Phase 2: AI Tools layer (critical — 10 touchpoints)
Read the full checklist at: .docs/autotask/change-guidelines/ai-tools-special-operation-checklist.md
The summary of mandatory steps is:
| # | File | What to add |
|---|---|---|
| 1 | constants/resource-operations.ts | Entry in SPECIAL_AI_OPERATIONS |
| 2 | constants/resource-operations.ts | Entry in AI_OPERATION_ORDER |
| 3 | AutotaskAiTools.node.ts | Entry in SUPPORTED_TOOL_OPERATIONS |
| 4 | AutotaskAiTools.node.ts | Entry in WRITE_OPERATIONS if operation mutates data |
| 5 | AutotaskAiTools.node.ts | Entry in opLabels |
| 6 | ai-tools/schema-generator.ts | Zod schema generator function |
| 7 | ai-tools/description-builders.ts | Description builder function |
| 8 | AutotaskAiTools.node.ts | case in supplyData() switch + imports |
| 9 | ai-tools/tool-executor.ts | case in normaliseOperation() |
| 10 | ai-tools/tool-executor.ts | getNodeParameter overrides (if needed) |
| 11 | ai-tools/tool-executor.ts | case in formatToolResponse() |
| 12 | ai-tools/field-validator.ts | Add to noIdOperations (if op doesn't require entity ID) |
Phase 3: Shared executor and tool resource
- •Wire in
resources/tool/execute.ts(if the operation has custom parameter routing)- •Add parameter mapping in the
getNodeParameteroverride withinexecuteToolOperation - •Map AI tool flat parameters to the internal parameter names expected by the resource executor
- •Add parameter mapping in the
Phase 4: Documentation
- •Update
CHANGELOG.md— add anAddedentry under the current version - •Update
README.md— add the operation to the features/operations list
Phase 5: Validation
- •Run
corepack pnpm build— must compile clean - •Run
corepack pnpm lint— no new errors in changed files - •Run manual audit against the full checklist in
.docs/autotask/change-guidelines/ai-tools-special-operation-checklist.md
Critical hazards
normaliseOperation() — the silent killer
File: ai-tools/tool-executor.ts
This function lowercases its input and then uses a switch to restore camelCase for known operations. If a new camelCase operation is not added here, it stays lowercase (e.g. slahealthcheck instead of slaHealthCheck). This compiles and lints clean but silently breaks every runtime comparison:
- •
noIdOperations.includes()fails (case-sensitive) - •
effectiveOperation === 'slaHealthCheck'fails in getNodeParameter overrides - •
case 'slaHealthCheck'fails in formatToolResponse - •Net effect: the operation is completely non-functional for AI tools
Rule: Any operation name containing uppercase letters must have an explicit case in normaliseOperation. Single-word lowercase names (get, count, create, update, delete) don't need one.
Zod schema — no .refine() on the return
Schema generator functions must return z.ZodObject<Record<string, z.ZodTypeAny>>. Using .refine(), .transform(), or .superRefine() produces ZodEffects which is not assignable to ZodObject — this causes a TypeScript compilation error. Put cross-field validation in the execute function instead.
getNodeParameter throws in shared code
Any shared helper code accessing parameters only injected by the AI tool executor must use try/catch, not just a fallback value. Newer n8n versions throw even with a fallback when the parameter name is absent from the node schema.
WRITE_OPERATIONS safety gate omissions
SUPPORTED_TOOL_OPERATIONS controls visibility, but allowWriteOperations is enforced by WRITE_OPERATIONS. If a mutating special operation is omitted from WRITE_OPERATIONS, it can still be invoked while write operations are disabled.
Rule: Add all mutating special operations (clone/move/upload/orchestrated copy) to WRITE_OPERATIONS.
Quality gates
- • Resource
description.ts— operation added to dropdown, new fields defined - • Resource
execute.ts— operation implemented, case added to switch - • Picklist/reference label descriptions — operation added (if applicable)
- •
SPECIAL_AI_OPERATIONS— operation registered for the resource - •
AI_OPERATION_ORDER— operation in logical position - •
SUPPORTED_TOOL_OPERATIONS— operation listed - •
WRITE_OPERATIONS— operation listed if operation mutates data - •
opLabels— human-readable label added - • Schema generator — function exported, returns
ZodObject(no refine/transform) - • Description builder — function exported
- •
supplyData()switch — case added with schema + description + imports - •
normaliseOperation()— case added for lowercase → camelCase restoration - •
getNodeParameteroverride — custom parameter mapping added (if needed) - •
formatToolResponse()— case added for structured output - •
noIdOperations— operation added (if it doesn't require entity ID) - •
tool/execute.ts— parameter mapping added (if needed) - • Impersonation (move/copy ops): If the operation creates records and the entity supports impersonation, follow
.docs/autotask/impersonation.md— add optionalimpersonationResourceIdto the UI, schema, and description builder. UsegetOptionalImpersonationResourceIdin the executor. Only pass to write calls. Always pair withproceedWithoutImpersonationIfDenied(boolean, defaulttrue) in the same display context. Both must appear in the UI description, execute handler, helper interface/options, AI schema, and be passed as the 7th argument to everyautotaskApiRequestwrite call. - • For multi-step orchestrator operations, add retry/throttling/partial-failure handling and audit notes
- •
README.mdandCHANGELOG.md— updated - •
corepack pnpm build— compiles clean - •
corepack pnpm lint— no new errors in changed files
Reference implementations
- •
slaHealthCheck(ticket resource): Custom operation with dual identifier input (ticket ID or ticket number), custom SLA computation logic, label enrichment - •
searchByDomain(company resource): Custom operation with domain normalisation, contact email fallback search, structured multi-source output - •
whoAmI(resource): Simple operation that resolves the current authenticated user, reuses read field schema
Existing files quick-reference
| Concern | File path |
|---|---|
| Special operation registry | nodes/Autotask/constants/resource-operations.ts |
| AI tools node | nodes/Autotask/AutotaskAiTools.node.ts |
| Zod schemas | nodes/Autotask/ai-tools/schema-generator.ts |
| LLM descriptions | nodes/Autotask/ai-tools/description-builders.ts |
| Tool executor + normalise + format | nodes/Autotask/ai-tools/tool-executor.ts |
| ID validator | nodes/Autotask/ai-tools/field-validator.ts |
| Shared executor backbone | nodes/Autotask/resources/tool/execute.ts |
| Impersonation guide | .docs/autotask/impersonation.md |