n8n-nodes-commercetools 0.1.15 → 0.1.17

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,754 +1,729 @@
1
- ![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)
2
-
3
-
4
- # n8n-nodes-commercetools
5
-
6
- This repository provides a custom [n8n](https://n8n.io) node for integrating with [Commercetools](https://commercetools.com). It includes all required credentials, node definitions, utilities to interact with the Commercetools API, and **AWS SQS integration with Lambda processing**.
7
-
8
- ## Features
9
-
10
- - **Complete Commercetools Integration**: Full support for products, categories, and customers
11
- - **Webhook Product Trigger**: Native trigger for product events; send directly to n8n webhooks or route through AWS SQS/Lambda using the provided automation scripts
12
- - **AWS SQS + Lambda**: Scalable, reliable event processing with AWS infrastructure (CloudFormation + helper scripts included)
13
- - **Event Types**: Product Event Triggers
14
- product created,product published,product unpublished,product deleted,
15
- product added to category,product removed from category,
16
- product image added,product slug changed,product state transition,product reverted staged changes,
17
- product variant added,product variant deleted,
18
- product price added,product price changed,product price removed,product prices set,product price mode set,product price key set,product price discounts set,product price external discount set,
19
- product price custom field added,product price custom field changed,product price custom field removed,
20
- product price custom fields set,product price custom fields removed.
21
- - **Monitoring**: CloudWatch alarms and logging for production use
22
- - **Multi-Environment**: Support for dev, staging, and production deployments
23
-
24
-
25
- ## Quick Start
26
-
27
- **To start developing and testing the Commercetools node:**
28
-
29
- ```bash
30
- npm install
31
- npm run dev
32
- ```
33
-
34
- This will start n8n with the Commercetools node loaded and hot reload enabled.
35
-
36
- ## Webhook Trigger
37
-
38
- Use the Commercetools Trigger node to receive events directly in n8n.
39
-
40
- 1. Add the **Commercetools Trigger** node and choose **Webhook** as the destination (use the SQS steps below if you prefer queue delivery).
41
- 2. Activate your workflow to generate the webhook URL and set the `WEBHOOK_URL` environment variable in your CommerceTools subscription or Lambda deployment so events post to this URL. The URL typically looks like `https://<n8n-host>/webhook/<path>/commercetools-product-events`.
42
- 3. In CommerceTools, create or update a subscription pointing to that webhook URL and enable the product event types you need (Created, Published, Deleted). If you deploy via Lambda + SQS, ensure the Lambda forwards the payloads to `WEBHOOK_URL` using the provided AWS infrastructure utilities.
43
-
44
- ## AWS SQS + Lambda Integration
45
-
46
- For production-grade event processing, this node supports AWS SQS queues with Lambda function processing:
47
-
48
- ### Quick Deploy
49
-
50
- ```bash
51
- # Deploy AWS infrastructure
52
- cd aws
53
- ./deploy.sh deploy
54
-
55
- # Get configuration values
56
- ./deploy.sh outputs
57
- ```
58
-
59
- ### Configure SQS in n8n
60
-
61
- 1. Add CommerceTools Trigger node to your workflow
62
- 2. Select **"Amazon SQS"** as destination type
63
- 3. Configure with deployment outputs:
64
- - **AWS Region**: Your deployment region
65
- - **SQS Queue URL**: From deployment outputs
66
- - **AWS Access Key ID** and **Secret**: Your AWS credentials
67
- - **Lambda Function Name**: `commercetools-integration-dev-product-processor`
68
- - **CTP Project Key**: `n8n-ct-integration`
69
- - **Product Events**: Select `Product Published`
70
-
71
- ### Benefits of SQS Integration
72
-
73
- - **Reliability**: Messages are persisted and retried automatically
74
- - **Scalability**: Lambda scales automatically based on queue depth
75
- - **Monitoring**: CloudWatch alarms for errors and failed messages
76
- - **Dead Letter Queue**: Failed messages are preserved for investigation
77
- - **Cost-Effective**: Pay only for what you use
78
-
79
- See [aws/README.md](aws/README.md) for detailed configuration and customization options. Additional AWS resources: [AWS_AUTOMATION_PLAN.md](AWS_AUTOMATION_PLAN.md), [AWS_ATTRIBUTE_REFERENCE.md](AWS_ATTRIBUTE_REFERENCE.md), and [AUTOMATIC_SETUP.md](AUTOMATIC_SETUP.md).
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
- ## Configuration Options
88
-
89
- Below are the main configuration options and parameters available for the Commercetools node (resource: product or category):
90
-
91
- ### Common Parameters
92
- - **resource**: Select 'product' or 'category' to access respective operations.
93
- - **operation**: Choose the desired operation (e.g., create, query, get, update, delete, etc.).
94
- - **Credentials**: Select your configured Commercetools OAuth2 credentials.
95
-
96
- ### Product Operation-Specific Parameters
97
-
98
- #### Create Product
99
- - **productDraft**: JSON object with product details (name, slug, productType, masterVariant, etc.).
100
- - **additionalFieldsCreate**: Optional fields for additional product properties.
101
-
102
- #### Query Products
103
- - **returnAll**: Boolean to return all products (up to 500 per request).
104
- - **limit**: Number of products to return per request.
105
- - **offset**: Pagination offset.
106
- - **additionalFields**: Optional filters, sorting, and predicate variables.
107
-
108
- #### Search Products
109
- - **searchRequest**: JSON object for advanced search queries.
110
- - **additionalFieldsSearch**: Optional search parameters (limit, offset, staged, etc.).
111
-
112
- #### Get Product / Get By Key
113
- - **productId** or **productKey**: ID or key of the product to retrieve.
114
- - **additionalFieldsGet**: Optional fields for expanded data.
115
-
116
- #### Update Product / Update By Key
117
- - **productId** or **productKey**: ID or key of the product to update.
118
- - **version**: Product version (required for updates).
119
- - **actions**: Array of update actions (JSON).
120
- - **updateActions**: UI builder that lets you stack multiple product update actions without hand-writing JSON. These can be combined with the `actions` array if you need to mix UI-built and raw payloads.
121
- - **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
122
-
123
- #### Delete Product / Delete By Key
124
- - **productId** or **productKey**: ID or key of the product to delete.
125
- - **version**: Product version (required for deletion).
126
- - **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
127
-
128
- #### Query Product Selections
129
- - **productId** or **productKey**: ID or key of the product.
130
- - **additionalFieldsSelections**: Optional fields (expand, limit, offset, withTotal, customParameters).
131
-
132
- #### Upload Product Image
133
- - **productId**: ID of the product to upload the image to.
134
- - **binaryPropertyName**: Name of the binary property containing the image.
135
- - **additionalFieldsUpload**: Optional fields (variantId, sku, staged, filename, externalUrl, label, customParameters).
136
-
137
-
138
- ### Customer Operation-Specific Parameters
139
-
140
- #### Authenticate Customer
141
-
142
- - **email**: Customer's email.
143
- - **password**: Customer password.
144
-
145
- #### Authenticate Customer in Store
146
-
147
- - **storeKey**: Key of the store.
148
- - **email**: Customer email.
149
- - **password**: Customer password.
150
-
151
-
152
- #### Change Customer Password
153
-
154
- - **customerId**: ID of the customer.
155
- - **version**: Customer version.
156
- - **passwordToken**: PasswordToken to authenticate.
157
- - **newPassword**: New password.
158
-
159
- #### Change Customer Password in Store
160
-
161
- - **storeKey**: Store key.
162
- - **customerId**: ID of the customer.
163
- - **version**: Customer version.
164
- - **passwordToken**: PasswordToken to authenticate.
165
- - **newPassword**: New password.
166
-
167
- #### Check if Customer Exists
168
-
169
- - **customerId**: Customer ID.
170
-
171
- #### Check if Customer Exists by Key
172
-
173
- - **customerKey**: Customer key.
174
-
175
- #### Check if Any Customer Matches the Query
176
-
177
- - **where**: Predicate expression.
178
- - **additionalFieldsCheckQuery**: Optional parameters (store projection, expand).
179
-
180
- #### Check if Customer Exists in Store
181
-
182
- - **storeKey**: Store key.
183
- - **customerId**: Customer ID.
184
-
185
- #### Check if Customer Exists in Store by Key
186
-
187
- - **storeKey**: Store key.
188
- - **customerKey**: Customer key.
189
-
190
- #### Check if Any Customer Matches the Query in Store
191
-
192
- - **storeKey**: Store key.
193
- - **where**: Predicate filter.
194
- - **additionalFieldsCheckQueryStore**: Optional parameters.
195
-
196
- #### Create Customer
197
-
198
- - **customerDraft**: Customer JSON object (email, firstName, lastName, password, custom, etc.).
199
- - **additionalFieldsCreate**: Optional fields (expand, localeProjection, etc.).
200
-
201
- #### Create Email Verification Token
202
-
203
- - **id**: Customer ID.
204
- - **version**: Customer version.
205
-
206
- #### Create Email Verification Token in Store
207
-
208
- - **storeKey**: Store key.
209
- - **id**: Customer ID.
210
- - **version**: Customer version.
211
- - **ttlMinutes**: Optional.
212
-
213
- #### Create Customer in Store
214
-
215
- - **storeKey**: Store key.
216
- - **customerDraft**: Customer draft JSON.
217
- - **additionalFieldsCreateStore**: Optional fields.
218
-
219
-
220
- #### Create Password Reset Token
221
-
222
- - **email**: Customer email.
223
-
224
- #### Create Password Reset Token in Store
225
-
226
- - **storeKey**: Store key.
227
- - **email**: Customer email.
228
-
229
-
230
- #### Delete Customer
231
-
232
- - **customerId**: ID of the customer.
233
- - **version**: Version of the customer.
234
-
235
- #### Delete Customer by Key
236
-
237
- - **customerKey**: Key of the customer.
238
- - **version**: Version.
239
- - **additionalFieldsDeleteKey**: Optional.
240
-
241
- #### Delete Customer in Store
242
-
243
- - **storeKey**: Store key.
244
- - **customerId**: Customer ID.
245
- - **version**: Version.
246
-
247
- #### Delete Customer in Store by Key
248
-
249
- - **storeKey**: Store key.
250
- - **customerKey**: Customer key.
251
- - **version**: Version.
252
-
253
- #### Get Customer
254
-
255
- - **customerId**: Customer ID.
256
- - **additionalFieldsGet**: Optional fields (expand, localeProjection).
257
-
258
- #### Get Customer By Email Token
259
-
260
- - **emailToken**: Token value.
261
- - **additionalFieldsGetToken**: Optional.
262
-
263
- #### Get Customer By Key
264
-
265
- - **customerKey**: Customer key.
266
- - **additionalFieldsGetKey**: Optional.
267
-
268
- #### Get Customer By Password Token
269
-
270
- - **passwordToken**: Token value.
271
- - **additionalFieldsGetPassToken**: Optional.
272
-
273
- #### Get Customer in Store
274
-
275
- - **storeKey**: Store key.
276
- - **customerId**: Customer ID.
277
- - **additionalFieldsGetStore**: Optional.
278
-
279
- #### Get Customer in Store by Email Token
280
-
281
- - **storeKey**: Store key.
282
- - **emailToken**: Token value.
283
- - **additionalFieldsGetStoreEmailToken**: Optional.
284
-
285
- #### Get Customer in Store by Key
286
-
287
- - **storeKey**: Store key.
288
- - **customerKey**: Customer key.
289
- - **additionalFieldsGetStoreKey**: Optional.
290
-
291
- #### Get Customer in Store by Password Token
292
-
293
- - **storeKey**: Store key.
294
- - **passwordToken**: Token value.
295
- - **additionalFieldsGetStorePassToken**: Optional.
296
-
297
- #### Query Customers
298
-
299
- - **where**: Predicate expression.
300
- - **limit**: Number of results.
301
- - **offset**: Offset for pagination.
302
- - **sort**: Sorting expressions.
303
- - **additionalFieldsQuery**: Optional fields.
304
-
305
- #### Query Customers in Store
306
-
307
- - **storeKey**: Store key.
308
- - **where**: Predicate expression.
309
- - **limit**: Number of results.
310
- - **offset**: Pagination offset.
311
- - **sort**: Sorting expression.
312
- - **additionalFieldsQueryStore**: Optional.
313
-
314
-
315
- #### Reset Customer Password
316
-
317
- - **tokenValue**: Password reset token.
318
- - **newPassword**: New password.
319
- - **additionalFieldsResetPwd**: Optional.
320
-
321
- #### Reset Customer Password in Store
322
-
323
- - **storeKey**: Store key.
324
- - **tokenValue**: Token.
325
- - **newPassword**: New password.
326
- - **additionalFieldsResetPwdStore**: Optional.
327
-
328
-
329
- #### Update Customer
330
-
331
- - **customerId**: Customer ID.
332
- - **version**: Customer version.
333
- - **actions**: Array of update actions.
334
- - **additionalFieldsUpdate**: Optional (expand).
335
-
336
- #### Update Customer by Key
337
-
338
- - **customerKey**: Customer key.
339
- - **version**: Version.
340
- - **actions**: Update actions array.
341
- - **additionalFieldsUpdateKey**: Optional.
342
-
343
- #### Update Customer in Store
344
-
345
- - **storeKey**: Store key.
346
- - **customerId**: Customer ID.
347
- - **version**: Version.
348
- - **actions**: Update actions array.
349
- - **additionalFieldsUpdateStore**: Optional.
350
-
351
- #### Update Customer in Store by Key
352
-
353
- - **storeKey**: Store key.
354
- - **customerKey**: Customer key.
355
- - **version**: Version.
356
- - **actions**: Update actions.
357
- - **additionalFieldsUpdateStoreKey**: Optional.
358
-
359
- #### Verify Customer Email
360
-
361
- - **tokenValue**: Email verification token.
362
- - **additionalFieldsVerify**: Optional.
363
-
364
- #### Verify Customer Email in Store
365
-
366
- - **storeKey**: Store key.
367
- - **tokenValue**: Verification token.
368
- - **additionalFieldsVerifyStore**: Optional.
369
-
370
- ### Category Operation-Specific Parameters
371
-
372
- #### Create Category
373
- - **categoryDraft**: JSON object with category details (name, slug, parent, orderHint, etc.).
374
- - **additionalFieldsCreate**: Optional fields for additional category properties.
375
-
376
- #### Query Categories
377
- - **returnAll**: Boolean to return all categories (up to 500 per request).
378
- - **limit**: Number of categories to return per request.
379
- - **offset**: Pagination offset.
380
- - **additionalFields**: Optional filters, sorting, and predicate variables.
381
-
382
- #### Get Category / Get By Key
383
- - **categoryId** or **categoryKey**: ID or key of the category to retrieve.
384
- - **additionalFieldsGet**: Optional fields for expanded data.
385
-
386
- #### Update Category / Update By Key
387
- - **categoryId** or **categoryKey**: ID or key of the category to update.
388
- - **version**: Category version (required for updates).
389
- - **actions**: Array of update actions (JSON). (Categories currently require JSON actions only.)
390
- - **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
391
-
392
- #### Delete Category / Delete By Key
393
- - **categoryId** or **categoryKey**: ID or key of the category to delete.
394
- - **version**: Category version (required for deletion).
395
- - **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
396
-
397
- Refer to the node UI in n8n for detailed descriptions and validation for each parameter.
398
-
399
- Below is a sample workflow using the Commercetools node in n8n to create and query a product.
400
-
401
- ### Example: Create a Product
402
-
403
- 1. Add the **Commercetools** node to your workflow.
404
- 2. Select the **Create Product** operation.
405
- 3. Fill in the required product draft fields (e.g., name, slug, product type, etc.).
406
- 4. Select your configured Commercetools credentials.
407
- 5. Run the workflow to create a new product in your Commercetools project.
408
-
409
- **Sample Input (Product Draft):**
410
- ```json
411
- {
412
- "name": { "en": "Sample Product" },
413
- "slug": { "en": "sample-product" },
414
- "productType": { "id": "your-product-type-id" },
415
- "masterVariant": {
416
- "sku": "SKU123",
417
- "prices": [ { "value": { "currencyCode": "USD", "centAmount": 1000 } } ]
418
- }
419
- }
420
- ```
421
-
422
-
423
- ### Example: Query Products
424
-
425
- 1. Add the **Commercetools** node to your workflow.
426
- 2. Select the **Query Products** operation.
427
- 3. Optionally set filters, sorting, and pagination parameters.
428
- 4. Select your configured Commercetools credentials.
429
- 5. Run the workflow to retrieve products from your Commercetools project.
430
-
431
- **Sample Output:**
432
- ```json
433
- [
434
- {
435
- "id": "product-id-1",
436
- "name": { "en": "Sample Product" },
437
- "slug": { "en": "sample-product" }
438
- // ...other product fields
439
- }
440
- // ...more products
441
- ]
442
- ```
443
-
444
- ### Using updateActions (Product Updates)
445
-
446
- The `updateActions` fixed collection lets you compose Commercetools product update commands directly in the node UI, with helper inputs for localized data, prices, assets, and variant targeting. Highlights:
447
- - Choose whether each variant is addressed by `variantId` or `sku`, and mix multiple variant-specific actions in a single request.
448
- - Localized name/slug/meta helpers automatically map locale/value pairs to the format the Commercetools API expects.
449
- - Attribute editors support string/number/boolean parsing so you don’t need to pre-format JSON.
450
- - Asset, price, image, and search keyword builders flatten nested fixed collections (sources, dimensions, tokenizers, etc.) into valid drafts.
451
-
452
- Supported product update actions:
453
- - Add Asset
454
- - Add External Image
455
- - Add Price
456
- - Add Product Variant
457
- - Add To Category
458
- - Change Asset Name
459
- - Change Asset Order
460
- - Change Master Variant
461
- - Change Name
462
- - Change Price
463
- - Change Slug
464
- - Move Image To Position
465
- - Publish
466
- - Remove Asset
467
- - Remove From Category
468
- - Remove Image
469
- - Remove Price
470
- - Remove Variant
471
- - Revert Staged Changes
472
- - Revert Staged Variant Changes
473
- - Set Asset Custom Field
474
- - Set Asset Custom Type
475
- - Set Asset Description
476
- - Set Asset Key
477
- - Set Asset Sources
478
- - Set Asset Tags
479
- - Set Attribute
480
- - Set Attribute In All Variants
481
- - Set Category Order Hint
482
- - Set Description
483
- - Set Image Label
484
- - Set Key
485
- - Set Meta Description
486
- - Set Meta Keywords
487
- - Set Meta Title
488
- - Set Price Custom Field
489
- - Set Price Key
490
- - Set Price Mode
491
- - Set Prices
492
- - Set Product Attribute
493
- - Set Product Price Custom Type
494
- - Set Product Variant Key
495
- - Set Search Keywords
496
- - Set SKU
497
- - Set Tax Category
498
- - Transition State
499
- - Unpublish
500
-
501
- Need a field that isn’t exposed yet? Add it via the `actions` JSON array—the node merges both sources in request order.
502
-
503
- > **Transition State note:** the builder enforces that either a state ID or a state key is set per the [Commercetools Transition State action](https://docs.commercetools.com/api/projects/products#transition-state).
504
-
505
- ### Example: Create a Category
506
-
507
- 1. Add the **Commercetools** node to your workflow.
508
- 2. Select the **Create Category** operation.
509
- 3. Fill in the required category draft fields (e.g., name, slug, parent, orderHint, etc.).
510
- 4. Select your configured Commercetools credentials.
511
- 5. Run the workflow to create a new category in your Commercetools project.
512
-
513
- **Sample Input (Category Draft):**
514
- ```json
515
- {
516
- "name": { "en": "Sample Category" },
517
- "slug": { "en": "sample-category" },
518
- "orderHint": "0.1"
519
- }
520
- ```
521
-
522
- ### Example: Query Categories
523
-
524
- 1. Add the **Commercetools** node to your workflow.
525
- 2. Select the **Query Categories** operation.
526
- 3. Optionally set filters, sorting, and pagination parameters.
527
- 4. Select your configured Commercetools credentials.
528
- 5. Run the workflow to retrieve categories from your Commercetools project.
529
-
530
- **Sample Output:**
531
- ```json
532
- [
533
- {
534
- "id": "category-id-1",
535
- "name": { "en": "Sample Category" },
536
- "slug": { "en": "sample-category" }
537
- // ...other category fields
538
- }
539
- // ...more categories
540
- ]
541
- ```
542
-
543
- You can chain Commercetools node operations with other n8n nodes to build advanced workflows for product and category management, automation, and integration.
544
-
545
-
546
- ## Credential Setup
547
-
548
- To use the Commercetools node for both product and category operations, you must configure OAuth2 credentials for your Commercetools project in n8n. Follow these steps:
549
-
550
- 1. **Obtain Commercetools API credentials:**
551
- - Log in to your Commercetools Merchant Center.
552
- - Go to the API Clients section and create a new API client.
553
- - Note the following values:
554
- - `Client ID`
555
- - `Client Secret`
556
- - `Project Key`
557
- - `Scopes` (ensure you have the required scopes for product and category operations)
558
- - `Region` (e.g., `australia-southeast1.gcp`)
559
-
560
- 2. **Add credentials in n8n:**
561
- - In n8n, go to **Credentials** > **Create New**.
562
- - Search for and select **Commercetools OAuth2 API**.
563
- - Fill in the required fields:
564
- - **Client ID**
565
- - **Client Secret**
566
- - **Project Key**
567
- - **Region**
568
- - **Scopes**
569
- - **AWS Client ID**
570
- - **AWS Client Secret**
571
- - The AWS fields map to your access key pair and are required for webhook/SQS delivery paths.
572
- - Save the credentials.
573
-
574
- 3. **Use credentials in your workflow:**
575
- - When adding the Commercetools node to your workflow, select the credentials you just created from the credentials dropdown.
576
-
577
- Your Commercetools node is now authenticated and ready to use for both product and category operations in n8n workflows.
578
-
579
-
580
- ## Features & Supported Operations
581
-
582
- The Commercetools node for n8n enables you to interact with the Commercetools API for product and category management. The following operations are supported:
583
-
584
- ### Product Operations
585
- - **Create Product**
586
- Create a new product in your Commercetools project.
587
-
588
- - **Query Products**
589
- Retrieve a list of products with support for pagination, sorting, filtering, and predicate variables.
590
-
591
- - **Search Products**
592
- Perform advanced product searches using the Commercetools search endpoint.
593
-
594
- - **Get Product (by ID or Key)**
595
- Retrieve detailed information for a specific product by its ID or key.
596
-
597
- - **Update Product (by ID or Key)**
598
- Update an existing product using one or more update actions. The `updateActions` UI builder now mirrors Commercetools’ product update catalog, including localized content helpers, price/asset editors, search keyword builders, and state transitions.
599
-
600
- - **Delete Product (by ID or Key)**
601
- Delete a product from your project.
602
-
603
- - **Query Product Selections (by ID or Key)**
604
- Retrieve product selection assignments for a product.
605
-
606
- - **Upload Product Image**
607
- Upload an image to a product, either from binary data or an external URL.
608
-
609
- ### Category Operations
610
- - **Create Category**
611
- Create a new category in your Commercetools project.
612
-
613
- - **Query Categories**
614
- Retrieve a list of categories with support for pagination, sorting, and filtering.
615
-
616
- - **Get Category (by ID or Key)**
617
- Retrieve detailed information for a specific category by its ID or key.
618
-
619
- - **Update Category (by ID or Key)**
620
- Update an existing category using one or more update actions. (Categories currently require JSON-based `actions`.)
621
-
622
- - **Delete Category (by ID or Key)**
623
- Delete a category from your project.
624
-
625
- ### Check Product & Category Existence
626
- - **By ID:** Use the "HEAD" operation with a product or category ID to check if it exists.
627
- - **By Key:** Use the "HEAD by Key" operation with a product or category key.
628
- - **By Query:** Use the "HEAD by Query" operation to check if any product or category matches a specific query.
629
-
630
- Each operation supports additional parameters for fine-tuned control, such as staged changes, data erasure, dry run, and more.
631
-
632
- ## What's Included
633
-
634
- - **Commercetools Node**: Located in `nodes/Commercetools/`, this node provides operations for interacting with the Commercetools API, including product management and authentication via OAuth2.
635
- - **Credentials**: OAuth2 credentials for Commercetools in `credentials/CommerceToolsOAuth2Api.credentials.ts`.
636
- - **Utilities and Descriptions**: Helper functions and operation definitions for Commercetools API requests.
637
-
638
-
639
-
640
- ## Prerequisites
641
-
642
- - **[Node.js](https://nodejs.org/)** (v22 or higher) and npm
643
- - **[git](https://git-scm.com/downloads)**
644
-
645
-
646
- ## Usage
647
-
648
- 1. **Install dependencies**
649
- ```bash
650
- npm install
651
- ```
652
- 2. **Start development server**
653
- ```bash
654
- npm run dev
655
- ```
656
- This will build the node and launch n8n locally with hot reload enabled. Access n8n at [http://localhost:5678](http://localhost:5678).
657
- 3. **Configure Commercetools credentials**
658
- - Go to n8n's credentials section and add your Commercetools OAuth2 credentials.
659
- 4. **Use the Commercetools node in your workflow**
660
- - Add the Commercetools node to your workflow and select the desired operation (e.g., product management).
661
- - For product updates, use the `updateActions` builder to stack multiple actions (or combine with `actions` JSON for edge cases).
662
- 5. **Lint and build**
663
- - Lint: `npm run lint`
664
- - Auto-fix: `npm run lint:fix`
665
- - Build: `npm run build`
666
- 6. **Publish**
667
- - When ready, publish your package to npm:
668
- ```bash
669
- npm publish
670
- ```
671
-
672
-
673
- ## Available Scripts
674
-
675
- | Script | Description |
676
- | --------------------- | ---------------------------------------------------------------- |
677
- | `npm run dev` | Start n8n with the Commercetools node and watch for changes |
678
- | `npm run build` | Compile TypeScript to JavaScript for production |
679
- | `npm run build:watch` | Build in watch mode (auto-rebuild on changes) |
680
- | `npm run lint` | Check your code for errors and style issues |
681
- | `npm run lint:fix` | Automatically fix linting issues when possible |
682
- | `npm run release` | Create a new release |
683
-
684
-
685
-
686
-
687
- ## Error Handling & Troubleshooting
688
-
689
- Here are common errors and troubleshooting tips for the Commercetools node (products and categories):
690
-
691
- - **Authentication Errors:**
692
- - Ensure your OAuth2 credentials (Client ID, Client Secret, Project Key, Region, Scopes) are correct and have the required permissions.
693
- - If you see an authentication error, re-authorize or recreate your credentials in n8n.
694
-
695
- - **Missing or Invalid Parameters:**
696
- - Double-check required fields for each operation:
697
- - For products: productDraft, productId/productKey, version, etc.
698
- - For categories: categoryDraft, categoryId/categoryKey, version, etc.
699
- - The node will display a clear error if a required parameter is missing or invalid.
700
-
701
- - **API Errors:**
702
- - Errors from the Commercetools API (e.g., 404 Not Found, 400 Bad Request) will be shown in the node output or n8n error panel.
703
- - Review the error message for details and check your input data.
704
-
705
- - **Not Found (Product/Category):**
706
- - For get, update, delete, or existence checks, ensure the productId/productKey or categoryId/categoryKey is correct and the item exists in your project.
707
-
708
- - **Version Mismatch:**
709
- - For update and delete operations, the version must match the current version in Commercetools. Retrieve the latest version before updating or deleting (applies to both products and categories).
710
-
711
- - **Binary Data Issues (Image Upload):**
712
- - Ensure the binary property name matches the uploaded file and the file is present in the workflow (product image upload only).
713
-
714
- - **General Node Issues:**
715
- - If the node does not appear in n8n, ensure dependencies are installed, the node is registered in `package.json`, and the dev server is running.
716
- - Check the n8n console and logs for error details.
717
-
718
- For linting or TypeScript errors, use the provided scripts or consult the [n8n node development guidelines](https://docs.n8n.io/integrations/creating-nodes/).
719
-
720
-
721
- ## Resources
722
-
723
- - **[n8n Node Documentation](https://docs.n8n.io/integrations/creating-nodes/)**
724
- - **[n8n Community Forum](https://community.n8n.io/)**
725
- - **[@n8n/node-cli Documentation](https://www.npmjs.com/package/@n8n/node-cli)**
726
-
727
-
728
- ## Contributing
729
-
730
- Contributions and suggestions for improving the Commercetools node are welcome. Please open an issue or submit a pull request.
731
-
732
-
733
-
734
- ## Changelog
735
-
736
- All notable changes to this project will be documented in the `CHANGELOG.md` file. Below is a summary of recent updates:
737
-
738
-
739
- ### [Unreleased]
740
- - Added Commercetools webhook-based product trigger plus AWS automation/test guides
741
- - Added AWS credential fields (client ID/secret) and environment-driven webhook URL support for trigger delivery
742
- - Documented AWS deployment automation and attribute references for the CloudFormation scripts
743
- - Refactored Commercetools product, category, and customer property definitions for easier maintenance
744
-
745
- ### v1.0.0
746
- - Initial release of the Commercetools node for n8n
747
- - Supports product management operations: create, query, search, get, update, delete, product selections, image upload, and existence checks
748
- - OAuth2 credential integration
749
-
750
- Refer to `CHANGELOG.md` for a complete version history and details.
751
-
752
- ## License
753
-
754
- [MIT](LICENSE.md)
1
+ ![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)
2
+
3
+
4
+ # n8n-nodes-commercetools
5
+
6
+ This repository provides a custom [n8n](https://n8n.io) node for integrating with [Commercetools](https://commercetools.com). It includes all required credentials, node definitions, utilities to interact with the Commercetools API, and optional **AWS SQS integration with Lambda processing**.
7
+
8
+ ## Features
9
+
10
+ - **Complete Commercetools Integration**: Full support for products, categories, and customers
11
+ - **Webhook Product Trigger**: Native trigger for product events; delivers directly to n8n or, when AWS credentials are provided, through an auto-created SQS + Lambda pipeline
12
+ - **AWS SQS + Lambda (optional)**: Auto-provisions SQS, Lambda, and IAM via the AWS SDK when AWS credentials are present in the node credentials
13
+ - **Event Types**: Product Event Triggers
14
+ product created,product published,product unpublished,product deleted,
15
+ product added to category,product removed from category,
16
+ product image added,product slug changed,product state transition,product reverted staged changes,
17
+ product variant added,product variant deleted,
18
+ product price added,product price changed,product price removed,product prices set,product price mode set,product price key set,product price discounts set,product price external discount set,
19
+ product price custom field added,product price custom field changed,product price custom field removed,
20
+ product price custom fields set,product price custom fields removed.
21
+ Customer Event Triggers
22
+ customer created, customer deleted, customer email verified,
23
+ customer email changed, customer password updated,
24
+ customer first name set, customer last name set, customer company name set,
25
+ customer title set, customer date of birth set, customer stores set,
26
+ customer group set, customer address added, customer address changed, customer address removed,
27
+ customer billing address added, customer billing address removed,
28
+ customer shipping address added, customer shipping address removed,
29
+ customer default billing address set, customer default shipping address set,
30
+ customer custom type set, customer custom type removed,
31
+ customer custom field added, customer custom field changed, customer custom field removed,
32
+ customer address custom type set, customer address custom type removed,
33
+ customer address custom field added, customer address custom field changed, customer address custom field removed
34
+
35
+ - **Monitoring**: CloudWatch logging from the generated Lambda function
36
+
37
+
38
+ ## Quick Start
39
+
40
+ **To start developing and testing the Commercetools node:**
41
+
42
+ ```bash
43
+ npm install
44
+ npm run dev
45
+ ```
46
+
47
+ This will start n8n with the Commercetools node loaded and hot reload enabled.
48
+
49
+ ## Webhook Trigger
50
+
51
+ Use the Commercetools Trigger node to receive events directly in n8n.
52
+
53
+ 1. Add the **Commercetools Trigger** node.
54
+ 2. Select the event you want to subscribe to.
55
+ 3. Choose your **Commercetools OAuth2** credentials. To send events through SQS + Lambda, also fill in **AWS Access Key**, **AWS Secret Access Key**, and **AWS Region** in the same credential.
56
+ 4. Activate your workflow. The node registers a CommerceTools subscription pointing at your n8n webhook URL (`.../webhook/<path>/commercetools-events`). With AWS credentials, it also creates the SQS queue, Lambda function, IAM role, and event source mapping, then forwards messages to n8n.
57
+ 5. Deactivate or update the trigger to clean up and recreate subscriptions or AWS resources when the configuration changes.
58
+
59
+ ## AWS SQS + Lambda Integration (optional)
60
+
61
+ When AWS credentials are present in the Commercetools credentials, the trigger:
62
+
63
+ - Creates an SQS queue, Lambda function, IAM role, and event source mapping for the selected product events.
64
+ - Configures the Lambda with your n8n webhook URL so messages are forwarded into the workflow.
65
+ - Stores identifiers in workflow static data and deletes the resources when the trigger is removed or reconfigured.
66
+
67
+ Notes:
68
+ - Resource names are generated per activation and include the event type.
69
+ - Ensure the n8n webhook endpoint is reachable from AWS.
70
+
71
+
72
+ ## Configuration Options
73
+
74
+ Below are the main configuration options and parameters available for the Commercetools node (resource: product or category):
75
+
76
+ ### Common Parameters
77
+ - **resource**: Select 'product' or 'category' to access respective operations.
78
+ - **operation**: Choose the desired operation (e.g., create, query, get, update, delete, etc.).
79
+ - **Credentials**: Select your configured Commercetools OAuth2 credentials.
80
+
81
+ ### Product Operation-Specific Parameters
82
+
83
+ #### Create Product
84
+ - **productDraft**: JSON object with product details (name, slug, productType, masterVariant, etc.).
85
+ - **additionalFieldsCreate**: Optional fields for additional product properties.
86
+
87
+ #### Query Products
88
+ - **returnAll**: Boolean to return all products (up to 500 per request).
89
+ - **limit**: Number of products to return per request.
90
+ - **offset**: Pagination offset.
91
+ - **additionalFields**: Optional filters, sorting, and predicate variables.
92
+
93
+ #### Search Products
94
+ - **searchRequest**: JSON object for advanced search queries.
95
+ - **additionalFieldsSearch**: Optional search parameters (limit, offset, staged, etc.).
96
+
97
+ #### Get Product / Get By Key
98
+ - **productId** or **productKey**: ID or key of the product to retrieve.
99
+ - **additionalFieldsGet**: Optional fields for expanded data.
100
+
101
+ #### Update Product / Update By Key
102
+ - **productId** or **productKey**: ID or key of the product to update.
103
+ - **version**: Product version (required for updates).
104
+ - **actions**: Array of update actions (JSON).
105
+ - **updateActions**: UI builder that lets you stack multiple product update actions without hand-writing JSON. These can be combined with the `actions` array if you need to mix UI-built and raw payloads.
106
+ - **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
107
+
108
+ #### Delete Product / Delete By Key
109
+ - **productId** or **productKey**: ID or key of the product to delete.
110
+ - **version**: Product version (required for deletion).
111
+ - **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
112
+
113
+ #### Query Product Selections
114
+ - **productId** or **productKey**: ID or key of the product.
115
+ - **additionalFieldsSelections**: Optional fields (expand, limit, offset, withTotal, customParameters).
116
+
117
+ #### Upload Product Image
118
+ - **productId**: ID of the product to upload the image to.
119
+ - **binaryPropertyName**: Name of the binary property containing the image.
120
+ - **additionalFieldsUpload**: Optional fields (variantId, sku, staged, filename, externalUrl, label, customParameters).
121
+
122
+
123
+ ### Customer Operation-Specific Parameters
124
+
125
+ #### Authenticate Customer
126
+
127
+ - **email**: Customer's email.
128
+ - **password**: Customer password.
129
+
130
+ #### Authenticate Customer in Store
131
+
132
+ - **storeKey**: Key of the store.
133
+ - **email**: Customer email.
134
+ - **password**: Customer password.
135
+
136
+
137
+ #### Change Customer Password
138
+
139
+ - **customerId**: ID of the customer.
140
+ - **version**: Customer version.
141
+ - **passwordToken**: PasswordToken to authenticate.
142
+ - **newPassword**: New password.
143
+
144
+ #### Change Customer Password in Store
145
+
146
+ - **storeKey**: Store key.
147
+ - **customerId**: ID of the customer.
148
+ - **version**: Customer version.
149
+ - **passwordToken**: PasswordToken to authenticate.
150
+ - **newPassword**: New password.
151
+
152
+ #### Check if Customer Exists
153
+
154
+ - **customerId**: Customer ID.
155
+
156
+ #### Check if Customer Exists by Key
157
+
158
+ - **customerKey**: Customer key.
159
+
160
+ #### Check if Any Customer Matches the Query
161
+
162
+ - **where**: Predicate expression.
163
+ - **additionalFieldsCheckQuery**: Optional parameters (store projection, expand).
164
+
165
+ #### Check if Customer Exists in Store
166
+
167
+ - **storeKey**: Store key.
168
+ - **customerId**: Customer ID.
169
+
170
+ #### Check if Customer Exists in Store by Key
171
+
172
+ - **storeKey**: Store key.
173
+ - **customerKey**: Customer key.
174
+
175
+ #### Check if Any Customer Matches the Query in Store
176
+
177
+ - **storeKey**: Store key.
178
+ - **where**: Predicate filter.
179
+ - **additionalFieldsCheckQueryStore**: Optional parameters.
180
+
181
+ #### Create Customer
182
+
183
+ - **customerDraft**: Customer JSON object (email, firstName, lastName, password, custom, etc.).
184
+ - **additionalFieldsCreate**: Optional fields (expand, localeProjection, etc.).
185
+
186
+ #### Create Email Verification Token
187
+
188
+ - **id**: Customer ID.
189
+ - **version**: Customer version.
190
+
191
+ #### Create Email Verification Token in Store
192
+
193
+ - **storeKey**: Store key.
194
+ - **id**: Customer ID.
195
+ - **version**: Customer version.
196
+ - **ttlMinutes**: Optional.
197
+
198
+ #### Create Customer in Store
199
+
200
+ - **storeKey**: Store key.
201
+ - **customerDraft**: Customer draft JSON.
202
+ - **additionalFieldsCreateStore**: Optional fields.
203
+
204
+
205
+ #### Create Password Reset Token
206
+
207
+ - **email**: Customer email.
208
+
209
+ #### Create Password Reset Token in Store
210
+
211
+ - **storeKey**: Store key.
212
+ - **email**: Customer email.
213
+
214
+
215
+ #### Delete Customer
216
+
217
+ - **customerId**: ID of the customer.
218
+ - **version**: Version of the customer.
219
+
220
+ #### Delete Customer by Key
221
+
222
+ - **customerKey**: Key of the customer.
223
+ - **version**: Version.
224
+ - **additionalFieldsDeleteKey**: Optional.
225
+
226
+ #### Delete Customer in Store
227
+
228
+ - **storeKey**: Store key.
229
+ - **customerId**: Customer ID.
230
+ - **version**: Version.
231
+
232
+ #### Delete Customer in Store by Key
233
+
234
+ - **storeKey**: Store key.
235
+ - **customerKey**: Customer key.
236
+ - **version**: Version.
237
+
238
+ #### Get Customer
239
+
240
+ - **customerId**: Customer ID.
241
+ - **additionalFieldsGet**: Optional fields (expand, localeProjection).
242
+
243
+ #### Get Customer By Email Token
244
+
245
+ - **emailToken**: Token value.
246
+ - **additionalFieldsGetToken**: Optional.
247
+
248
+ #### Get Customer By Key
249
+
250
+ - **customerKey**: Customer key.
251
+ - **additionalFieldsGetKey**: Optional.
252
+
253
+ #### Get Customer By Password Token
254
+
255
+ - **passwordToken**: Token value.
256
+ - **additionalFieldsGetPassToken**: Optional.
257
+
258
+ #### Get Customer in Store
259
+
260
+ - **storeKey**: Store key.
261
+ - **customerId**: Customer ID.
262
+ - **additionalFieldsGetStore**: Optional.
263
+
264
+ #### Get Customer in Store by Email Token
265
+
266
+ - **storeKey**: Store key.
267
+ - **emailToken**: Token value.
268
+ - **additionalFieldsGetStoreEmailToken**: Optional.
269
+
270
+ #### Get Customer in Store by Key
271
+
272
+ - **storeKey**: Store key.
273
+ - **customerKey**: Customer key.
274
+ - **additionalFieldsGetStoreKey**: Optional.
275
+
276
+ #### Get Customer in Store by Password Token
277
+
278
+ - **storeKey**: Store key.
279
+ - **passwordToken**: Token value.
280
+ - **additionalFieldsGetStorePassToken**: Optional.
281
+
282
+ #### Query Customers
283
+
284
+ - **where**: Predicate expression.
285
+ - **limit**: Number of results.
286
+ - **offset**: Offset for pagination.
287
+ - **sort**: Sorting expressions.
288
+ - **additionalFieldsQuery**: Optional fields.
289
+
290
+ #### Query Customers in Store
291
+
292
+ - **storeKey**: Store key.
293
+ - **where**: Predicate expression.
294
+ - **limit**: Number of results.
295
+ - **offset**: Pagination offset.
296
+ - **sort**: Sorting expression.
297
+ - **additionalFieldsQueryStore**: Optional.
298
+
299
+
300
+ #### Reset Customer Password
301
+
302
+ - **tokenValue**: Password reset token.
303
+ - **newPassword**: New password.
304
+ - **additionalFieldsResetPwd**: Optional.
305
+
306
+ #### Reset Customer Password in Store
307
+
308
+ - **storeKey**: Store key.
309
+ - **tokenValue**: Token.
310
+ - **newPassword**: New password.
311
+ - **additionalFieldsResetPwdStore**: Optional.
312
+
313
+
314
+ #### Update Customer
315
+
316
+ - **customerId**: Customer ID.
317
+ - **version**: Customer version.
318
+ - **actions**: Array of update actions.
319
+ - **additionalFieldsUpdate**: Optional (expand).
320
+
321
+ #### Update Customer by Key
322
+
323
+ - **customerKey**: Customer key.
324
+ - **version**: Version.
325
+ - **actions**: Update actions array.
326
+ - **additionalFieldsUpdateKey**: Optional.
327
+
328
+ #### Update Customer in Store
329
+
330
+ - **storeKey**: Store key.
331
+ - **customerId**: Customer ID.
332
+ - **version**: Version.
333
+ - **actions**: Update actions array.
334
+ - **additionalFieldsUpdateStore**: Optional.
335
+
336
+ #### Update Customer in Store by Key
337
+
338
+ - **storeKey**: Store key.
339
+ - **customerKey**: Customer key.
340
+ - **version**: Version.
341
+ - **actions**: Update actions.
342
+ - **additionalFieldsUpdateStoreKey**: Optional.
343
+
344
+ #### Verify Customer Email
345
+
346
+ - **tokenValue**: Email verification token.
347
+ - **additionalFieldsVerify**: Optional.
348
+
349
+ #### Verify Customer Email in Store
350
+
351
+ - **storeKey**: Store key.
352
+ - **tokenValue**: Verification token.
353
+ - **additionalFieldsVerifyStore**: Optional.
354
+
355
+ ### Category Operation-Specific Parameters
356
+
357
+ #### Create Category
358
+ - **categoryDraft**: JSON object with category details (name, slug, parent, orderHint, etc.).
359
+ - **additionalFieldsCreate**: Optional fields for additional category properties.
360
+
361
+ #### Query Categories
362
+ - **returnAll**: Boolean to return all categories (up to 500 per request).
363
+ - **limit**: Number of categories to return per request.
364
+ - **offset**: Pagination offset.
365
+ - **additionalFields**: Optional filters, sorting, and predicate variables.
366
+
367
+ #### Get Category / Get By Key
368
+ - **categoryId** or **categoryKey**: ID or key of the category to retrieve.
369
+ - **additionalFieldsGet**: Optional fields for expanded data.
370
+
371
+ #### Update Category / Update By Key
372
+ - **categoryId** or **categoryKey**: ID or key of the category to update.
373
+ - **version**: Category version (required for updates).
374
+ - **actions**: Array of update actions (JSON). (Categories currently require JSON actions only.)
375
+ - **additionalFieldsUpdate**: Optional fields (dataErasure, dryRun, etc.).
376
+
377
+ #### Delete Category / Delete By Key
378
+ - **categoryId** or **categoryKey**: ID or key of the category to delete.
379
+ - **version**: Category version (required for deletion).
380
+ - **additionalFieldsDelete**: Optional fields (dataErasure, etc.).
381
+
382
+ Refer to the node UI in n8n for detailed descriptions and validation for each parameter.
383
+
384
+ Below is a sample workflow using the Commercetools node in n8n to create and query a product.
385
+
386
+ ### Example: Create a Product
387
+
388
+ 1. Add the **Commercetools** node to your workflow.
389
+ 2. Select the **Create Product** operation.
390
+ 3. Fill in the required product draft fields (e.g., name, slug, product type, etc.).
391
+ 4. Select your configured Commercetools credentials.
392
+ 5. Run the workflow to create a new product in your Commercetools project.
393
+
394
+ **Sample Input (Product Draft):**
395
+ ```json
396
+ {
397
+ "name": { "en": "Sample Product" },
398
+ "slug": { "en": "sample-product" },
399
+ "productType": { "id": "your-product-type-id" },
400
+ "masterVariant": {
401
+ "sku": "SKU123",
402
+ "prices": [ { "value": { "currencyCode": "USD", "centAmount": 1000 } } ]
403
+ }
404
+ }
405
+ ```
406
+
407
+
408
+ ### Example: Query Products
409
+
410
+ 1. Add the **Commercetools** node to your workflow.
411
+ 2. Select the **Query Products** operation.
412
+ 3. Optionally set filters, sorting, and pagination parameters.
413
+ 4. Select your configured Commercetools credentials.
414
+ 5. Run the workflow to retrieve products from your Commercetools project.
415
+
416
+ **Sample Output:**
417
+ ```json
418
+ [
419
+ {
420
+ "id": "product-id-1",
421
+ "name": { "en": "Sample Product" },
422
+ "slug": { "en": "sample-product" }
423
+ // ...other product fields
424
+ }
425
+ // ...more products
426
+ ]
427
+ ```
428
+
429
+ ### Using updateActions (Product Updates)
430
+
431
+ The `updateActions` fixed collection lets you compose Commercetools product update commands directly in the node UI, with helper inputs for localized data, prices, assets, and variant targeting. Highlights:
432
+ - Choose whether each variant is addressed by `variantId` or `sku`, and mix multiple variant-specific actions in a single request.
433
+ - Localized name/slug/meta helpers automatically map locale/value pairs to the format the Commercetools API expects.
434
+ - Attribute editors support string/number/boolean parsing so you don't need to pre-format JSON.
435
+ - Asset, price, image, and search keyword builders flatten nested fixed collections (sources, dimensions, tokenizers, etc.) into valid drafts.
436
+
437
+ Supported product update actions:
438
+ - Add Asset
439
+ - Add External Image
440
+ - Add Price
441
+ - Add Product Variant
442
+ - Add To Category
443
+ - Change Asset Name
444
+ - Change Asset Order
445
+ - Change Master Variant
446
+ - Change Name
447
+ - Change Price
448
+ - Change Slug
449
+ - Move Image To Position
450
+ - Publish
451
+ - Remove Asset
452
+ - Remove From Category
453
+ - Remove Image
454
+ - Remove Price
455
+ - Remove Variant
456
+ - Revert Staged Changes
457
+ - Revert Staged Variant Changes
458
+ - Set Asset Custom Field
459
+ - Set Asset Custom Type
460
+ - Set Asset Description
461
+ - Set Asset Key
462
+ - Set Asset Sources
463
+ - Set Asset Tags
464
+ - Set Attribute
465
+ - Set Attribute In All Variants
466
+ - Set Category Order Hint
467
+ - Set Description
468
+ - Set Image Label
469
+ - Set Key
470
+ - Set Meta Description
471
+ - Set Meta Keywords
472
+ - Set Meta Title
473
+ - Set Price Custom Field
474
+ - Set Price Key
475
+ - Set Price Mode
476
+ - Set Prices
477
+ - Set Product Attribute
478
+ - Set Product Price Custom Type
479
+ - Set Product Variant Key
480
+ - Set Search Keywords
481
+ - Set SKU
482
+ - Set Tax Category
483
+ - Transition State
484
+ - Unpublish
485
+
486
+ Need a field that isn't exposed yet? Add it via the `actions` JSON array - the node merges both sources in request order.
487
+
488
+ > **Transition State note:** the builder enforces that either a state ID or a state key is set per the [Commercetools Transition State action](https://docs.commercetools.com/api/projects/products#transition-state).
489
+
490
+ ### Example: Create a Category
491
+
492
+ 1. Add the **Commercetools** node to your workflow.
493
+ 2. Select the **Create Category** operation.
494
+ 3. Fill in the required category draft fields (e.g., name, slug, parent, orderHint, etc.).
495
+ 4. Select your configured Commercetools credentials.
496
+ 5. Run the workflow to create a new category in your Commercetools project.
497
+
498
+ **Sample Input (Category Draft):**
499
+ ```json
500
+ {
501
+ "name": { "en": "Sample Category" },
502
+ "slug": { "en": "sample-category" },
503
+ "orderHint": "0.1"
504
+ }
505
+ ```
506
+
507
+ ### Example: Query Categories
508
+
509
+ 1. Add the **Commercetools** node to your workflow.
510
+ 2. Select the **Query Categories** operation.
511
+ 3. Optionally set filters, sorting, and pagination parameters.
512
+ 4. Select your configured Commercetools credentials.
513
+ 5. Run the workflow to retrieve categories from your Commercetools project.
514
+
515
+ **Sample Output:**
516
+ ```json
517
+ [
518
+ {
519
+ "id": "category-id-1",
520
+ "name": { "en": "Sample Category" },
521
+ "slug": { "en": "sample-category" }
522
+ // ...other category fields
523
+ }
524
+ // ...more categories
525
+ ]
526
+ ```
527
+
528
+ You can chain Commercetools node operations with other n8n nodes to build advanced workflows for product and category management, automation, and integration.
529
+
530
+
531
+ ## Credential Setup
532
+
533
+ To use the Commercetools node for both product and category operations, you must configure OAuth2 credentials for your Commercetools project in n8n. Follow these steps:
534
+
535
+ 1. **Obtain Commercetools API credentials:**
536
+ - Log in to your Commercetools Merchant Center.
537
+ - Go to the API Clients section and create a new API client.
538
+ - Note the following values:
539
+ - `Client ID`
540
+ - `Client Secret`
541
+ - `Project Key`
542
+ - `Scopes` (ensure you have the required scopes for product and category operations)
543
+ - `Region` (e.g., `australia-southeast1.gcp`)
544
+
545
+ 2. **Add credentials in n8n:**
546
+ - In n8n, go to **Credentials** > **Create New**.
547
+ - Search for and select **Commercetools OAuth2 API**.
548
+ - Fill in the required fields:
549
+ - **Client ID**
550
+ - **Client Secret**
551
+ - **Project Key**
552
+ - **Region**
553
+ - **Scopes**
554
+ - **AWS Client ID**
555
+ - **AWS Client Secret**
556
+ - The AWS fields map to your access key pair and are required for webhook/SQS delivery paths.
557
+ - Save the credentials.
558
+
559
+ 3. **Use credentials in your workflow:**
560
+ - When adding the Commercetools node to your workflow, select the credentials you just created from the credentials dropdown.
561
+
562
+ Your Commercetools node is now authenticated and ready to use for both product and category operations in n8n workflows.
563
+
564
+
565
+ ## Features & Supported Operations
566
+
567
+ The Commercetools node for n8n enables you to interact with the Commercetools API for product and category management. The following operations are supported:
568
+
569
+ ### Product Operations
570
+ - **Create Product**
571
+ Create a new product in your Commercetools project.
572
+
573
+ - **Query Products**
574
+ Retrieve a list of products with support for pagination, sorting, filtering, and predicate variables.
575
+
576
+ - **Search Products**
577
+ Perform advanced product searches using the Commercetools search endpoint.
578
+
579
+ - **Get Product (by ID or Key)**
580
+ Retrieve detailed information for a specific product by its ID or key.
581
+
582
+ - **Update Product (by ID or Key)**
583
+ Update an existing product using one or more update actions. The `updateActions` UI builder now mirrors Commercetools' product update catalog, including localized content helpers, price/asset editors, search keyword builders, and state transitions.
584
+
585
+ - **Delete Product (by ID or Key)**
586
+ Delete a product from your project.
587
+
588
+ - **Query Product Selections (by ID or Key)**
589
+ Retrieve product selection assignments for a product.
590
+
591
+ - **Upload Product Image**
592
+ Upload an image to a product, either from binary data or an external URL.
593
+
594
+ ### Category Operations
595
+ - **Create Category**
596
+ Create a new category in your Commercetools project.
597
+
598
+ - **Query Categories**
599
+ Retrieve a list of categories with support for pagination, sorting, and filtering.
600
+
601
+ - **Get Category (by ID or Key)**
602
+ Retrieve detailed information for a specific category by its ID or key.
603
+
604
+ - **Update Category (by ID or Key)**
605
+ Update an existing category using one or more update actions. (Categories currently require JSON-based `actions`.)
606
+
607
+ - **Delete Category (by ID or Key)**
608
+ Delete a category from your project.
609
+
610
+ ### Check Product & Category Existence
611
+ - **By ID:** Use the "HEAD" operation with a product or category ID to check if it exists.
612
+ - **By Key:** Use the "HEAD by Key" operation with a product or category key.
613
+ - **By Query:** Use the "HEAD by Query" operation to check if any product or category matches a specific query.
614
+
615
+ Each operation supports additional parameters for fine-tuned control, such as staged changes, data erasure, dry run, and more.
616
+
617
+ ## What's Included
618
+
619
+ - **Commercetools Node**: Located in `nodes/Commercetools/`, this node provides operations for interacting with the Commercetools API, including product management and authentication via OAuth2.
620
+ - **Credentials**: OAuth2 credentials for Commercetools in `credentials/CommerceToolsOAuth2Api.credentials.ts`.
621
+ - **Utilities and Descriptions**: Helper functions and operation definitions for Commercetools API requests.
622
+
623
+
624
+
625
+ ## Prerequisites
626
+
627
+ - **[Node.js](https://nodejs.org/)** (v22 or higher) and npm
628
+ - **[git](https://git-scm.com/downloads)**
629
+
630
+
631
+ ## Usage
632
+
633
+ 1. **Install dependencies**
634
+ ```bash
635
+ npm install
636
+ ```
637
+ 2. **Start development server**
638
+ ```bash
639
+ npm run dev
640
+ ```
641
+ This will build the node and launch n8n locally with hot reload enabled. Access n8n at [http://localhost:5678](http://localhost:5678).
642
+ 3. **Configure Commercetools credentials**
643
+ - Go to n8n's credentials section and add your Commercetools OAuth2 credentials.
644
+ 4. **Use the Commercetools node in your workflow**
645
+ - Add the Commercetools node to your workflow and select the desired operation (e.g., product management).
646
+ - For product updates, use the `updateActions` builder to stack multiple actions (or combine with `actions` JSON for edge cases).
647
+ 5. **Lint and build**
648
+ - Lint: `npm run lint`
649
+ - Auto-fix: `npm run lint:fix`
650
+ - Build: `npm run build`
651
+ 6. **Publish**
652
+ - When ready, publish your package to npm:
653
+ ```bash
654
+ npm publish
655
+ ```
656
+
657
+
658
+ ## Available Scripts
659
+
660
+ | Script | Description |
661
+ | --------------------- | ---------------------------------------------------------------- |
662
+ | `npm run dev` | Start n8n with the Commercetools node and watch for changes |
663
+ | `npm run build` | Compile TypeScript to JavaScript for production |
664
+ | `npm run build:watch` | Build in watch mode (auto-rebuild on changes) |
665
+ | `npm run lint` | Check your code for errors and style issues |
666
+ | `npm run lint:fix` | Automatically fix linting issues when possible |
667
+ | `npm run release` | Create a new release |
668
+
669
+
670
+
671
+
672
+ ## Error Handling & Troubleshooting
673
+
674
+ Here are common errors and troubleshooting tips for the Commercetools node (products and categories):
675
+
676
+ - **Authentication Errors:**
677
+ - Ensure your OAuth2 credentials (Client ID, Client Secret, Project Key, Region, Scopes) are correct and have the required permissions.
678
+ - If you see an authentication error, re-authorize or recreate your credentials in n8n.
679
+
680
+ - **Missing or Invalid Parameters:**
681
+ - Double-check required fields for each operation:
682
+ - For products: productDraft, productId/productKey, version, etc.
683
+ - For categories: categoryDraft, categoryId/categoryKey, version, etc.
684
+ - The node will display a clear error if a required parameter is missing or invalid.
685
+
686
+ - **API Errors:**
687
+ - Errors from the Commercetools API (e.g., 404 Not Found, 400 Bad Request) will be shown in the node output or n8n error panel.
688
+ - Review the error message for details and check your input data.
689
+
690
+ - **Not Found (Product/Category):**
691
+ - For get, update, delete, or existence checks, ensure the productId/productKey or categoryId/categoryKey is correct and the item exists in your project.
692
+
693
+ - **Version Mismatch:**
694
+ - For update and delete operations, the version must match the current version in Commercetools. Retrieve the latest version before updating or deleting (applies to both products and categories).
695
+
696
+ - **Binary Data Issues (Image Upload):**
697
+ - Ensure the binary property name matches the uploaded file and the file is present in the workflow (product image upload only).
698
+
699
+ - **General Node Issues:**
700
+ - If the node does not appear in n8n, ensure dependencies are installed, the node is registered in `package.json`, and the dev server is running.
701
+ - Check the n8n console and logs for error details.
702
+
703
+ For linting or TypeScript errors, use the provided scripts or consult the [n8n node development guidelines](https://docs.n8n.io/integrations/creating-nodes/).
704
+
705
+
706
+ ## Resources
707
+
708
+ - **[n8n Node Documentation](https://docs.n8n.io/integrations/creating-nodes/)**
709
+ - **[n8n Community Forum](https://community.n8n.io/)**
710
+ - **[@n8n/node-cli Documentation](https://www.npmjs.com/package/@n8n/node-cli)**
711
+
712
+
713
+ ## Contributing
714
+
715
+ Contributions and suggestions for improving the Commercetools node are welcome. Please open an issue or submit a pull request.
716
+
717
+
718
+
719
+ ## Changelog
720
+
721
+ See `CHANGELOG.md` for the full history. Highlights:
722
+
723
+ - **v0.1.15**: Updated AWS trigger infrastructure and test payloads.
724
+ - **v0.1.14**: Added product trigger event coverage and consolidated trigger/actions.
725
+ - **v0.1.12**: Introduced the Commercetools product trigger and AWS credential fields in the credential model.
726
+
727
+ ## License
728
+
729
+ [MIT](LICENSE.md)