n8n-nodes-autotask 1.4.0 → 1.4.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.
package/README.md CHANGED
@@ -1,716 +1,716 @@
1
- # n8n-nodes-autotask
2
-
3
- ![n8n-nodes-autotask](https://img.shields.io/badge/n8n--nodes--autotask-1.3.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. When Mapping Column Mode is set to "Map automatically" (`autoMapInputData`), the node uses incoming item data directly and passes all fields whose keys match the selected entity's schema IDs, regardless of whether those columns are toggled off in the UI. Node parameter mappings are ignored in this mode (matching n8n's standard resource mapper behaviour). `bodyJson` still takes final precedence as an override.
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
- - **Dry Run Mode**: Preview write operations (create, update, delete) without making actual changes. When enabled, returns a preview of the request that would be sent, useful for testing and validation
212
-
213
- ### API Threshold Resource
214
-
215
- The API Threshold resource provides a simple way to monitor your Autotask API usage limits and current consumption. This helps users:
216
- - Track how many API requests have been made in the current timeframe
217
- - See the maximum allowed requests (threshold limit)
218
- - View the usage as a percentage and categorized level (Normal, Moderate, High, Critical)
219
- - Calculate remaining available requests
220
- - Monitor timeframe duration for rate limits
221
-
222
- 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.
223
-
224
- ### AI Agent Playbook
225
-
226
- This node is optimised for AI agents and tool-calling systems with specialised features designed for autonomous operation.
227
-
228
- #### Quick Start for AI Agents
229
-
230
- **1. Introspect Resources**
231
- ```javascript
232
- // Discover available fields and requirements
233
- operation: aiHelper.describeResource
234
- params: { resource: "ticket", mode: "write" }
235
- ```
236
-
237
- **2. Prepare Data**
238
- ```javascript
239
- // Use JSON parameters for direct data input
240
- bodyJson: {
241
- "title": "API Integration Issue",
242
- "description": "Customer reporting connection problems",
243
- "priority": "Medium",
244
- "status": "New"
245
- }
246
- ```
247
-
248
- Note: You may provide labels for picklist/reference fields in `bodyJson` (e.g., `status: "New"`). They are automatically resolved to IDs pre-flight.
249
-
250
- **3. Preview First (Optional)**
251
- ```javascript
252
- // Test your request without making API calls
253
- dryRun: true
254
- ```
255
-
256
- **4. Execute with Optimal Output**
257
- ```javascript
258
- // Choose output format for token efficiency
259
- outputMode: "rawIds" // Most efficient
260
- outputMode: "idsAndLabels" // Default (balanced)
261
- outputMode: "labelsOnly" // Most readable
262
- ```
263
-
264
- #### AI Helper Operations
265
-
266
- **Introspection Endpoint:**
267
- - `aiHelper.describeResource(resource, mode)` - Get field metadata, requirements, constraints, and **entity dependencies**
268
- - `aiHelper.listPicklistValues(resource, fieldId, query, limit, page)` - Get valid values for dropdown fields
269
- - `aiHelper.validateParameters(resource, mode, fieldValues)` - **NEW:** Validate field values without API calls - pre-flight validation
270
-
271
- **Dynamic Dependency Discovery:**
272
- - **Reference fields** show what entity they link to (e.g., `companyID → company`)
273
- - **Field dependencies** reveal required relationships (e.g., `contactID requires: companyID`)
274
- - **Workflow guidance** provides creation order tips (e.g., "Ensure company exists before creating contact")
275
-
276
- **Enhanced Validation:**
277
- - **JSON Schema validation** - Immediate feedback on malformed `bodyJson`/`selectColumnsJson`
278
- - **Parameter pre-validation** - Validate field values, types, dependencies without API calls
279
- - **Structured error responses** - Detailed validation results with field-by-field feedback
280
-
281
- **JSON Parameter Fallbacks:**
282
- - `bodyJson` - Override UI mappings for write operations (create/update)
283
- - `selectColumnsJson` - Specify fields for read operations as JSON array
284
-
285
- **Agent-Friendly Features:**
286
- - `outputMode` - Control response format (rawIds/idsAndLabels/labelsOnly)
287
- - `dryRun` - Get request preview without API execution
288
- - Smart error hints with actionable suggestions
289
-
290
- #### Tool Configuration for Maximum Effectiveness
291
-
292
- For optimal AI agent integration, configure multiple instances of this node as separate tools. This provides focused, reliable access to different resource types.
293
-
294
- **Recommended Tool Setup:**
295
-
296
- ```javascript
297
- // Tool 1: Resource Discovery and Field Introspection
298
- {
299
- name: "autotask_inspector",
300
- description: "Discover Autotask resources, fields, and valid values",
301
- resource: "aiHelper",
302
- operations: ["describeResource", "listPicklistValues"]
303
- }
304
-
305
- // Tool 2: Contact Management
306
- {
307
- name: "autotask_contacts",
308
- description: "Read and write Autotask contacts and people",
309
- resource: "contact",
310
- operations: ["get", "getMany", "create", "update"],
311
- defaultParams: {
312
- outputMode: "idsAndLabels",
313
- selectColumnsJson: ["id", "firstName", "lastName", "emailAddress", "companyID", "title", "phone"]
314
- }
315
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
316
- }
317
-
318
- // Tool 3: Company/Account Management
319
- {
320
- name: "autotask_companies",
321
- description: "Read and write Autotask companies and accounts",
322
- resource: "company",
323
- operations: ["get", "getMany", "create", "update"],
324
- defaultParams: {
325
- outputMode: "idsAndLabels",
326
- selectColumnsJson: ["id", "companyName", "companyType", "phone", "address1", "city", "state"]
327
- }
328
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
329
- }
330
-
331
- // Tool 4: General Resource Access
332
- {
333
- name: "autotask_resources",
334
- description: "Access any Autotask resource with full flexibility",
335
- allResources: true,
336
- defaultParams: {
337
- outputMode: "rawIds" // Most token-efficient for exploratory queries
338
- }
339
- // Accepts labels in bodyJson; labels are auto-resolved to IDs
340
- }
341
- ```
342
-
343
- **Usage Pattern:**
344
- 1. **Start with Inspector** - Use `autotask_inspector` to understand field requirements
345
- 2. **Use Focused Tools** - Call `autotask_contacts` or `autotask_companies` for CRM related operations
346
- 3. **Use Specialist Tools** - Use `autotask_resources` for lookups of Autotask MSP staff (resources)
347
-
348
- **Benefits:**
349
- - **Faster execution** - Pre-configured tools reduce parameter complexity
350
- - **Better reliability** - Focused tools have predictable schemas
351
- - **Token efficiency** - Default parameters optimised for each use case
352
- - **Easier debugging** - Clear separation of concerns
353
-
354
- #### Environment Setup
355
-
356
- For AI tool usage, set this environment variable:
357
-
358
- ```bash
359
- N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
360
- ```
361
-
362
- Configuration options:
363
- - Add to your `.env` file
364
- - Set in system environment variables
365
- - Include in Docker/container configuration
366
- - Add to startup command: `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true n8n start`
367
-
368
- #### Example Agent Workflow
369
-
370
- **Scenario: Create a contact for a new company**
371
-
372
- ```javascript
373
- // 1. Inspect contact requirements using dedicated tool
374
- autotask_inspector.call({
375
- operation: "describeResource",
376
- targetResource: "contact",
377
- mode: "write"
378
- })
379
- // Returns: {
380
- // fields: [
381
- // { id: "companyID", required: true, isReference: true, referencesEntity: "company" },
382
- // { id: "firstName", required: true, type: "string" },
383
- // { id: "lastName", required: true, type: "string" }
384
- // ],
385
- // notes: [
386
- // "Required fields for write: companyID, firstName, lastName",
387
- // "Reference fields (must reference existing entities): companyID → company",
388
- // "Workflow tip: Ensure referenced company exists before creating contact."
389
- // ]
390
- // }
391
-
392
- // 2. Check company picklist values if needed
393
- autotask_inspector.call({
394
- operation: "listPicklistValues",
395
- targetResource: "contact",
396
- fieldId: "companyID",
397
- query: "Tech Solutions" // Search for company
398
- })
399
-
400
- // 2.5. Validate parameters before creation (NEW!)
401
- autotask_inspector.call({
402
- operation: "validateParameters",
403
- targetResource: "contact",
404
- mode: "create",
405
- fieldValues: {
406
- "firstName": "John",
407
- "lastName": "Smith",
408
- "emailAddress": "john.smith@techsolutions.com",
409
- "companyID": 12345,
410
- "title": "IT Manager"
411
- }
412
- })
413
- // Returns: {
414
- // isValid: true,
415
- // errors: [],
416
- // warnings: [
417
- // { field: "companyID", message: "Reference field 'companyID' points to company. Ensure the referenced record exists.", code: "REFERENCE_EXISTENCE_CHECK" }
418
- // ],
419
- // summary: { totalFields: 15, providedFields: 5, validFields: 5, requiredFieldsMissing: 0, invalidValues: 0 }
420
- // }
421
-
422
- // 3. Create contact using focused tool
423
- autotask_contacts.call({
424
- operation: "create",
425
- bodyJson: {
426
- "firstName": "John",
427
- "lastName": "Smith",
428
- "emailAddress": "john.smith@techsolutions.com",
429
- "companyID": 12345,
430
- "title": "IT Manager"
431
- },
432
- dryRun: true // Preview first
433
- })
434
- // Dry-run response includes a `resolutions` array when labels were resolved to IDs, e.g.:
435
- // resolutions: [{ field: 'status', from: 'New', to: 1, method: 'picklist' }]
436
-
437
- // 4. Execute after validation
438
- autotask_contacts.call({
439
- operation: "create",
440
- bodyJson: { /* same data */ },
441
- outputMode: "idsAndLabels"
442
- })
443
-
444
- // 5. Retrieve company details using focused tool
445
- autotask_companies.call({
446
- operation: "get",
447
- id: 12345
448
- })
449
- ```
450
-
451
- #### Error Self-Healing
452
-
453
- Errors include structured hints to help agents self-correct:
454
-
455
- ```javascript
456
- // Error response includes actionable guidance
457
- {
458
- "error": "Field 'priority' has invalid value 'Urgent'",
459
- "extensions": {
460
- "hint": "Use aiHelper.listPicklistValues('ticket', 'priority') to get valid options, then retry with a valid value.",
461
- "suggestions": [
462
- "Get valid values: aiHelper.listPicklistValues('ticket', 'priority')",
463
- "Use exact values from the picklist response"
464
- ]
465
- }
466
- }
467
- ```
468
-
469
- #### Best Practices for Agents
470
-
471
- - **Configure focused tools** - Set up separate tools for inspector, contacts, companies, and general resources
472
- - **Start with inspection** - Always call `autotask_inspector.describeResource` first to understand field requirements
473
- - **Use focused tools** - Prefer `autotask_contacts` or `autotask_companies` over general tools for better reliability
474
- - **Validate before execution** - Use `autotask_inspector.validateParameters` for pre-flight validation to catch errors early
475
- - **Optimise responses** - Use `selectColumnsJson` to reduce payload size and `outputMode: "rawIds"` for token efficiency
476
- - **Double-check with dry-run** - Use `dryRun: true` to preview requests before execution, especially for write operations
477
- - **Handle errors smartly** - Follow the structured hints in error responses for self-correction
478
- - **Cache discoveries** - Store field metadata and picklist values to avoid repeated introspection calls
479
- - **JSON validation** - Invalid JSON in `bodyJson`/`selectColumnsJson` is caught immediately with helpful error messages
480
-
481
- #### Troubleshooting
482
-
483
- **Tool Not Available:** Ensure `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` is set
484
- **No Parameters Visible:** Call `aiHelper.describeResource` to inspect available fields
485
- **Large Responses:** Use `selectColumnsJson` and `outputMode: "rawIds"` for efficiency
486
- **Validation Errors:** Follow error hints to resolve field requirement issues
487
-
488
- ## Usage
489
-
490
- ### Basic Example: Creating a Ticket
491
-
492
- 1. Add an **Autotask** node to your workflow
493
- 2. Select **Ticket** as the resource
494
- 3. Select **Create** as the operation
495
- 4. Configure the required fields (Title, Status, etc.)
496
- 5. Connect to a trigger or previous node
497
- 6. Execute the workflow
498
-
499
- ### Intermediate Example: Querying Projects with Filters
500
-
501
- 1. Add an **Autotask** node to your workflow
502
- 2. Select **Project** as the resource
503
- 3. Select **Get Many** as the operation
504
- 4. Add filter conditions (e.g., Status equals "Active")
505
- 5. Choose whether to retrieve all results or limit the number:
506
- - Toggle "Get All" to true to retrieve all matching records
507
- - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
508
- 6. Connect to a trigger or previous node
509
- 7. Execute the workflow
510
-
511
- ### Advanced Example: Using Column Selection and Reference Labels
512
-
513
- 1. Add an **Autotask** node to your workflow
514
- 2. Select **Ticket** as the resource
515
- 3. Select **Get Many** as the operation
516
- 4. Add filter conditions as needed
517
- 5. Enable **Select Columns** to choose specific fields to return
518
- 6. Select only the fields you need in the response (improves performance)
519
- 7. Enable **Add Picklist Labels** to get human-readable values for picklist fields
520
- 8. Enable **Add Reference Labels** to get human-readable values for reference fields
521
- 9. Enable **Flatten User-Defined Fields** to bring UDFs to the top level of response objects
522
- 10. Execute the workflow to get tickets with only the selected fields and human-readable labels
523
-
524
- ### Advanced Example: Complex Filtering with Get Many Advanced
525
-
526
- 1. Add an **Autotask** node to your workflow
527
- 2. Select **Ticket** as the resource
528
- 3. Select **Get Many Advanced** as the operation
529
- 4. Build a complex filter, for example:
530
- ```json
531
- {
532
- "filter": [
533
- {
534
- "op": "and",
535
- "items": [
536
- {
537
- "field": "status",
538
- "op": "noteq",
539
- "value": 5
540
- },
541
- {
542
- "op": "or",
543
- "items": [
544
- {
545
- "field": "priority",
546
- "op": "eq",
547
- "value": 6
548
- },
549
- {
550
- "field": "dueDateTime",
551
- "op": "lt",
552
- "value": "{{ $now.plus(3, 'days').toLocal()}}"
553
- }
554
- ]
555
- }
556
- ]
557
- }
558
- ]
559
- }
560
- ```
561
- [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)
562
- 5. Choose whether to retrieve all results or limit the number:
563
- - Toggle "Get All" to true to retrieve all matching records
564
- - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
565
- 6. Enable **Select Columns** to choose specific fields to return
566
- 7. Enable **Add Reference Labels** and **Add Picklist Labels** for human-readable values
567
- 8. Execute the workflow to retrieve tickets that are not complete AND either have priority 6 OR are due within the next 3 days
568
-
569
- ### Example: Monitoring API Usage with API Threshold
570
-
571
- 1. Add an **Autotask** node to your workflow
572
- 2. Select **API Threshold** as the resource
573
- 3. The operation **Get API Usage** will be automatically selected (it's the only available operation)
574
- 4. Execute the node to receive current API usage information including:
575
- - Current usage count
576
- - Maximum threshold (limit)
577
- - Usage percentage
578
- - Usage level (Normal, Moderate, High, Critical)
579
- - Remaining requests
580
- - Timeframe duration
581
- 5. You can use this information with IF nodes to implement conditional logic:
582
- - Pause workflows when usage is too high
583
- - Throttle requests during peak usage periods
584
- - Log warnings when approaching limits
585
- - Only execute non-critical operations when usage is below certain thresholds
586
-
587
- ### Advanced Example: Working with Parent-Child Relationships
588
-
589
- Many Autotask entities have parent-child relationships (e.g., Companies and Contacts). To work with these:
590
-
591
- 1. First, retrieve or create the parent entity
592
- 2. Use the parent entity's ID in the child entity operations
593
- 3. For example, to create a Contact for a Company:
594
- - First node: Get or create the Company
595
- - Second node: Create a Contact with the Company ID
596
-
597
- ### Example: Setting Up a Webhook Trigger
598
-
599
- 1. Add an **Autotask Trigger** node to your workflow
600
- 2. Select the entity type to monitor (Companies, Contacts, Tickets, etc.)
601
- 3. Select the events to subscribe to (Create, Update, Delete)
602
- 4. Configure the webhook URL (n8n will handle this automatically)
603
- 5. Optionally specify fields to include in the webhook payload
604
- 6. Optionally exclude specific resources from triggering the workflow
605
- 7. Configure email notifications for webhook delivery failures if needed
606
- 8. Save and activate the workflow
607
- 9. The node will automatically register the webhook with Autotask
608
- 10. When events occur in Autotask, they will trigger your workflow
609
- 11. When the workflow is deactivated, the webhook will be automatically removed
610
-
611
- ## Configuration
612
-
613
- ### Caching Options
614
-
615
- The node includes an enhanced file-based caching system to improve performance by reducing API calls:
616
-
617
- - **Enable Field Caching**: Toggle caching on/off
618
- - **Cache TTL**: How long to cache field values (in seconds)
619
- - **Cache Entity Info**: Whether to cache entity information and field definitions
620
- - **Entity Info TTL**: How long to cache entity information
621
- - **Cache Reference Fields**: Whether to cache reference field values
622
- - **Reference Fields TTL**: How long to cache reference field values
623
- - **Cache Picklists**: Whether to cache picklist values
624
- - **Picklists TTL**: How long to cache picklist values
625
- - **File-based Cache**: Cache is stored in files that can be shared between workflows and runs
626
- - **Cache Directory**: Optional path to a directory where cache files will be stored
627
-
628
- > **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.
629
-
630
- ### Label Enrichment and Field Processing
631
-
632
- The node provides options to enrich entities with human-readable labels and simplify field access:
633
-
634
- - **Add Picklist Labels**: Adds "_label" fields for picklist values (e.g., Status_label: "In Progress")
635
- - **Add Reference Labels**: Adds "_label" fields for reference values (e.g., Company_label: "Acme Corporation")
636
- - **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)
637
-
638
- ### Column Selection
639
-
640
- To improve performance and reduce payload size, you can select specific columns to return:
641
-
642
- - **Select Columns**: Choose which fields to include in the response
643
- - Works with all get operations (get, getMany, getManyAdvanced)
644
- - Compatible with label enrichment features
645
-
646
- ### Timezone Handling
647
-
648
- All dates and times in the Autotask API are in UTC. The node automatically converts between your selected timezone and UTC:
649
-
650
- - When creating or updating records, local times are converted to UTC
651
- - When retrieving records, UTC times are converted to your local timezone
652
- - The timezone is configured in the credentials
653
- - For Search Filter operations, input dates are thoroughly converted to UTC using the configured timezone, ensuring consistency with API requirements
654
- - Output dates from all operations are converted to the configured local timezone for easier workflow handling
655
-
656
- ## Limitations
657
-
658
- ### API Limits
659
-
660
- - Maximum 500 records per page in query results
661
- - Maximum 50 pages per query operation
662
- - Maximum 500 OR conditions in filters
663
- - Maximum 1 User Defined Field per query
664
-
665
- ### Entity-Specific Limitations
666
-
667
- - Some entities may not support all operations (e.g., Project Phases cannot be deleted)
668
- - Parent-child relationships require specific handling
669
- - Some fields may be read-only or have specific validation rules
670
-
671
- ### Performance Considerations
672
-
673
- - Large queries may be slow and should be optimised with filters
674
- - Column selection can significantly improve performance by reducing payload size
675
- - Complex workflows with many API calls may hit rate limits
676
- - 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.
677
-
678
- ## Troubleshooting
679
-
680
- ### Common Issues
681
-
682
- - **Authentication Errors**: Verify your API credentials and ensure the API user has appropriate permissions
683
- - **Field Validation Errors**: Check field requirements in the Autotask API documentation
684
- - **Rate Limiting**: If you encounter rate limiting, reduce the frequency of API calls or implement retry logic
685
-
686
- ### Reporting Bugs
687
-
688
- If you encounter any bugs or issues with this integration:
689
-
690
- 1. Check the [GitHub Issues](https://github.com/msoukhomlinov/n8n-nodes-autotask/issues) to see if the problem has already been reported
691
- 2. If not, please submit a new issue with:
692
- - A clear description of the problem
693
- - Steps to reproduce the issue
694
- - Expected vs actual behaviour
695
- - Your environment details (n8n version, Node.js version)
696
- - Any relevant error messages or screenshots
697
-
698
- Bug reports should be submitted via GitHub at: https://github.com/msoukhomlinov/n8n-nodes-autotask/issues
699
-
700
- ## Resources
701
-
702
- - [Autotask API Documentation](https://ww6.autotask.net/help/developerhelp/Content/APIs/REST/REST_API_Home.htm)
703
- - [n8n Documentation](https://docs.n8n.io/)
704
- - [GitHub Repository](https://github.com/msoukhomlinov/n8n-nodes-autotask)
705
-
706
- ## Support
707
-
708
- If you find this node helpful and want to support its ongoing development, you can buy me a coffee:
709
-
710
- [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
711
-
712
- Your support helps maintain this project and develop new features.
713
-
714
- ## License
715
-
716
- [MIT](LICENSE)
1
+ # n8n-nodes-autotask
2
+
3
+ ![n8n-nodes-autotask](https://img.shields.io/badge/n8n--nodes--autotask-1.3.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. When Mapping Column Mode is set to "Map automatically" (`autoMapInputData`), the node uses incoming item data directly and passes all fields whose keys match the selected entity's schema IDs, regardless of whether those columns are toggled off in the UI. Node parameter mappings are ignored in this mode (matching n8n's standard resource mapper behaviour). `bodyJson` still takes final precedence as an override.
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
+ - **Dry Run Mode**: Preview write operations (create, update, delete) without making actual changes. When enabled, returns a preview of the request that would be sent, useful for testing and validation
212
+
213
+ ### API Threshold Resource
214
+
215
+ The API Threshold resource provides a simple way to monitor your Autotask API usage limits and current consumption. This helps users:
216
+ - Track how many API requests have been made in the current timeframe
217
+ - See the maximum allowed requests (threshold limit)
218
+ - View the usage as a percentage and categorized level (Normal, Moderate, High, Critical)
219
+ - Calculate remaining available requests
220
+ - Monitor timeframe duration for rate limits
221
+
222
+ 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.
223
+
224
+ ### AI Agent Playbook
225
+
226
+ This node is optimised for AI agents and tool-calling systems with specialised features designed for autonomous operation.
227
+
228
+ #### Quick Start for AI Agents
229
+
230
+ **1. Introspect Resources**
231
+ ```javascript
232
+ // Discover available fields and requirements
233
+ operation: aiHelper.describeResource
234
+ params: { resource: "ticket", mode: "write" }
235
+ ```
236
+
237
+ **2. Prepare Data**
238
+ ```javascript
239
+ // Use JSON parameters for direct data input
240
+ bodyJson: {
241
+ "title": "API Integration Issue",
242
+ "description": "Customer reporting connection problems",
243
+ "priority": "Medium",
244
+ "status": "New"
245
+ }
246
+ ```
247
+
248
+ Note: You may provide labels for picklist/reference fields in `bodyJson` (e.g., `status: "New"`). They are automatically resolved to IDs pre-flight.
249
+
250
+ **3. Preview First (Optional)**
251
+ ```javascript
252
+ // Test your request without making API calls
253
+ dryRun: true
254
+ ```
255
+
256
+ **4. Execute with Optimal Output**
257
+ ```javascript
258
+ // Choose output format for token efficiency
259
+ outputMode: "rawIds" // Most efficient
260
+ outputMode: "idsAndLabels" // Default (balanced)
261
+ outputMode: "labelsOnly" // Most readable
262
+ ```
263
+
264
+ #### AI Helper Operations
265
+
266
+ **Introspection Endpoint:**
267
+ - `aiHelper.describeResource(resource, mode)` - Get field metadata, requirements, constraints, and **entity dependencies**
268
+ - `aiHelper.listPicklistValues(resource, fieldId, query, limit, page)` - Get valid values for dropdown fields
269
+ - `aiHelper.validateParameters(resource, mode, fieldValues)` - **NEW:** Validate field values without API calls - pre-flight validation
270
+
271
+ **Dynamic Dependency Discovery:**
272
+ - **Reference fields** show what entity they link to (e.g., `companyID → company`)
273
+ - **Field dependencies** reveal required relationships (e.g., `contactID requires: companyID`)
274
+ - **Workflow guidance** provides creation order tips (e.g., "Ensure company exists before creating contact")
275
+
276
+ **Enhanced Validation:**
277
+ - **JSON Schema validation** - Immediate feedback on malformed `bodyJson`/`selectColumnsJson`
278
+ - **Parameter pre-validation** - Validate field values, types, dependencies without API calls
279
+ - **Structured error responses** - Detailed validation results with field-by-field feedback
280
+
281
+ **JSON Parameter Fallbacks:**
282
+ - `bodyJson` - Override UI mappings for write operations (create/update)
283
+ - `selectColumnsJson` - Specify fields for read operations as JSON array
284
+
285
+ **Agent-Friendly Features:**
286
+ - `outputMode` - Control response format (rawIds/idsAndLabels/labelsOnly)
287
+ - `dryRun` - Get request preview without API execution
288
+ - Smart error hints with actionable suggestions
289
+
290
+ #### Tool Configuration for Maximum Effectiveness
291
+
292
+ For optimal AI agent integration, configure multiple instances of this node as separate tools. This provides focused, reliable access to different resource types.
293
+
294
+ **Recommended Tool Setup:**
295
+
296
+ ```javascript
297
+ // Tool 1: Resource Discovery and Field Introspection
298
+ {
299
+ name: "autotask_inspector",
300
+ description: "Discover Autotask resources, fields, and valid values",
301
+ resource: "aiHelper",
302
+ operations: ["describeResource", "listPicklistValues"]
303
+ }
304
+
305
+ // Tool 2: Contact Management
306
+ {
307
+ name: "autotask_contacts",
308
+ description: "Read and write Autotask contacts and people",
309
+ resource: "contact",
310
+ operations: ["get", "getMany", "create", "update"],
311
+ defaultParams: {
312
+ outputMode: "idsAndLabels",
313
+ selectColumnsJson: ["id", "firstName", "lastName", "emailAddress", "companyID", "title", "phone"]
314
+ }
315
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
316
+ }
317
+
318
+ // Tool 3: Company/Account Management
319
+ {
320
+ name: "autotask_companies",
321
+ description: "Read and write Autotask companies and accounts",
322
+ resource: "company",
323
+ operations: ["get", "getMany", "create", "update"],
324
+ defaultParams: {
325
+ outputMode: "idsAndLabels",
326
+ selectColumnsJson: ["id", "companyName", "companyType", "phone", "address1", "city", "state"]
327
+ }
328
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
329
+ }
330
+
331
+ // Tool 4: General Resource Access
332
+ {
333
+ name: "autotask_resources",
334
+ description: "Access any Autotask resource with full flexibility",
335
+ allResources: true,
336
+ defaultParams: {
337
+ outputMode: "rawIds" // Most token-efficient for exploratory queries
338
+ }
339
+ // Accepts labels in bodyJson; labels are auto-resolved to IDs
340
+ }
341
+ ```
342
+
343
+ **Usage Pattern:**
344
+ 1. **Start with Inspector** - Use `autotask_inspector` to understand field requirements
345
+ 2. **Use Focused Tools** - Call `autotask_contacts` or `autotask_companies` for CRM related operations
346
+ 3. **Use Specialist Tools** - Use `autotask_resources` for lookups of Autotask MSP staff (resources)
347
+
348
+ **Benefits:**
349
+ - **Faster execution** - Pre-configured tools reduce parameter complexity
350
+ - **Better reliability** - Focused tools have predictable schemas
351
+ - **Token efficiency** - Default parameters optimised for each use case
352
+ - **Easier debugging** - Clear separation of concerns
353
+
354
+ #### Environment Setup
355
+
356
+ For AI tool usage, set this environment variable:
357
+
358
+ ```bash
359
+ N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
360
+ ```
361
+
362
+ Configuration options:
363
+ - Add to your `.env` file
364
+ - Set in system environment variables
365
+ - Include in Docker/container configuration
366
+ - Add to startup command: `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true n8n start`
367
+
368
+ #### Example Agent Workflow
369
+
370
+ **Scenario: Create a contact for a new company**
371
+
372
+ ```javascript
373
+ // 1. Inspect contact requirements using dedicated tool
374
+ autotask_inspector.call({
375
+ operation: "describeResource",
376
+ targetResource: "contact",
377
+ mode: "write"
378
+ })
379
+ // Returns: {
380
+ // fields: [
381
+ // { id: "companyID", required: true, isReference: true, referencesEntity: "company" },
382
+ // { id: "firstName", required: true, type: "string" },
383
+ // { id: "lastName", required: true, type: "string" }
384
+ // ],
385
+ // notes: [
386
+ // "Required fields for write: companyID, firstName, lastName",
387
+ // "Reference fields (must reference existing entities): companyID → company",
388
+ // "Workflow tip: Ensure referenced company exists before creating contact."
389
+ // ]
390
+ // }
391
+
392
+ // 2. Check company picklist values if needed
393
+ autotask_inspector.call({
394
+ operation: "listPicklistValues",
395
+ targetResource: "contact",
396
+ fieldId: "companyID",
397
+ query: "Tech Solutions" // Search for company
398
+ })
399
+
400
+ // 2.5. Validate parameters before creation (NEW!)
401
+ autotask_inspector.call({
402
+ operation: "validateParameters",
403
+ targetResource: "contact",
404
+ mode: "create",
405
+ fieldValues: {
406
+ "firstName": "John",
407
+ "lastName": "Smith",
408
+ "emailAddress": "john.smith@techsolutions.com",
409
+ "companyID": 12345,
410
+ "title": "IT Manager"
411
+ }
412
+ })
413
+ // Returns: {
414
+ // isValid: true,
415
+ // errors: [],
416
+ // warnings: [
417
+ // { field: "companyID", message: "Reference field 'companyID' points to company. Ensure the referenced record exists.", code: "REFERENCE_EXISTENCE_CHECK" }
418
+ // ],
419
+ // summary: { totalFields: 15, providedFields: 5, validFields: 5, requiredFieldsMissing: 0, invalidValues: 0 }
420
+ // }
421
+
422
+ // 3. Create contact using focused tool
423
+ autotask_contacts.call({
424
+ operation: "create",
425
+ bodyJson: {
426
+ "firstName": "John",
427
+ "lastName": "Smith",
428
+ "emailAddress": "john.smith@techsolutions.com",
429
+ "companyID": 12345,
430
+ "title": "IT Manager"
431
+ },
432
+ dryRun: true // Preview first
433
+ })
434
+ // Dry-run response includes a `resolutions` array when labels were resolved to IDs, e.g.:
435
+ // resolutions: [{ field: 'status', from: 'New', to: 1, method: 'picklist' }]
436
+
437
+ // 4. Execute after validation
438
+ autotask_contacts.call({
439
+ operation: "create",
440
+ bodyJson: { /* same data */ },
441
+ outputMode: "idsAndLabels"
442
+ })
443
+
444
+ // 5. Retrieve company details using focused tool
445
+ autotask_companies.call({
446
+ operation: "get",
447
+ id: 12345
448
+ })
449
+ ```
450
+
451
+ #### Error Self-Healing
452
+
453
+ Errors include structured hints to help agents self-correct:
454
+
455
+ ```javascript
456
+ // Error response includes actionable guidance
457
+ {
458
+ "error": "Field 'priority' has invalid value 'Urgent'",
459
+ "extensions": {
460
+ "hint": "Use aiHelper.listPicklistValues('ticket', 'priority') to get valid options, then retry with a valid value.",
461
+ "suggestions": [
462
+ "Get valid values: aiHelper.listPicklistValues('ticket', 'priority')",
463
+ "Use exact values from the picklist response"
464
+ ]
465
+ }
466
+ }
467
+ ```
468
+
469
+ #### Best Practices for Agents
470
+
471
+ - **Configure focused tools** - Set up separate tools for inspector, contacts, companies, and general resources
472
+ - **Start with inspection** - Always call `autotask_inspector.describeResource` first to understand field requirements
473
+ - **Use focused tools** - Prefer `autotask_contacts` or `autotask_companies` over general tools for better reliability
474
+ - **Validate before execution** - Use `autotask_inspector.validateParameters` for pre-flight validation to catch errors early
475
+ - **Optimise responses** - Use `selectColumnsJson` to reduce payload size and `outputMode: "rawIds"` for token efficiency
476
+ - **Double-check with dry-run** - Use `dryRun: true` to preview requests before execution, especially for write operations
477
+ - **Handle errors smartly** - Follow the structured hints in error responses for self-correction
478
+ - **Cache discoveries** - Store field metadata and picklist values to avoid repeated introspection calls
479
+ - **JSON validation** - Invalid JSON in `bodyJson`/`selectColumnsJson` is caught immediately with helpful error messages
480
+
481
+ #### Troubleshooting
482
+
483
+ **Tool Not Available:** Ensure `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` is set
484
+ **No Parameters Visible:** Call `aiHelper.describeResource` to inspect available fields
485
+ **Large Responses:** Use `selectColumnsJson` and `outputMode: "rawIds"` for efficiency
486
+ **Validation Errors:** Follow error hints to resolve field requirement issues
487
+
488
+ ## Usage
489
+
490
+ ### Basic Example: Creating a Ticket
491
+
492
+ 1. Add an **Autotask** node to your workflow
493
+ 2. Select **Ticket** as the resource
494
+ 3. Select **Create** as the operation
495
+ 4. Configure the required fields (Title, Status, etc.)
496
+ 5. Connect to a trigger or previous node
497
+ 6. Execute the workflow
498
+
499
+ ### Intermediate Example: Querying Projects with Filters
500
+
501
+ 1. Add an **Autotask** node to your workflow
502
+ 2. Select **Project** as the resource
503
+ 3. Select **Get Many** as the operation
504
+ 4. Add filter conditions (e.g., Status equals "Active")
505
+ 5. Choose whether to retrieve all results or limit the number:
506
+ - Toggle "Get All" to true to retrieve all matching records
507
+ - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
508
+ 6. Connect to a trigger or previous node
509
+ 7. Execute the workflow
510
+
511
+ ### Advanced Example: Using Column Selection and Reference Labels
512
+
513
+ 1. Add an **Autotask** node to your workflow
514
+ 2. Select **Ticket** as the resource
515
+ 3. Select **Get Many** as the operation
516
+ 4. Add filter conditions as needed
517
+ 5. Enable **Select Columns** to choose specific fields to return
518
+ 6. Select only the fields you need in the response (improves performance)
519
+ 7. Enable **Add Picklist Labels** to get human-readable values for picklist fields
520
+ 8. Enable **Add Reference Labels** to get human-readable values for reference fields
521
+ 9. Enable **Flatten User-Defined Fields** to bring UDFs to the top level of response objects
522
+ 10. Execute the workflow to get tickets with only the selected fields and human-readable labels
523
+
524
+ ### Advanced Example: Complex Filtering with Get Many Advanced
525
+
526
+ 1. Add an **Autotask** node to your workflow
527
+ 2. Select **Ticket** as the resource
528
+ 3. Select **Get Many Advanced** as the operation
529
+ 4. Build a complex filter, for example:
530
+ ```json
531
+ {
532
+ "filter": [
533
+ {
534
+ "op": "and",
535
+ "items": [
536
+ {
537
+ "field": "status",
538
+ "op": "noteq",
539
+ "value": 5
540
+ },
541
+ {
542
+ "op": "or",
543
+ "items": [
544
+ {
545
+ "field": "priority",
546
+ "op": "eq",
547
+ "value": 6
548
+ },
549
+ {
550
+ "field": "dueDateTime",
551
+ "op": "lt",
552
+ "value": "{{ $now.plus(3, 'days').toLocal()}}"
553
+ }
554
+ ]
555
+ }
556
+ ]
557
+ }
558
+ ]
559
+ }
560
+ ```
561
+ [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)
562
+ 5. Choose whether to retrieve all results or limit the number:
563
+ - Toggle "Get All" to true to retrieve all matching records
564
+ - Toggle "Get All" to false and set "Max Records" (1-500) to limit the results
565
+ 6. Enable **Select Columns** to choose specific fields to return
566
+ 7. Enable **Add Reference Labels** and **Add Picklist Labels** for human-readable values
567
+ 8. Execute the workflow to retrieve tickets that are not complete AND either have priority 6 OR are due within the next 3 days
568
+
569
+ ### Example: Monitoring API Usage with API Threshold
570
+
571
+ 1. Add an **Autotask** node to your workflow
572
+ 2. Select **API Threshold** as the resource
573
+ 3. The operation **Get API Usage** will be automatically selected (it's the only available operation)
574
+ 4. Execute the node to receive current API usage information including:
575
+ - Current usage count
576
+ - Maximum threshold (limit)
577
+ - Usage percentage
578
+ - Usage level (Normal, Moderate, High, Critical)
579
+ - Remaining requests
580
+ - Timeframe duration
581
+ 5. You can use this information with IF nodes to implement conditional logic:
582
+ - Pause workflows when usage is too high
583
+ - Throttle requests during peak usage periods
584
+ - Log warnings when approaching limits
585
+ - Only execute non-critical operations when usage is below certain thresholds
586
+
587
+ ### Advanced Example: Working with Parent-Child Relationships
588
+
589
+ Many Autotask entities have parent-child relationships (e.g., Companies and Contacts). To work with these:
590
+
591
+ 1. First, retrieve or create the parent entity
592
+ 2. Use the parent entity's ID in the child entity operations
593
+ 3. For example, to create a Contact for a Company:
594
+ - First node: Get or create the Company
595
+ - Second node: Create a Contact with the Company ID
596
+
597
+ ### Example: Setting Up a Webhook Trigger
598
+
599
+ 1. Add an **Autotask Trigger** node to your workflow
600
+ 2. Select the entity type to monitor (Companies, Contacts, Tickets, etc.)
601
+ 3. Select the events to subscribe to (Create, Update, Delete)
602
+ 4. Configure the webhook URL (n8n will handle this automatically)
603
+ 5. Optionally specify fields to include in the webhook payload
604
+ 6. Optionally exclude specific resources from triggering the workflow
605
+ 7. Configure email notifications for webhook delivery failures if needed
606
+ 8. Save and activate the workflow
607
+ 9. The node will automatically register the webhook with Autotask
608
+ 10. When events occur in Autotask, they will trigger your workflow
609
+ 11. When the workflow is deactivated, the webhook will be automatically removed
610
+
611
+ ## Configuration
612
+
613
+ ### Caching Options
614
+
615
+ The node includes an enhanced file-based caching system to improve performance by reducing API calls:
616
+
617
+ - **Enable Field Caching**: Toggle caching on/off
618
+ - **Cache TTL**: How long to cache field values (in seconds)
619
+ - **Cache Entity Info**: Whether to cache entity information and field definitions
620
+ - **Entity Info TTL**: How long to cache entity information
621
+ - **Cache Reference Fields**: Whether to cache reference field values
622
+ - **Reference Fields TTL**: How long to cache reference field values
623
+ - **Cache Picklists**: Whether to cache picklist values
624
+ - **Picklists TTL**: How long to cache picklist values
625
+ - **File-based Cache**: Cache is stored in files that can be shared between workflows and runs
626
+ - **Cache Directory**: Optional path to a directory where cache files will be stored
627
+
628
+ > **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.
629
+
630
+ ### Label Enrichment and Field Processing
631
+
632
+ The node provides options to enrich entities with human-readable labels and simplify field access:
633
+
634
+ - **Add Picklist Labels**: Adds "_label" fields for picklist values (e.g., Status_label: "In Progress")
635
+ - **Add Reference Labels**: Adds "_label" fields for reference values (e.g., Company_label: "Acme Corporation")
636
+ - **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)
637
+
638
+ ### Column Selection
639
+
640
+ To improve performance and reduce payload size, you can select specific columns to return:
641
+
642
+ - **Select Columns**: Choose which fields to include in the response
643
+ - Works with all get operations (get, getMany, getManyAdvanced)
644
+ - Compatible with label enrichment features
645
+
646
+ ### Timezone Handling
647
+
648
+ All dates and times in the Autotask API are in UTC. The node automatically converts between your selected timezone and UTC:
649
+
650
+ - When creating or updating records, local times are converted to UTC
651
+ - When retrieving records, UTC times are converted to your local timezone
652
+ - The timezone is configured in the credentials
653
+ - For Search Filter operations, input dates are thoroughly converted to UTC using the configured timezone, ensuring consistency with API requirements
654
+ - Output dates from all operations are converted to the configured local timezone for easier workflow handling
655
+
656
+ ## Limitations
657
+
658
+ ### API Limits
659
+
660
+ - Maximum 500 records per page in query results
661
+ - Maximum 50 pages per query operation
662
+ - Maximum 500 OR conditions in filters
663
+ - Maximum 1 User Defined Field per query
664
+
665
+ ### Entity-Specific Limitations
666
+
667
+ - Some entities may not support all operations (e.g., Project Phases cannot be deleted)
668
+ - Parent-child relationships require specific handling
669
+ - Some fields may be read-only or have specific validation rules
670
+
671
+ ### Performance Considerations
672
+
673
+ - Large queries may be slow and should be optimised with filters
674
+ - Column selection can significantly improve performance by reducing payload size
675
+ - Complex workflows with many API calls may hit rate limits
676
+ - 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.
677
+
678
+ ## Troubleshooting
679
+
680
+ ### Common Issues
681
+
682
+ - **Authentication Errors**: Verify your API credentials and ensure the API user has appropriate permissions
683
+ - **Field Validation Errors**: Check field requirements in the Autotask API documentation
684
+ - **Rate Limiting**: If you encounter rate limiting, reduce the frequency of API calls or implement retry logic
685
+
686
+ ### Reporting Bugs
687
+
688
+ If you encounter any bugs or issues with this integration:
689
+
690
+ 1. Check the [GitHub Issues](https://github.com/msoukhomlinov/n8n-nodes-autotask/issues) to see if the problem has already been reported
691
+ 2. If not, please submit a new issue with:
692
+ - A clear description of the problem
693
+ - Steps to reproduce the issue
694
+ - Expected vs actual behaviour
695
+ - Your environment details (n8n version, Node.js version)
696
+ - Any relevant error messages or screenshots
697
+
698
+ Bug reports should be submitted via GitHub at: https://github.com/msoukhomlinov/n8n-nodes-autotask/issues
699
+
700
+ ## Resources
701
+
702
+ - [Autotask API Documentation](https://ww6.autotask.net/help/developerhelp/Content/APIs/REST/REST_API_Home.htm)
703
+ - [n8n Documentation](https://docs.n8n.io/)
704
+ - [GitHub Repository](https://github.com/msoukhomlinov/n8n-nodes-autotask)
705
+
706
+ ## Support
707
+
708
+ If you find this node helpful and want to support its ongoing development, you can buy me a coffee:
709
+
710
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-yellow.svg)](https://buymeacoffee.com/msoukhomlinov)
711
+
712
+ Your support helps maintain this project and develop new features.
713
+
714
+ ## License
715
+
716
+ [MIT](LICENSE)