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