n8n-nodes-autotask 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/README.md +715 -715
  2. package/dist/nodes/Autotask/Autotask.node.js +2 -2
  3. package/dist/nodes/Autotask/Autotask.node.js.map +1 -1
  4. package/dist/nodes/Autotask/operations/base/field-processor.js +7 -0
  5. package/dist/nodes/Autotask/operations/base/field-processor.js.map +1 -1
  6. package/dist/nodes/Autotask/operations/base/field-values.js +8 -0
  7. package/dist/nodes/Autotask/operations/base/field-values.js.map +1 -1
  8. package/dist/nodes/Autotask/resources/contractExclusionSets/description.js.map +1 -0
  9. package/dist/nodes/Autotask/resources/contractExclusionSets/execute.js.map +1 -0
  10. package/dist/nodes/Autotask/resources/contractExclusionSets/index.js.map +1 -0
  11. package/dist/nodes/Autotask/resources/tool/execute.js +1 -1
  12. package/dist/nodes/Autotask/resources/tool/execute.js.map +1 -1
  13. package/dist/package.json +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/package.json +11 -13
  16. package/dist/nodes/Autotask/resources/contract-exclusion-sets/description.js.map +0 -1
  17. package/dist/nodes/Autotask/resources/contract-exclusion-sets/execute.js.map +0 -1
  18. package/dist/nodes/Autotask/resources/contract-exclusion-sets/index.js.map +0 -1
  19. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/description.d.ts +0 -0
  20. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/description.js +0 -0
  21. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/execute.d.ts +0 -0
  22. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/execute.js +0 -0
  23. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/index.d.ts +0 -0
  24. /package/dist/nodes/Autotask/resources/{contract-exclusion-sets → contractExclusionSets}/index.js +0 -0
package/README.md CHANGED
@@ -1,715 +1,715 @@
1
- # n8n-nodes-autotask
2
-
3
- ![n8n-nodes-autotask](https://img.shields.io/badge/n8n--nodes--autotask-1.2.0-blue)
4
- ![License](https://img.shields.io/badge/license-MIT-green)
5
-
6
- [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
7
-
8
- > **IMPORTANT**: After updating this node to a new version, a restart of your n8n instance is highly recommended to ensure all changes are properly applied.
9
-
10
- This is an n8n community node for integrating with Autotask PSA. It provides a comprehensive set of operations to interact with Autotask entities through their REST API.
11
-
12
- ![Overview of n8n-nodes-autotask](./overview.gif)
13
-
14
- [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
15
-
16
- [Installation](#installation)
17
- [Authentication](#authentication)
18
- [Features](#features)
19
- [Usage](#usage)
20
- [Configuration](#configuration)
21
- [Limitations](#limitations)
22
- [Troubleshooting](#troubleshooting)
23
- [Resources](#resources)
24
- [Support](#support)
25
- [License](#license)
26
-
27
- ## Installation
28
-
29
- Follow these steps to install this node:
30
-
31
- ```bash
32
- # Install with npm
33
- npm install n8n-nodes-autotask
34
-
35
- # Install with pnpm
36
- pnpm install n8n-nodes-autotask
37
- ```
38
-
39
- **Requirements:**
40
- - n8n version 1.0.0 or later
41
- - Node.js version 18.10 or later
42
- - pnpm version 9.1 or later (if using pnpm)
43
-
44
- ## Authentication
45
-
46
- To use this node, you need to have API access to your Autotask instance. Follow these steps to set up authentication:
47
-
48
- 1. In Autotask, go to **Admin > API User Security**
49
- 2. Create or select an API user
50
- 3. Note the API Integration Code, Username, and Secret
51
- 4. In n8n, create a new credential of type **Autotask API**
52
- 5. Enter your API Integration Code, Username, and Secret
53
- 6. Select your Autotask zone
54
- 7. Select your timezone (affects how dates and times are displayed and entered)
55
- 8. Configure caching options as needed (this will cache dynamically fetched field picklists)
56
-
57
- ## Features
58
-
59
- ### Supported Resources
60
-
61
- The node supports the following Autotask resources:
62
-
63
- | Resource | Description |
64
- |----------|-------------|
65
- | API Threshold | Check Autotask API usage limits and current usage levels |
66
- | Billing Code | Manage billing codes for time entries and charges |
67
- | Billing Items | Manage Autotask Billing Items, which represent billable items that have been approved and posted for potential invoicing |
68
- | Company | Manage organisations in Autotask |
69
- | Company Alert | Manage alerts associated with companies |
70
- | Company Location | Manage locations for companies |
71
- | Company Note | Manage notes attached to companies |
72
- | Company Site Configuration | Manage company site configurations and user-defined fields for customer companies |
73
- | Company Webhook | Manage webhooks for company events |
74
- | Configuration Item | Manage configuration items (CIs) for companies |
75
- | Configuration Item Billing Product Association | Manage product associations for configuration items |
76
- | Configuration Item Category | Manage categories for configuration items |
77
- | Configuration Item Category UDF Association | Manage UDF associations for CI categories |
78
- | Configuration Item DNS Record | Manage DNS records for configuration items |
79
- | Configuration Item Note | Manage notes for configuration items |
80
- | Configuration Item Related Item | Manage related items for configuration items |
81
- | Configuration Item SSL Subject Alternative Name | Manage SSL alternative names for configuration items |
82
- | Configuration Item Type | Manage types for configuration items |
83
- | Configuration Item Webhook | Manage webhooks for configuration item events |
84
- | Contact | Manage contacts associated with companies |
85
- | Contact Groups | Manage contact groups |
86
- | Contact Group Contacts | Manage contacts within contact groups |
87
- | Contact Webhook | Manage webhooks for contact events |
88
- | Contract | Manage contracts for companies |
89
- | Contract Billing Rules | Manage billing rules for contracts |
90
- | Contract Block | Manage block hour contracts |
91
- | Contract Block Hour Factor | Manage hour factors for block hour contracts |
92
- | Contract Charge | Manage charges associated with contracts |
93
- | Contract Exclusion Billing Codes | Manage excluded billing codes for contracts |
94
- | Contract Exclusion Roles | Manage excluded roles for contracts |
95
- | Contract Exclusion Set Excluded Roles | Manage excluded roles within exclusion sets |
96
- | Contract Exclusion Set Excluded Work Types | Manage excluded work types within exclusion sets |
97
- | Contract Exclusion Sets | Manage exclusion sets for contracts |
98
- | Contract Milestone | Manage milestones for contracts |
99
- | Contract Note | Manage notes attached to contracts |
100
- | Contract Rate | Manage rates for contract services |
101
- | Contract Retainers | Manage retainers for contracts |
102
- | Contract Role Costs | Manage role costs for contracts |
103
- | Contract Service | Manage services within contracts |
104
- | Contract Service Adjustments | Manage adjustments for contract services |
105
- | Contract Service Bundle Adjustments | Manage adjustments for service bundles |
106
- | Contract Service Bundles | Manage service bundles within contracts |
107
- | Contract Service Bundle Units | Manage service bundle units |
108
- | Contract Service Unit | Manage service units for contracts |
109
- | Contract Ticket Purchases | Manage ticket purchases for contracts |
110
- | Countries | Query countries, which are used in address information for companies, contacts, and resources |
111
- | Domain Registrars | Manage domain registrars |
112
- | Holiday | Manage holiday dates |
113
- | Holiday Set | Manage holiday sets for resources |
114
- | Invoices | Manage invoices |
115
- | Notification History | View notification history |
116
- | Opportunity | Manage sales opportunities |
117
- | Product | Manage products in the catalogue |
118
- | Product Vendors | Manage vendor associations for products |
119
- | Project | Manage projects |
120
- | Project Charge | Manage charges associated with projects |
121
- | Project Note | Manage notes attached to projects |
122
- | Project Phase | Manage phases within projects |
123
- | Project Task | Manage tasks within projects |
124
- | Quote | Manage quotes for opportunities with pricing for products, services, and labor |
125
- | Quote Item | Manage line items for quotes including products, services, and labor |
126
- | Quote Location | Manage shipping and billing address information for quotes |
127
- | Quote Template | Query quote templates that define content and appearance of quotes |
128
- | Resource | Manage staff resources |
129
- | Resource Role | Manage department/role relationships, service desk queues, and service desk roles |
130
- | Roles | Manage roles in the system |
131
- | Search Filter | Build advanced search filters |
132
- | Service | Manage services offered to clients |
133
- | Service Call | Manage service calls |
134
- | Service Call Task | Manage tasks associated with service calls |
135
- | Service Call Task Resource | Manage resources assigned to service call tasks |
136
- | Service Call Ticket | Manage tickets linked to service calls |
137
- | Service Call Ticket Resource | Manage resources assigned to service call tickets |
138
- | Survey | Manage customer surveys |
139
- | Survey Results | Manage results from customer surveys |
140
- | Subscription | Manage Subscriptions, which represent recurring service agreements with customers |
141
- | Subscription Period | Query Subscription Periods, which track billing periods and usage for subscriptions |
142
- | Ticket | Manage service tickets |
143
- | Ticket History | View historical changes to tickets |
144
- | Ticket Note | Manage notes attached to tickets |
145
- | Ticket Note Webhook | Manage webhooks for ticket note events |
146
- | Ticket Webhook | Manage webhooks for ticket events |
147
- | Time Entry | Manage time entries for billing |
148
-
149
- ### Operations
150
-
151
- For most resources, the following operations are available:
152
-
153
- - **Create**: Add new records
154
- - **Read**: Retrieve a single record by ID
155
- - **Update**: Modify existing records
156
- - **Delete**: Remove records
157
- - **Get Many**: Retrieve multiple records with basic filtering options. This operation allows you to:
158
- - Filter records using simple field conditions (equals)
159
- - Filtering on User Defined Fields (UDFs)
160
- - Automatically paginate through large result sets
161
- - Choose to get all results or limit to a specific number (1-500)
162
- - Set a maximum number of records to return when not retrieving all records
163
- - Select specific columns to return in the response
164
- - Add human-readable labels for picklist and reference fields
165
- - Flatten User-Defined Fields for easier access in workflows
166
- - **Get Many Advanced**: Build complex queries with multiple filter conditions and logical operators. This operation provides:
167
- - Support for complex AND/OR logic in filters
168
- - Nested condition groups for sophisticated queries
169
- - Filtering on User Defined Fields (UDFs)
170
- - Advanced operators like contains, beginsWith, endsWith, exists, notExists
171
- - Support for IN and NOT IN operators with multiple values
172
- - Choose to get all results or limit to a specific number (1-500)
173
- - Set a maximum number of records to return when not retrieving all records
174
- - Select specific columns to return in the response
175
- - Add human-readable labels for picklist and reference fields
176
- - Flatten User-Defined Fields for easier access in workflows
177
- - Date-based filtering with automatic timezone handling
178
- - **Count**: Get the number of matching records
179
- - **Get Entity Info**: Retrieve metadata about the entity
180
- - **Get Field Info**: Retrieve field definitions for the selected entity
181
-
182
- For webhook resources (Company Webhook, Contact Webhook, Configuration Item Webhook, Ticket Webhook, Ticket Note Webhook), the following operations are available:
183
- - **Get**: Retrieve a single webhook by ID
184
- - **Get Many**: Retrieve multiple webhooks with basic filtering
185
- - **Delete**: Remove a webhook
186
-
187
- ### Webhook Trigger
188
-
189
- The node includes an Autotask Trigger node that can receive webhook events from Autotask. The trigger supports:
190
-
191
- - Events for multiple entity types (Companies, Contacts, Tickets, Configuration Items, Ticket Notes)
192
- - Create, Update, and Delete events
193
- - Field selection for webhook payloads (specify which fields to include)
194
- - Resource exclusion (exclude specific resources from triggering the workflow)
195
- - Email notifications for webhook delivery failures
196
- - Threshold notifications for monitoring webhook performance
197
- - Automatic webhook registration and cleanup
198
- - Secure payload verification with HMAC signatures
199
-
200
- ### Advanced Features
201
-
202
- - **Resource Mapping**: Dynamically map fields based on entity definitions
203
- - **Advanced Filtering**: Build complex queries with multiple conditions
204
- - **Column Selection**: Choose specific fields to return in get operations
205
- - **Picklist Label Enrichment**: Automatically add human-readable labels for picklist fields
206
- - **Reference Label Enrichment**: Add human-readable labels for reference fields
207
- - **UDF Flattening**: Bring user-defined fields up to the top level of response objects for easier access
208
- - **File-based Caching**: Improved performance with persistent caching that can be shared between workflows and runs
209
- - **Timezone Handling**: Automatic conversion between local time and UTC
210
- - **API Usage Monitoring**: Check current API usage thresholds and limits using the API Threshold resource to help prevent hitting rate limits and ensure smooth operations
211
-
212
- ### API Threshold Resource
213
-
214
- The API Threshold resource provides a simple way to monitor your Autotask API usage limits and current consumption. This helps users:
215
- - Track how many API requests have been made in the current timeframe
216
- - See the maximum allowed requests (threshold limit)
217
- - View the usage as a percentage and categorized level (Normal, Moderate, High, Critical)
218
- - Calculate remaining available requests
219
- - Monitor timeframe duration for rate limits
220
-
221
- This is particularly useful for workflows that make many API calls, allowing you to implement conditional logic based on current usage levels to avoid hitting rate limits and ensure continuous operation.
222
-
223
- ### AI Agent Playbook
224
-
225
- This node is optimised for AI agents and tool-calling systems with specialised features designed for autonomous operation.
226
-
227
- #### Quick Start for AI Agents
228
-
229
- **1. Introspect Resources**
230
- ```javascript
231
- // Discover available fields and requirements
232
- operation: aiHelper.describeResource
233
- params: { resource: "ticket", mode: "write" }
234
- ```
235
-
236
- **2. Prepare Data**
237
- ```javascript
238
- // Use JSON parameters for direct data input
239
- bodyJson: {
240
- "title": "API Integration Issue",
241
- "description": "Customer reporting connection problems",
242
- "priority": "Medium",
243
- "status": "New"
244
- }
245
- ```
246
-
247
- Note: You may provide labels for picklist/reference fields in `bodyJson` (e.g., `status: "New"`). They are automatically resolved to IDs pre-flight.
248
-
249
- **3. Preview First (Optional)**
250
- ```javascript
251
- // Test your request without making API calls
252
- dryRun: true
253
- ```
254
-
255
- **4. Execute with Optimal Output**
256
- ```javascript
257
- // Choose output format for token efficiency
258
- outputMode: "rawIds" // Most efficient
259
- outputMode: "idsAndLabels" // Default (balanced)
260
- outputMode: "labelsOnly" // Most readable
261
- ```
262
-
263
- #### AI Helper Operations
264
-
265
- **Introspection Endpoint:**
266
- - `aiHelper.describeResource(resource, mode)` - Get field metadata, requirements, constraints, and **entity dependencies**
267
- - `aiHelper.listPicklistValues(resource, fieldId, query, limit, page)` - Get valid values for dropdown fields
268
- - `aiHelper.validateParameters(resource, mode, fieldValues)` - **NEW:** Validate field values without API calls - pre-flight validation
269
-
270
- **Dynamic Dependency Discovery:**
271
- - **Reference fields** show what entity they link to (e.g., `companyID → company`)
272
- - **Field dependencies** reveal required relationships (e.g., `contactID requires: companyID`)
273
- - **Workflow guidance** provides creation order tips (e.g., "Ensure company exists before creating contact")
274
-
275
- **Enhanced Validation:**
276
- - **JSON Schema validation** - Immediate feedback on malformed `bodyJson`/`selectColumnsJson`
277
- - **Parameter pre-validation** - Validate field values, types, dependencies without API calls
278
- - **Structured error responses** - Detailed validation results with field-by-field feedback
279
-
280
- **JSON Parameter Fallbacks:**
281
- - `bodyJson` - Override UI mappings for write operations (create/update)
282
- - `selectColumnsJson` - Specify fields for read operations as JSON array
283
-
284
- **Agent-Friendly Features:**
285
- - `outputMode` - Control response format (rawIds/idsAndLabels/labelsOnly)
286
- - `dryRun` - Get request preview without API execution
287
- - Smart error hints with actionable suggestions
288
-
289
- #### Tool Configuration for Maximum Effectiveness
290
-
291
- For optimal AI agent integration, configure multiple instances of this node as separate tools. This provides focused, reliable access to different resource types.
292
-
293
- **Recommended Tool Setup:**
294
-
295
- ```javascript
296
- // Tool 1: Resource Discovery and Field Introspection
297
- {
298
- name: "autotask_inspector",
299
- description: "Discover Autotask resources, fields, and valid values",
300
- resource: "aiHelper",
301
- operations: ["describeResource", "listPicklistValues"]
302
- }
303
-
304
- // Tool 2: Contact Management
305
- {
306
- name: "autotask_contacts",
307
- description: "Read and write Autotask contacts and people",
308
- resource: "contact",
309
- operations: ["get", "getMany", "create", "update"],
310
- defaultParams: {
311
- outputMode: "idsAndLabels",
312
- selectColumnsJson: ["id", "firstName", "lastName", "emailAddress", "companyID", "title", "phone"]
313
- }
314
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
315
- }
316
-
317
- // Tool 3: Company/Account Management
318
- {
319
- name: "autotask_companies",
320
- description: "Read and write Autotask companies and accounts",
321
- resource: "company",
322
- operations: ["get", "getMany", "create", "update"],
323
- defaultParams: {
324
- outputMode: "idsAndLabels",
325
- selectColumnsJson: ["id", "companyName", "companyType", "phone", "address1", "city", "state"]
326
- }
327
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
328
- }
329
-
330
- // Tool 4: General Resource Access
331
- {
332
- name: "autotask_resources",
333
- description: "Access any Autotask resource with full flexibility",
334
- allResources: true,
335
- defaultParams: {
336
- outputMode: "rawIds" // Most token-efficient for exploratory queries
337
- }
338
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
339
- }
340
- ```
341
-
342
- **Usage Pattern:**
343
- 1. **Start with Inspector** - Use `autotask_inspector` to understand field requirements
344
- 2. **Use Focused Tools** - Call `autotask_contacts` or `autotask_companies` for CRM related operations
345
- 3. **Use Specialist Tools** - Use `autotask_resources` for lookups of Autotask MSP staff (resources)
346
-
347
- **Benefits:**
348
- - **Faster execution** - Pre-configured tools reduce parameter complexity
349
- - **Better reliability** - Focused tools have predictable schemas
350
- - **Token efficiency** - Default parameters optimised for each use case
351
- - **Easier debugging** - Clear separation of concerns
352
-
353
- #### Environment Setup
354
-
355
- For AI tool usage, set this environment variable:
356
-
357
- ```bash
358
- N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
359
- ```
360
-
361
- Configuration options:
362
- - Add to your `.env` file
363
- - Set in system environment variables
364
- - Include in Docker/container configuration
365
- - Add to startup command: `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true n8n start`
366
-
367
- #### Example Agent Workflow
368
-
369
- **Scenario: Create a contact for a new company**
370
-
371
- ```javascript
372
- // 1. Inspect contact requirements using dedicated tool
373
- autotask_inspector.call({
374
- operation: "describeResource",
375
- targetResource: "contact",
376
- mode: "write"
377
- })
378
- // Returns: {
379
- // fields: [
380
- // { id: "companyID", required: true, isReference: true, referencesEntity: "company" },
381
- // { id: "firstName", required: true, type: "string" },
382
- // { id: "lastName", required: true, type: "string" }
383
- // ],
384
- // notes: [
385
- // "Required fields for write: companyID, firstName, lastName",
386
- // "Reference fields (must reference existing entities): companyID → company",
387
- // "Workflow tip: Ensure referenced company exists before creating contact."
388
- // ]
389
- // }
390
-
391
- // 2. Check company picklist values if needed
392
- autotask_inspector.call({
393
- operation: "listPicklistValues",
394
- targetResource: "contact",
395
- fieldId: "companyID",
396
- query: "Tech Solutions" // Search for company
397
- })
398
-
399
- // 2.5. Validate parameters before creation (NEW!)
400
- autotask_inspector.call({
401
- operation: "validateParameters",
402
- targetResource: "contact",
403
- mode: "create",
404
- fieldValues: {
405
- "firstName": "John",
406
- "lastName": "Smith",
407
- "emailAddress": "john.smith@techsolutions.com",
408
- "companyID": 12345,
409
- "title": "IT Manager"
410
- }
411
- })
412
- // Returns: {
413
- // isValid: true,
414
- // errors: [],
415
- // warnings: [
416
- // { field: "companyID", message: "Reference field 'companyID' points to company. Ensure the referenced record exists.", code: "REFERENCE_EXISTENCE_CHECK" }
417
- // ],
418
- // summary: { totalFields: 15, providedFields: 5, validFields: 5, requiredFieldsMissing: 0, invalidValues: 0 }
419
- // }
420
-
421
- // 3. Create contact using focused tool
422
- autotask_contacts.call({
423
- operation: "create",
424
- bodyJson: {
425
- "firstName": "John",
426
- "lastName": "Smith",
427
- "emailAddress": "john.smith@techsolutions.com",
428
- "companyID": 12345,
429
- "title": "IT Manager"
430
- },
431
- dryRun: true // Preview first
432
- })
433
- // Dry-run response includes a `resolutions` array when labels were resolved to IDs, e.g.:
434
- // resolutions: [{ field: 'status', from: 'New', to: 1, method: 'picklist' }]
435
-
436
- // 4. Execute after validation
437
- autotask_contacts.call({
438
- operation: "create",
439
- bodyJson: { /* same data */ },
440
- outputMode: "idsAndLabels"
441
- })
442
-
443
- // 5. Retrieve company details using focused tool
444
- autotask_companies.call({
445
- operation: "get",
446
- id: 12345
447
- })
448
- ```
449
-
450
- #### Error Self-Healing
451
-
452
- Errors include structured hints to help agents self-correct:
453
-
454
- ```javascript
455
- // Error response includes actionable guidance
456
- {
457
- "error": "Field 'priority' has invalid value 'Urgent'",
458
- "extensions": {
459
- "hint": "Use aiHelper.listPicklistValues('ticket', 'priority') to get valid options, then retry with a valid value.",
460
- "suggestions": [
461
- "Get valid values: aiHelper.listPicklistValues('ticket', 'priority')",
462
- "Use exact values from the picklist response"
463
- ]
464
- }
465
- }
466
- ```
467
-
468
- #### Best Practices for Agents
469
-
470
- - **Configure focused tools** - Set up separate tools for inspector, contacts, companies, and general resources
471
- - **Start with inspection** - Always call `autotask_inspector.describeResource` first to understand field requirements
472
- - **Use focused tools** - Prefer `autotask_contacts` or `autotask_companies` over general tools for better reliability
473
- - **Validate before execution** - Use `autotask_inspector.validateParameters` for pre-flight validation to catch errors early
474
- - **Optimise responses** - Use `selectColumnsJson` to reduce payload size and `outputMode: "rawIds"` for token efficiency
475
- - **Double-check with dry-run** - Use `dryRun: true` to preview requests before execution, especially for write operations
476
- - **Handle errors smartly** - Follow the structured hints in error responses for self-correction
477
- - **Cache discoveries** - Store field metadata and picklist values to avoid repeated introspection calls
478
- - **JSON validation** - Invalid JSON in `bodyJson`/`selectColumnsJson` is caught immediately with helpful error messages
479
-
480
- #### Troubleshooting
481
-
482
- **Tool Not Available:** Ensure `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` is set
483
- **No Parameters Visible:** Call `aiHelper.describeResource` to inspect available fields
484
- **Large Responses:** Use `selectColumnsJson` and `outputMode: "rawIds"` for efficiency
485
- **Validation Errors:** Follow error hints to resolve field requirement issues
486
-
487
- ## Usage
488
-
489
- ### Basic Example: Creating a Ticket
490
-
491
- 1. Add an **Autotask** node to your workflow
492
- 2. Select **Ticket** as the resource
493
- 3. Select **Create** as the operation
494
- 4. Configure the required fields (Title, Status, etc.)
495
- 5. Connect to a trigger or previous node
496
- 6. Execute the workflow
497
-
498
- ### Intermediate Example: Querying Projects with Filters
499
-
500
- 1. Add an **Autotask** node to your workflow
501
- 2. Select **Project** as the resource
502
- 3. Select **Get Many** as the operation
503
- 4. Add filter conditions (e.g., Status equals "Active")
504
- 5. Choose whether to retrieve all results or limit the number:
505
- - Toggle "Get All" to true to retrieve all matching records
506
- - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
507
- 6. Connect to a trigger or previous node
508
- 7. Execute the workflow
509
-
510
- ### Advanced Example: Using Column Selection and Reference Labels
511
-
512
- 1. Add an **Autotask** node to your workflow
513
- 2. Select **Ticket** as the resource
514
- 3. Select **Get Many** as the operation
515
- 4. Add filter conditions as needed
516
- 5. Enable **Select Columns** to choose specific fields to return
517
- 6. Select only the fields you need in the response (improves performance)
518
- 7. Enable **Add Picklist Labels** to get human-readable values for picklist fields
519
- 8. Enable **Add Reference Labels** to get human-readable values for reference fields
520
- 9. Enable **Flatten User-Defined Fields** to bring UDFs to the top level of response objects
521
- 10. Execute the workflow to get tickets with only the selected fields and human-readable labels
522
-
523
- ### Advanced Example: Complex Filtering with Get Many Advanced
524
-
525
- 1. Add an **Autotask** node to your workflow
526
- 2. Select **Ticket** as the resource
527
- 3. Select **Get Many Advanced** as the operation
528
- 4. Build a complex filter, for example:
529
- ```json
530
- {
531
- "filter": [
532
- {
533
- "op": "and",
534
- "items": [
535
- {
536
- "field": "status",
537
- "op": "noteq",
538
- "value": 5
539
- },
540
- {
541
- "op": "or",
542
- "items": [
543
- {
544
- "field": "priority",
545
- "op": "eq",
546
- "value": 6
547
- },
548
- {
549
- "field": "dueDateTime",
550
- "op": "lt",
551
- "value": "{{ $now.plus(3, 'days').toLocal()}}"
552
- }
553
- ]
554
- }
555
- ]
556
- }
557
- ]
558
- }
559
- ```
560
- [Valid filter operators and filter documentation can be found here](https://ww15.autotask.net/help/DeveloperHelp/Content/APIs/REST/API_Calls/REST_Basic_Query_Calls.htm?Highlight=filter#List2)
561
- 5. Choose whether to retrieve all results or limit the number:
562
- - Toggle "Get All" to true to retrieve all matching records
563
- - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
564
- 6. Enable **Select Columns** to choose specific fields to return
565
- 7. Enable **Add Reference Labels** and **Add Picklist Labels** for human-readable values
566
- 8. Execute the workflow to retrieve tickets that are not complete AND either have priority 6 OR are due within the next 3 days
567
-
568
- ### Example: Monitoring API Usage with API Threshold
569
-
570
- 1. Add an **Autotask** node to your workflow
571
- 2. Select **API Threshold** as the resource
572
- 3. The operation **Get API Usage** will be automatically selected (it's the only available operation)
573
- 4. Execute the node to receive current API usage information including:
574
- - Current usage count
575
- - Maximum threshold (limit)
576
- - Usage percentage
577
- - Usage level (Normal, Moderate, High, Critical)
578
- - Remaining requests
579
- - Timeframe duration
580
- 5. You can use this information with IF nodes to implement conditional logic:
581
- - Pause workflows when usage is too high
582
- - Throttle requests during peak usage periods
583
- - Log warnings when approaching limits
584
- - Only execute non-critical operations when usage is below certain thresholds
585
-
586
- ### Advanced Example: Working with Parent-Child Relationships
587
-
588
- Many Autotask entities have parent-child relationships (e.g., Companies and Contacts). To work with these:
589
-
590
- 1. First, retrieve or create the parent entity
591
- 2. Use the parent entity's ID in the child entity operations
592
- 3. For example, to create a Contact for a Company:
593
- - First node: Get or create the Company
594
- - Second node: Create a Contact with the Company ID
595
-
596
- ### Example: Setting Up a Webhook Trigger
597
-
598
- 1. Add an **Autotask Trigger** node to your workflow
599
- 2. Select the entity type to monitor (Companies, Contacts, Tickets, etc.)
600
- 3. Select the events to subscribe to (Create, Update, Delete)
601
- 4. Configure the webhook URL (n8n will handle this automatically)
602
- 5. Optionally specify fields to include in the webhook payload
603
- 6. Optionally exclude specific resources from triggering the workflow
604
- 7. Configure email notifications for webhook delivery failures if needed
605
- 8. Save and activate the workflow
606
- 9. The node will automatically register the webhook with Autotask
607
- 10. When events occur in Autotask, they will trigger your workflow
608
- 11. When the workflow is deactivated, the webhook will be automatically removed
609
-
610
- ## Configuration
611
-
612
- ### Caching Options
613
-
614
- The node includes an enhanced file-based caching system to improve performance by reducing API calls:
615
-
616
- - **Enable Field Caching**: Toggle caching on/off
617
- - **Cache TTL**: How long to cache field values (in seconds)
618
- - **Cache Entity Info**: Whether to cache entity information and field definitions
619
- - **Entity Info TTL**: How long to cache entity information
620
- - **Cache Reference Fields**: Whether to cache reference field values
621
- - **Reference Fields TTL**: How long to cache reference field values
622
- - **Cache Picklists**: Whether to cache picklist values
623
- - **Picklists TTL**: How long to cache picklist values
624
- - **File-based Cache**: Cache is stored in files that can be shared between workflows and runs
625
- - **Cache Directory**: Optional path to a directory where cache files will be stored
626
-
627
- > **IMPORTANT**: This node uses dynamic picklists and field enrichers to convert numerical values into human-readable labels through dynamic lookups. It's strongly recommended to keep caching enabled to avoid excessive API calls. Without caching, each picklist and reference field lookup requires separate API calls, which can quickly consume your API rate limits, especially in workflows with many operations or large data sets.
628
-
629
- ### Label Enrichment and Field Processing
630
-
631
- The node provides options to enrich entities with human-readable labels and simplify field access:
632
-
633
- - **Add Picklist Labels**: Adds "_label" fields for picklist values (e.g., Status_label: "In Progress")
634
- - **Add Reference Labels**: Adds "_label" fields for reference values (e.g., Company_label: "Acme Corporation")
635
- - **Flatten User-Defined Fields**: When enabled, brings UDFs up to the top level of each response object for easier access instead of being nested in the userDefinedFields array (maintains the original array for backward compatibility)
636
-
637
- ### Column Selection
638
-
639
- To improve performance and reduce payload size, you can select specific columns to return:
640
-
641
- - **Select Columns**: Choose which fields to include in the response
642
- - Works with all get operations (get, getMany, getManyAdvanced)
643
- - Compatible with label enrichment features
644
-
645
- ### Timezone Handling
646
-
647
- All dates and times in the Autotask API are in UTC. The node automatically converts between your selected timezone and UTC:
648
-
649
- - When creating or updating records, local times are converted to UTC
650
- - When retrieving records, UTC times are converted to your local timezone
651
- - The timezone is configured in the credentials
652
- - For Search Filter operations, input dates are thoroughly converted to UTC using the configured timezone, ensuring consistency with API requirements
653
- - Output dates from all operations are converted to the configured local timezone for easier workflow handling
654
-
655
- ## Limitations
656
-
657
- ### API Limits
658
-
659
- - Maximum 500 records per page in query results
660
- - Maximum 50 pages per query operation
661
- - Maximum 500 OR conditions in filters
662
- - Maximum 1 User Defined Field per query
663
-
664
- ### Entity-Specific Limitations
665
-
666
- - Some entities may not support all operations (e.g., Project Phases cannot be deleted)
667
- - Parent-child relationships require specific handling
668
- - Some fields may be read-only or have specific validation rules
669
-
670
- ### Performance Considerations
671
-
672
- - Large queries may be slow and should be optimised with filters
673
- - Column selection can significantly improve performance by reducing payload size
674
- - Complex workflows with many API calls may hit rate limits
675
- - Disabling caching when using picklist or reference label enrichment can lead to a high volume of API calls, potentially triggering rate limits. Each field being enriched requires a separate API call when cache is not available.
676
-
677
- ## Troubleshooting
678
-
679
- ### Common Issues
680
-
681
- - **Authentication Errors**: Verify your API credentials and ensure the API user has appropriate permissions
682
- - **Field Validation Errors**: Check field requirements in the Autotask API documentation
683
- - **Rate Limiting**: If you encounter rate limiting, reduce the frequency of API calls or implement retry logic
684
-
685
- ### Reporting Bugs
686
-
687
- If you encounter any bugs or issues with this integration:
688
-
689
- 1. Check the [GitHub Issues](https://github.com/msoukhomlinov/n8n-nodes-autotask/issues) to see if the problem has already been reported
690
- 2. If not, please submit a new issue with:
691
- - A clear description of the problem
692
- - Steps to reproduce the issue
693
- - Expected vs actual behaviour
694
- - Your environment details (n8n version, Node.js version)
695
- - Any relevant error messages or screenshots
696
-
697
- Bug reports should be submitted via GitHub at: https://github.com/msoukhomlinov/n8n-nodes-autotask/issues
698
-
699
- ## Resources
700
-
701
- - [Autotask API Documentation](https://ww6.autotask.net/help/developerhelp/Content/APIs/REST/REST_API_Home.htm)
702
- - [n8n Documentation](https://docs.n8n.io/)
703
- - [GitHub Repository](https://github.com/msoukhomlinov/n8n-nodes-autotask)
704
-
705
- ## Support
706
-
707
- If you find this node helpful and want to support its ongoing development, you can buy me a coffee:
708
-
709
- [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
710
-
711
- Your support helps maintain this project and develop new features.
712
-
713
- ## License
714
-
715
- [MIT](LICENSE)
1
+ # n8n-nodes-autotask
2
+
3
+ ![n8n-nodes-autotask](https://img.shields.io/badge/n8n--nodes--autotask-1.2.1-blue)
4
+ ![License](https://img.shields.io/badge/license-MIT-green)
5
+
6
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
7
+
8
+ > **IMPORTANT**: After updating this node to a new version, a restart of your n8n instance is highly recommended to ensure all changes are properly applied.
9
+
10
+ This is an n8n community node for integrating with Autotask PSA. It provides a comprehensive set of operations to interact with Autotask entities through their REST API.
11
+
12
+ ![Overview of n8n-nodes-autotask](./overview.gif)
13
+
14
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
15
+
16
+ [Installation](#installation)
17
+ [Authentication](#authentication)
18
+ [Features](#features)
19
+ [Usage](#usage)
20
+ [Configuration](#configuration)
21
+ [Limitations](#limitations)
22
+ [Troubleshooting](#troubleshooting)
23
+ [Resources](#resources)
24
+ [Support](#support)
25
+ [License](#license)
26
+
27
+ ## Installation
28
+
29
+ Follow these steps to install this node:
30
+
31
+ ```bash
32
+ # Install with npm
33
+ npm install n8n-nodes-autotask
34
+
35
+ # Install with pnpm
36
+ pnpm install n8n-nodes-autotask
37
+ ```
38
+
39
+ **Requirements:**
40
+ - n8n version 1.0.0 or later
41
+ - Node.js version 18.10 or later
42
+ - pnpm version 9.1 or later (if using pnpm)
43
+
44
+ ## Authentication
45
+
46
+ To use this node, you need to have API access to your Autotask instance. Follow these steps to set up authentication:
47
+
48
+ 1. In Autotask, go to **Admin > API User Security**
49
+ 2. Create or select an API user
50
+ 3. Note the API Integration Code, Username, and Secret
51
+ 4. In n8n, create a new credential of type **Autotask API**
52
+ 5. Enter your API Integration Code, Username, and Secret
53
+ 6. Select your Autotask zone
54
+ 7. Select your timezone (affects how dates and times are displayed and entered)
55
+ 8. Configure caching options as needed (this will cache dynamically fetched field picklists)
56
+
57
+ ## Features
58
+
59
+ ### Supported Resources
60
+
61
+ The node supports the following Autotask resources:
62
+
63
+ | Resource | Description |
64
+ |----------|-------------|
65
+ | API Threshold | Check Autotask API usage limits and current usage levels |
66
+ | Billing Code | Manage billing codes for time entries and charges |
67
+ | Billing Items | Manage Autotask Billing Items, which represent billable items that have been approved and posted for potential invoicing |
68
+ | Company | Manage organisations in Autotask |
69
+ | Company Alert | Manage alerts associated with companies |
70
+ | Company Location | Manage locations for companies |
71
+ | Company Note | Manage notes attached to companies |
72
+ | Company Site Configuration | Manage company site configurations and user-defined fields for customer companies |
73
+ | Company Webhook | Manage webhooks for company events |
74
+ | Configuration Item | Manage configuration items (CIs) for companies |
75
+ | Configuration Item Billing Product Association | Manage product associations for configuration items |
76
+ | Configuration Item Category | Manage categories for configuration items |
77
+ | Configuration Item Category UDF Association | Manage UDF associations for CI categories |
78
+ | Configuration Item DNS Record | Manage DNS records for configuration items |
79
+ | Configuration Item Note | Manage notes for configuration items |
80
+ | Configuration Item Related Item | Manage related items for configuration items |
81
+ | Configuration Item SSL Subject Alternative Name | Manage SSL alternative names for configuration items |
82
+ | Configuration Item Type | Manage types for configuration items |
83
+ | Configuration Item Webhook | Manage webhooks for configuration item events |
84
+ | Contact | Manage contacts associated with companies |
85
+ | Contact Groups | Manage contact groups |
86
+ | Contact Group Contacts | Manage contacts within contact groups |
87
+ | Contact Webhook | Manage webhooks for contact events |
88
+ | Contract | Manage contracts for companies |
89
+ | Contract Billing Rules | Manage billing rules for contracts |
90
+ | Contract Block | Manage block hour contracts |
91
+ | Contract Block Hour Factor | Manage hour factors for block hour contracts |
92
+ | Contract Charge | Manage charges associated with contracts |
93
+ | Contract Exclusion Billing Codes | Manage excluded billing codes for contracts |
94
+ | Contract Exclusion Roles | Manage excluded roles for contracts |
95
+ | Contract Exclusion Set Excluded Roles | Manage excluded roles within exclusion sets |
96
+ | Contract Exclusion Set Excluded Work Types | Manage excluded work types within exclusion sets |
97
+ | Contract Exclusion Sets | Manage exclusion sets for contracts |
98
+ | Contract Milestone | Manage milestones for contracts |
99
+ | Contract Note | Manage notes attached to contracts |
100
+ | Contract Rate | Manage rates for contract services |
101
+ | Contract Retainers | Manage retainers for contracts |
102
+ | Contract Role Costs | Manage role costs for contracts |
103
+ | Contract Service | Manage services within contracts |
104
+ | Contract Service Adjustments | Manage adjustments for contract services |
105
+ | Contract Service Bundle Adjustments | Manage adjustments for service bundles |
106
+ | Contract Service Bundles | Manage service bundles within contracts |
107
+ | Contract Service Bundle Units | Manage service bundle units |
108
+ | Contract Service Unit | Manage service units for contracts |
109
+ | Contract Ticket Purchases | Manage ticket purchases for contracts |
110
+ | Countries | Query countries, which are used in address information for companies, contacts, and resources |
111
+ | Domain Registrars | Manage domain registrars |
112
+ | Holiday | Manage holiday dates |
113
+ | Holiday Set | Manage holiday sets for resources |
114
+ | Invoices | Manage invoices |
115
+ | Notification History | View notification history |
116
+ | Opportunity | Manage sales opportunities |
117
+ | Product | Manage products in the catalogue |
118
+ | Product Vendors | Manage vendor associations for products |
119
+ | Project | Manage projects |
120
+ | Project Charge | Manage charges associated with projects |
121
+ | Project Note | Manage notes attached to projects |
122
+ | Project Phase | Manage phases within projects |
123
+ | Project Task | Manage tasks within projects |
124
+ | Quote | Manage quotes for opportunities with pricing for products, services, and labor |
125
+ | Quote Item | Manage line items for quotes including products, services, and labor |
126
+ | Quote Location | Manage shipping and billing address information for quotes |
127
+ | Quote Template | Query quote templates that define content and appearance of quotes |
128
+ | Resource | Manage staff resources |
129
+ | Resource Role | Manage department/role relationships, service desk queues, and service desk roles |
130
+ | Roles | Manage roles in the system |
131
+ | Search Filter | Build advanced search filters |
132
+ | Service | Manage services offered to clients |
133
+ | Service Call | Manage service calls |
134
+ | Service Call Task | Manage tasks associated with service calls |
135
+ | Service Call Task Resource | Manage resources assigned to service call tasks |
136
+ | Service Call Ticket | Manage tickets linked to service calls |
137
+ | Service Call Ticket Resource | Manage resources assigned to service call tickets |
138
+ | Survey | Manage customer surveys |
139
+ | Survey Results | Manage results from customer surveys |
140
+ | Subscription | Manage Subscriptions, which represent recurring service agreements with customers |
141
+ | Subscription Period | Query Subscription Periods, which track billing periods and usage for subscriptions |
142
+ | Ticket | Manage service tickets |
143
+ | Ticket History | View historical changes to tickets |
144
+ | Ticket Note | Manage notes attached to tickets |
145
+ | Ticket Note Webhook | Manage webhooks for ticket note events |
146
+ | Ticket Webhook | Manage webhooks for ticket events |
147
+ | Time Entry | Manage time entries for billing |
148
+
149
+ ### Operations
150
+
151
+ For most resources, the following operations are available:
152
+
153
+ - **Create**: Add new records
154
+ - **Read**: Retrieve a single record by ID
155
+ - **Update**: Modify existing records
156
+ - **Delete**: Remove records
157
+ - **Get Many**: Retrieve multiple records with basic filtering options. This operation allows you to:
158
+ - Filter records using simple field conditions (equals)
159
+ - Filtering on User Defined Fields (UDFs)
160
+ - Automatically paginate through large result sets
161
+ - Choose to get all results or limit to a specific number (1-500)
162
+ - Set a maximum number of records to return when not retrieving all records
163
+ - Select specific columns to return in the response
164
+ - Add human-readable labels for picklist and reference fields
165
+ - Flatten User-Defined Fields for easier access in workflows
166
+ - **Get Many Advanced**: Build complex queries with multiple filter conditions and logical operators. This operation provides:
167
+ - Support for complex AND/OR logic in filters
168
+ - Nested condition groups for sophisticated queries
169
+ - Filtering on User Defined Fields (UDFs)
170
+ - Advanced operators like contains, beginsWith, endsWith, exists, notExists
171
+ - Support for IN and NOT IN operators with multiple values
172
+ - Choose to get all results or limit to a specific number (1-500)
173
+ - Set a maximum number of records to return when not retrieving all records
174
+ - Select specific columns to return in the response
175
+ - Add human-readable labels for picklist and reference fields
176
+ - Flatten User-Defined Fields for easier access in workflows
177
+ - Date-based filtering with automatic timezone handling
178
+ - **Count**: Get the number of matching records
179
+ - **Get Entity Info**: Retrieve metadata about the entity
180
+ - **Get Field Info**: Retrieve field definitions for the selected entity
181
+
182
+ For webhook resources (Company Webhook, Contact Webhook, Configuration Item Webhook, Ticket Webhook, Ticket Note Webhook), the following operations are available:
183
+ - **Get**: Retrieve a single webhook by ID
184
+ - **Get Many**: Retrieve multiple webhooks with basic filtering
185
+ - **Delete**: Remove a webhook
186
+
187
+ ### Webhook Trigger
188
+
189
+ The node includes an Autotask Trigger node that can receive webhook events from Autotask. The trigger supports:
190
+
191
+ - Events for multiple entity types (Companies, Contacts, Tickets, Configuration Items, Ticket Notes)
192
+ - Create, Update, and Delete events
193
+ - Field selection for webhook payloads (specify which fields to include)
194
+ - Resource exclusion (exclude specific resources from triggering the workflow)
195
+ - Email notifications for webhook delivery failures
196
+ - Threshold notifications for monitoring webhook performance
197
+ - Automatic webhook registration and cleanup
198
+ - Secure payload verification with HMAC signatures
199
+
200
+ ### Advanced Features
201
+
202
+ - **Resource Mapping**: Dynamically map fields based on entity definitions
203
+ - **Advanced Filtering**: Build complex queries with multiple conditions
204
+ - **Column Selection**: Choose specific fields to return in get operations
205
+ - **Picklist Label Enrichment**: Automatically add human-readable labels for picklist fields
206
+ - **Reference Label Enrichment**: Add human-readable labels for reference fields
207
+ - **UDF Flattening**: Bring user-defined fields up to the top level of response objects for easier access
208
+ - **File-based Caching**: Improved performance with persistent caching that can be shared between workflows and runs
209
+ - **Timezone Handling**: Automatic conversion between local time and UTC
210
+ - **API Usage Monitoring**: Check current API usage thresholds and limits using the API Threshold resource to help prevent hitting rate limits and ensure smooth operations
211
+
212
+ ### API Threshold Resource
213
+
214
+ The API Threshold resource provides a simple way to monitor your Autotask API usage limits and current consumption. This helps users:
215
+ - Track how many API requests have been made in the current timeframe
216
+ - See the maximum allowed requests (threshold limit)
217
+ - View the usage as a percentage and categorized level (Normal, Moderate, High, Critical)
218
+ - Calculate remaining available requests
219
+ - Monitor timeframe duration for rate limits
220
+
221
+ This is particularly useful for workflows that make many API calls, allowing you to implement conditional logic based on current usage levels to avoid hitting rate limits and ensure continuous operation.
222
+
223
+ ### AI Agent Playbook
224
+
225
+ This node is optimised for AI agents and tool-calling systems with specialised features designed for autonomous operation.
226
+
227
+ #### Quick Start for AI Agents
228
+
229
+ **1. Introspect Resources**
230
+ ```javascript
231
+ // Discover available fields and requirements
232
+ operation: aiHelper.describeResource
233
+ params: { resource: "ticket", mode: "write" }
234
+ ```
235
+
236
+ **2. Prepare Data**
237
+ ```javascript
238
+ // Use JSON parameters for direct data input
239
+ bodyJson: {
240
+ "title": "API Integration Issue",
241
+ "description": "Customer reporting connection problems",
242
+ "priority": "Medium",
243
+ "status": "New"
244
+ }
245
+ ```
246
+
247
+ Note: You may provide labels for picklist/reference fields in `bodyJson` (e.g., `status: "New"`). They are automatically resolved to IDs pre-flight.
248
+
249
+ **3. Preview First (Optional)**
250
+ ```javascript
251
+ // Test your request without making API calls
252
+ dryRun: true
253
+ ```
254
+
255
+ **4. Execute with Optimal Output**
256
+ ```javascript
257
+ // Choose output format for token efficiency
258
+ outputMode: "rawIds" // Most efficient
259
+ outputMode: "idsAndLabels" // Default (balanced)
260
+ outputMode: "labelsOnly" // Most readable
261
+ ```
262
+
263
+ #### AI Helper Operations
264
+
265
+ **Introspection Endpoint:**
266
+ - `aiHelper.describeResource(resource, mode)` - Get field metadata, requirements, constraints, and **entity dependencies**
267
+ - `aiHelper.listPicklistValues(resource, fieldId, query, limit, page)` - Get valid values for dropdown fields
268
+ - `aiHelper.validateParameters(resource, mode, fieldValues)` - **NEW:** Validate field values without API calls - pre-flight validation
269
+
270
+ **Dynamic Dependency Discovery:**
271
+ - **Reference fields** show what entity they link to (e.g., `companyID → company`)
272
+ - **Field dependencies** reveal required relationships (e.g., `contactID requires: companyID`)
273
+ - **Workflow guidance** provides creation order tips (e.g., "Ensure company exists before creating contact")
274
+
275
+ **Enhanced Validation:**
276
+ - **JSON Schema validation** - Immediate feedback on malformed `bodyJson`/`selectColumnsJson`
277
+ - **Parameter pre-validation** - Validate field values, types, dependencies without API calls
278
+ - **Structured error responses** - Detailed validation results with field-by-field feedback
279
+
280
+ **JSON Parameter Fallbacks:**
281
+ - `bodyJson` - Override UI mappings for write operations (create/update)
282
+ - `selectColumnsJson` - Specify fields for read operations as JSON array
283
+
284
+ **Agent-Friendly Features:**
285
+ - `outputMode` - Control response format (rawIds/idsAndLabels/labelsOnly)
286
+ - `dryRun` - Get request preview without API execution
287
+ - Smart error hints with actionable suggestions
288
+
289
+ #### Tool Configuration for Maximum Effectiveness
290
+
291
+ For optimal AI agent integration, configure multiple instances of this node as separate tools. This provides focused, reliable access to different resource types.
292
+
293
+ **Recommended Tool Setup:**
294
+
295
+ ```javascript
296
+ // Tool 1: Resource Discovery and Field Introspection
297
+ {
298
+ name: "autotask_inspector",
299
+ description: "Discover Autotask resources, fields, and valid values",
300
+ resource: "aiHelper",
301
+ operations: ["describeResource", "listPicklistValues"]
302
+ }
303
+
304
+ // Tool 2: Contact Management
305
+ {
306
+ name: "autotask_contacts",
307
+ description: "Read and write Autotask contacts and people",
308
+ resource: "contact",
309
+ operations: ["get", "getMany", "create", "update"],
310
+ defaultParams: {
311
+ outputMode: "idsAndLabels",
312
+ selectColumnsJson: ["id", "firstName", "lastName", "emailAddress", "companyID", "title", "phone"]
313
+ }
314
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
315
+ }
316
+
317
+ // Tool 3: Company/Account Management
318
+ {
319
+ name: "autotask_companies",
320
+ description: "Read and write Autotask companies and accounts",
321
+ resource: "company",
322
+ operations: ["get", "getMany", "create", "update"],
323
+ defaultParams: {
324
+ outputMode: "idsAndLabels",
325
+ selectColumnsJson: ["id", "companyName", "companyType", "phone", "address1", "city", "state"]
326
+ }
327
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
328
+ }
329
+
330
+ // Tool 4: General Resource Access
331
+ {
332
+ name: "autotask_resources",
333
+ description: "Access any Autotask resource with full flexibility",
334
+ allResources: true,
335
+ defaultParams: {
336
+ outputMode: "rawIds" // Most token-efficient for exploratory queries
337
+ }
338
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
339
+ }
340
+ ```
341
+
342
+ **Usage Pattern:**
343
+ 1. **Start with Inspector** - Use `autotask_inspector` to understand field requirements
344
+ 2. **Use Focused Tools** - Call `autotask_contacts` or `autotask_companies` for CRM related operations
345
+ 3. **Use Specialist Tools** - Use `autotask_resources` for lookups of Autotask MSP staff (resources)
346
+
347
+ **Benefits:**
348
+ - **Faster execution** - Pre-configured tools reduce parameter complexity
349
+ - **Better reliability** - Focused tools have predictable schemas
350
+ - **Token efficiency** - Default parameters optimised for each use case
351
+ - **Easier debugging** - Clear separation of concerns
352
+
353
+ #### Environment Setup
354
+
355
+ For AI tool usage, set this environment variable:
356
+
357
+ ```bash
358
+ N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
359
+ ```
360
+
361
+ Configuration options:
362
+ - Add to your `.env` file
363
+ - Set in system environment variables
364
+ - Include in Docker/container configuration
365
+ - Add to startup command: `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true n8n start`
366
+
367
+ #### Example Agent Workflow
368
+
369
+ **Scenario: Create a contact for a new company**
370
+
371
+ ```javascript
372
+ // 1. Inspect contact requirements using dedicated tool
373
+ autotask_inspector.call({
374
+ operation: "describeResource",
375
+ targetResource: "contact",
376
+ mode: "write"
377
+ })
378
+ // Returns: {
379
+ // fields: [
380
+ // { id: "companyID", required: true, isReference: true, referencesEntity: "company" },
381
+ // { id: "firstName", required: true, type: "string" },
382
+ // { id: "lastName", required: true, type: "string" }
383
+ // ],
384
+ // notes: [
385
+ // "Required fields for write: companyID, firstName, lastName",
386
+ // "Reference fields (must reference existing entities): companyID → company",
387
+ // "Workflow tip: Ensure referenced company exists before creating contact."
388
+ // ]
389
+ // }
390
+
391
+ // 2. Check company picklist values if needed
392
+ autotask_inspector.call({
393
+ operation: "listPicklistValues",
394
+ targetResource: "contact",
395
+ fieldId: "companyID",
396
+ query: "Tech Solutions" // Search for company
397
+ })
398
+
399
+ // 2.5. Validate parameters before creation (NEW!)
400
+ autotask_inspector.call({
401
+ operation: "validateParameters",
402
+ targetResource: "contact",
403
+ mode: "create",
404
+ fieldValues: {
405
+ "firstName": "John",
406
+ "lastName": "Smith",
407
+ "emailAddress": "john.smith@techsolutions.com",
408
+ "companyID": 12345,
409
+ "title": "IT Manager"
410
+ }
411
+ })
412
+ // Returns: {
413
+ // isValid: true,
414
+ // errors: [],
415
+ // warnings: [
416
+ // { field: "companyID", message: "Reference field 'companyID' points to company. Ensure the referenced record exists.", code: "REFERENCE_EXISTENCE_CHECK" }
417
+ // ],
418
+ // summary: { totalFields: 15, providedFields: 5, validFields: 5, requiredFieldsMissing: 0, invalidValues: 0 }
419
+ // }
420
+
421
+ // 3. Create contact using focused tool
422
+ autotask_contacts.call({
423
+ operation: "create",
424
+ bodyJson: {
425
+ "firstName": "John",
426
+ "lastName": "Smith",
427
+ "emailAddress": "john.smith@techsolutions.com",
428
+ "companyID": 12345,
429
+ "title": "IT Manager"
430
+ },
431
+ dryRun: true // Preview first
432
+ })
433
+ // Dry-run response includes a `resolutions` array when labels were resolved to IDs, e.g.:
434
+ // resolutions: [{ field: 'status', from: 'New', to: 1, method: 'picklist' }]
435
+
436
+ // 4. Execute after validation
437
+ autotask_contacts.call({
438
+ operation: "create",
439
+ bodyJson: { /* same data */ },
440
+ outputMode: "idsAndLabels"
441
+ })
442
+
443
+ // 5. Retrieve company details using focused tool
444
+ autotask_companies.call({
445
+ operation: "get",
446
+ id: 12345
447
+ })
448
+ ```
449
+
450
+ #### Error Self-Healing
451
+
452
+ Errors include structured hints to help agents self-correct:
453
+
454
+ ```javascript
455
+ // Error response includes actionable guidance
456
+ {
457
+ "error": "Field 'priority' has invalid value 'Urgent'",
458
+ "extensions": {
459
+ "hint": "Use aiHelper.listPicklistValues('ticket', 'priority') to get valid options, then retry with a valid value.",
460
+ "suggestions": [
461
+ "Get valid values: aiHelper.listPicklistValues('ticket', 'priority')",
462
+ "Use exact values from the picklist response"
463
+ ]
464
+ }
465
+ }
466
+ ```
467
+
468
+ #### Best Practices for Agents
469
+
470
+ - **Configure focused tools** - Set up separate tools for inspector, contacts, companies, and general resources
471
+ - **Start with inspection** - Always call `autotask_inspector.describeResource` first to understand field requirements
472
+ - **Use focused tools** - Prefer `autotask_contacts` or `autotask_companies` over general tools for better reliability
473
+ - **Validate before execution** - Use `autotask_inspector.validateParameters` for pre-flight validation to catch errors early
474
+ - **Optimise responses** - Use `selectColumnsJson` to reduce payload size and `outputMode: "rawIds"` for token efficiency
475
+ - **Double-check with dry-run** - Use `dryRun: true` to preview requests before execution, especially for write operations
476
+ - **Handle errors smartly** - Follow the structured hints in error responses for self-correction
477
+ - **Cache discoveries** - Store field metadata and picklist values to avoid repeated introspection calls
478
+ - **JSON validation** - Invalid JSON in `bodyJson`/`selectColumnsJson` is caught immediately with helpful error messages
479
+
480
+ #### Troubleshooting
481
+
482
+ **Tool Not Available:** Ensure `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` is set
483
+ **No Parameters Visible:** Call `aiHelper.describeResource` to inspect available fields
484
+ **Large Responses:** Use `selectColumnsJson` and `outputMode: "rawIds"` for efficiency
485
+ **Validation Errors:** Follow error hints to resolve field requirement issues
486
+
487
+ ## Usage
488
+
489
+ ### Basic Example: Creating a Ticket
490
+
491
+ 1. Add an **Autotask** node to your workflow
492
+ 2. Select **Ticket** as the resource
493
+ 3. Select **Create** as the operation
494
+ 4. Configure the required fields (Title, Status, etc.)
495
+ 5. Connect to a trigger or previous node
496
+ 6. Execute the workflow
497
+
498
+ ### Intermediate Example: Querying Projects with Filters
499
+
500
+ 1. Add an **Autotask** node to your workflow
501
+ 2. Select **Project** as the resource
502
+ 3. Select **Get Many** as the operation
503
+ 4. Add filter conditions (e.g., Status equals "Active")
504
+ 5. Choose whether to retrieve all results or limit the number:
505
+ - Toggle "Get All" to true to retrieve all matching records
506
+ - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
507
+ 6. Connect to a trigger or previous node
508
+ 7. Execute the workflow
509
+
510
+ ### Advanced Example: Using Column Selection and Reference Labels
511
+
512
+ 1. Add an **Autotask** node to your workflow
513
+ 2. Select **Ticket** as the resource
514
+ 3. Select **Get Many** as the operation
515
+ 4. Add filter conditions as needed
516
+ 5. Enable **Select Columns** to choose specific fields to return
517
+ 6. Select only the fields you need in the response (improves performance)
518
+ 7. Enable **Add Picklist Labels** to get human-readable values for picklist fields
519
+ 8. Enable **Add Reference Labels** to get human-readable values for reference fields
520
+ 9. Enable **Flatten User-Defined Fields** to bring UDFs to the top level of response objects
521
+ 10. Execute the workflow to get tickets with only the selected fields and human-readable labels
522
+
523
+ ### Advanced Example: Complex Filtering with Get Many Advanced
524
+
525
+ 1. Add an **Autotask** node to your workflow
526
+ 2. Select **Ticket** as the resource
527
+ 3. Select **Get Many Advanced** as the operation
528
+ 4. Build a complex filter, for example:
529
+ ```json
530
+ {
531
+ "filter": [
532
+ {
533
+ "op": "and",
534
+ "items": [
535
+ {
536
+ "field": "status",
537
+ "op": "noteq",
538
+ "value": 5
539
+ },
540
+ {
541
+ "op": "or",
542
+ "items": [
543
+ {
544
+ "field": "priority",
545
+ "op": "eq",
546
+ "value": 6
547
+ },
548
+ {
549
+ "field": "dueDateTime",
550
+ "op": "lt",
551
+ "value": "{{ $now.plus(3, 'days').toLocal()}}"
552
+ }
553
+ ]
554
+ }
555
+ ]
556
+ }
557
+ ]
558
+ }
559
+ ```
560
+ [Valid filter operators and filter documentation can be found here](https://ww15.autotask.net/help/DeveloperHelp/Content/APIs/REST/API_Calls/REST_Basic_Query_Calls.htm?Highlight=filter#List2)
561
+ 5. Choose whether to retrieve all results or limit the number:
562
+ - Toggle "Get All" to true to retrieve all matching records
563
+ - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
564
+ 6. Enable **Select Columns** to choose specific fields to return
565
+ 7. Enable **Add Reference Labels** and **Add Picklist Labels** for human-readable values
566
+ 8. Execute the workflow to retrieve tickets that are not complete AND either have priority 6 OR are due within the next 3 days
567
+
568
+ ### Example: Monitoring API Usage with API Threshold
569
+
570
+ 1. Add an **Autotask** node to your workflow
571
+ 2. Select **API Threshold** as the resource
572
+ 3. The operation **Get API Usage** will be automatically selected (it's the only available operation)
573
+ 4. Execute the node to receive current API usage information including:
574
+ - Current usage count
575
+ - Maximum threshold (limit)
576
+ - Usage percentage
577
+ - Usage level (Normal, Moderate, High, Critical)
578
+ - Remaining requests
579
+ - Timeframe duration
580
+ 5. You can use this information with IF nodes to implement conditional logic:
581
+ - Pause workflows when usage is too high
582
+ - Throttle requests during peak usage periods
583
+ - Log warnings when approaching limits
584
+ - Only execute non-critical operations when usage is below certain thresholds
585
+
586
+ ### Advanced Example: Working with Parent-Child Relationships
587
+
588
+ Many Autotask entities have parent-child relationships (e.g., Companies and Contacts). To work with these:
589
+
590
+ 1. First, retrieve or create the parent entity
591
+ 2. Use the parent entity's ID in the child entity operations
592
+ 3. For example, to create a Contact for a Company:
593
+ - First node: Get or create the Company
594
+ - Second node: Create a Contact with the Company ID
595
+
596
+ ### Example: Setting Up a Webhook Trigger
597
+
598
+ 1. Add an **Autotask Trigger** node to your workflow
599
+ 2. Select the entity type to monitor (Companies, Contacts, Tickets, etc.)
600
+ 3. Select the events to subscribe to (Create, Update, Delete)
601
+ 4. Configure the webhook URL (n8n will handle this automatically)
602
+ 5. Optionally specify fields to include in the webhook payload
603
+ 6. Optionally exclude specific resources from triggering the workflow
604
+ 7. Configure email notifications for webhook delivery failures if needed
605
+ 8. Save and activate the workflow
606
+ 9. The node will automatically register the webhook with Autotask
607
+ 10. When events occur in Autotask, they will trigger your workflow
608
+ 11. When the workflow is deactivated, the webhook will be automatically removed
609
+
610
+ ## Configuration
611
+
612
+ ### Caching Options
613
+
614
+ The node includes an enhanced file-based caching system to improve performance by reducing API calls:
615
+
616
+ - **Enable Field Caching**: Toggle caching on/off
617
+ - **Cache TTL**: How long to cache field values (in seconds)
618
+ - **Cache Entity Info**: Whether to cache entity information and field definitions
619
+ - **Entity Info TTL**: How long to cache entity information
620
+ - **Cache Reference Fields**: Whether to cache reference field values
621
+ - **Reference Fields TTL**: How long to cache reference field values
622
+ - **Cache Picklists**: Whether to cache picklist values
623
+ - **Picklists TTL**: How long to cache picklist values
624
+ - **File-based Cache**: Cache is stored in files that can be shared between workflows and runs
625
+ - **Cache Directory**: Optional path to a directory where cache files will be stored
626
+
627
+ > **IMPORTANT**: This node uses dynamic picklists and field enrichers to convert numerical values into human-readable labels through dynamic lookups. It's strongly recommended to keep caching enabled to avoid excessive API calls. Without caching, each picklist and reference field lookup requires separate API calls, which can quickly consume your API rate limits, especially in workflows with many operations or large data sets.
628
+
629
+ ### Label Enrichment and Field Processing
630
+
631
+ The node provides options to enrich entities with human-readable labels and simplify field access:
632
+
633
+ - **Add Picklist Labels**: Adds "_label" fields for picklist values (e.g., Status_label: "In Progress")
634
+ - **Add Reference Labels**: Adds "_label" fields for reference values (e.g., Company_label: "Acme Corporation")
635
+ - **Flatten User-Defined Fields**: When enabled, brings UDFs up to the top level of each response object for easier access instead of being nested in the userDefinedFields array (maintains the original array for backward compatibility)
636
+
637
+ ### Column Selection
638
+
639
+ To improve performance and reduce payload size, you can select specific columns to return:
640
+
641
+ - **Select Columns**: Choose which fields to include in the response
642
+ - Works with all get operations (get, getMany, getManyAdvanced)
643
+ - Compatible with label enrichment features
644
+
645
+ ### Timezone Handling
646
+
647
+ All dates and times in the Autotask API are in UTC. The node automatically converts between your selected timezone and UTC:
648
+
649
+ - When creating or updating records, local times are converted to UTC
650
+ - When retrieving records, UTC times are converted to your local timezone
651
+ - The timezone is configured in the credentials
652
+ - For Search Filter operations, input dates are thoroughly converted to UTC using the configured timezone, ensuring consistency with API requirements
653
+ - Output dates from all operations are converted to the configured local timezone for easier workflow handling
654
+
655
+ ## Limitations
656
+
657
+ ### API Limits
658
+
659
+ - Maximum 500 records per page in query results
660
+ - Maximum 50 pages per query operation
661
+ - Maximum 500 OR conditions in filters
662
+ - Maximum 1 User Defined Field per query
663
+
664
+ ### Entity-Specific Limitations
665
+
666
+ - Some entities may not support all operations (e.g., Project Phases cannot be deleted)
667
+ - Parent-child relationships require specific handling
668
+ - Some fields may be read-only or have specific validation rules
669
+
670
+ ### Performance Considerations
671
+
672
+ - Large queries may be slow and should be optimised with filters
673
+ - Column selection can significantly improve performance by reducing payload size
674
+ - Complex workflows with many API calls may hit rate limits
675
+ - Disabling caching when using picklist or reference label enrichment can lead to a high volume of API calls, potentially triggering rate limits. Each field being enriched requires a separate API call when cache is not available.
676
+
677
+ ## Troubleshooting
678
+
679
+ ### Common Issues
680
+
681
+ - **Authentication Errors**: Verify your API credentials and ensure the API user has appropriate permissions
682
+ - **Field Validation Errors**: Check field requirements in the Autotask API documentation
683
+ - **Rate Limiting**: If you encounter rate limiting, reduce the frequency of API calls or implement retry logic
684
+
685
+ ### Reporting Bugs
686
+
687
+ If you encounter any bugs or issues with this integration:
688
+
689
+ 1. Check the [GitHub Issues](https://github.com/msoukhomlinov/n8n-nodes-autotask/issues) to see if the problem has already been reported
690
+ 2. If not, please submit a new issue with:
691
+ - A clear description of the problem
692
+ - Steps to reproduce the issue
693
+ - Expected vs actual behaviour
694
+ - Your environment details (n8n version, Node.js version)
695
+ - Any relevant error messages or screenshots
696
+
697
+ Bug reports should be submitted via GitHub at: https://github.com/msoukhomlinov/n8n-nodes-autotask/issues
698
+
699
+ ## Resources
700
+
701
+ - [Autotask API Documentation](https://ww6.autotask.net/help/developerhelp/Content/APIs/REST/REST_API_Home.htm)
702
+ - [n8n Documentation](https://docs.n8n.io/)
703
+ - [GitHub Repository](https://github.com/msoukhomlinov/n8n-nodes-autotask)
704
+
705
+ ## Support
706
+
707
+ If you find this node helpful and want to support its ongoing development, you can buy me a coffee:
708
+
709
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
710
+
711
+ Your support helps maintain this project and develop new features.
712
+
713
+ ## License
714
+
715
+ [MIT](LICENSE)