n8n-nodes-mautic-advanced 0.3.9 → 0.4.1

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.
@@ -63,12 +63,12 @@ exports.categoryFields = [
63
63
  },
64
64
  },
65
65
  default: '',
66
- description: 'The title of the category to create',
66
+ description: 'The title or name of the category',
67
67
  },
68
68
  {
69
69
  displayName: 'Bundle',
70
70
  name: 'bundle',
71
- type: 'string',
71
+ type: 'options',
72
72
  required: true,
73
73
  displayOptions: {
74
74
  show: {
@@ -76,8 +76,75 @@ exports.categoryFields = [
76
76
  operation: ['create'],
77
77
  },
78
78
  },
79
- default: '',
80
- description: 'The bundle where the category will be available',
79
+ options: [
80
+ {
81
+ name: 'Global',
82
+ value: 'global',
83
+ description: 'Available across all Mautic elements',
84
+ },
85
+ {
86
+ name: 'Asset',
87
+ value: 'asset',
88
+ description: 'For downloadable assets',
89
+ },
90
+ {
91
+ name: 'Campaign',
92
+ value: 'campaign',
93
+ description: 'For marketing campaigns',
94
+ },
95
+ {
96
+ name: 'Email',
97
+ value: 'email',
98
+ description: 'For email templates',
99
+ },
100
+ {
101
+ name: 'Focus Items',
102
+ value: 'plugin:focus',
103
+ description: 'For focus items',
104
+ },
105
+ {
106
+ name: 'Form',
107
+ value: 'form',
108
+ description: 'For forms',
109
+ },
110
+ {
111
+ name: 'Marketing Messages',
112
+ value: 'messages',
113
+ description: 'For marketing messages',
114
+ },
115
+ {
116
+ name: 'Page',
117
+ value: 'page',
118
+ description: 'For landing pages',
119
+ },
120
+ {
121
+ name: 'Point',
122
+ value: 'point',
123
+ description: 'For point actions',
124
+ },
125
+ {
126
+ name: 'Segment',
127
+ value: 'segment',
128
+ description: 'For contact segments',
129
+ },
130
+ {
131
+ name: 'Text Message',
132
+ value: 'sms',
133
+ description: 'For SMS/text messages',
134
+ },
135
+ {
136
+ name: 'Social Monitoring',
137
+ value: 'plugin:mauticSocial',
138
+ description: 'For social monitoring',
139
+ },
140
+ {
141
+ name: 'Stage',
142
+ value: 'stage',
143
+ description: 'For contact stages',
144
+ },
145
+ ],
146
+ default: 'global',
147
+ description: 'The bundle where the category will be available. Determines which Mautic elements can use this category',
81
148
  },
82
149
  {
83
150
  displayName: 'Description',
@@ -90,12 +157,12 @@ exports.categoryFields = [
90
157
  },
91
158
  },
92
159
  default: '',
93
- description: 'The description of the category',
160
+ description: 'Optional description of the category to help identify its purpose',
94
161
  },
95
162
  {
96
163
  displayName: 'Color',
97
164
  name: 'color',
98
- type: 'string',
165
+ type: 'color',
99
166
  displayOptions: {
100
167
  show: {
101
168
  resource: ['category'],
@@ -103,7 +170,7 @@ exports.categoryFields = [
103
170
  },
104
171
  },
105
172
  default: '',
106
- description: 'The color of the category',
173
+ description: 'Color for visual organisation and identification of the category in Mautic',
107
174
  },
108
175
  /* -------------------------------------------------------------------------- */
109
176
  /* category:update */
@@ -153,28 +220,95 @@ exports.categoryFields = [
153
220
  name: 'title',
154
221
  type: 'string',
155
222
  default: '',
156
- description: 'The new title of the category',
223
+ description: 'The new title or name of the category',
157
224
  },
158
225
  {
159
226
  displayName: 'Bundle',
160
227
  name: 'bundle',
161
- type: 'string',
228
+ type: 'options',
162
229
  default: '',
163
- description: 'The new bundle of the category',
230
+ options: [
231
+ {
232
+ name: 'Global',
233
+ value: 'global',
234
+ description: 'Available across all Mautic elements',
235
+ },
236
+ {
237
+ name: 'Asset',
238
+ value: 'asset',
239
+ description: 'For downloadable assets',
240
+ },
241
+ {
242
+ name: 'Campaign',
243
+ value: 'campaign',
244
+ description: 'For marketing campaigns',
245
+ },
246
+ {
247
+ name: 'Email',
248
+ value: 'email',
249
+ description: 'For email templates',
250
+ },
251
+ {
252
+ name: 'Focus Items',
253
+ value: 'plugin:focus',
254
+ description: 'For focus items',
255
+ },
256
+ {
257
+ name: 'Form',
258
+ value: 'form',
259
+ description: 'For forms',
260
+ },
261
+ {
262
+ name: 'Marketing Messages',
263
+ value: 'messages',
264
+ description: 'For marketing messages',
265
+ },
266
+ {
267
+ name: 'Page',
268
+ value: 'page',
269
+ description: 'For landing pages',
270
+ },
271
+ {
272
+ name: 'Point',
273
+ value: 'point',
274
+ description: 'For point actions',
275
+ },
276
+ {
277
+ name: 'Segment',
278
+ value: 'segment',
279
+ description: 'For contact segments',
280
+ },
281
+ {
282
+ name: 'Text Message',
283
+ value: 'sms',
284
+ description: 'For SMS/text messages',
285
+ },
286
+ {
287
+ name: 'Social Monitoring',
288
+ value: 'plugin:mauticSocial',
289
+ description: 'For social monitoring',
290
+ },
291
+ {
292
+ name: 'Stage',
293
+ value: 'stage',
294
+ description: 'For contact stages',
295
+ },
296
+ ],
297
+ description: 'The bundle where the category will be available. Determines which Mautic elements can use this category',
164
298
  },
165
299
  {
166
300
  displayName: 'Description',
167
301
  name: 'description',
168
302
  type: 'string',
169
303
  default: '',
170
- description: 'The new description of the category',
304
+ description: 'Optional description of the category to help identify its purpose',
171
305
  },
172
306
  {
173
307
  displayName: 'Color',
174
308
  name: 'color',
175
- type: 'string',
309
+ type: 'color',
176
310
  default: '',
177
- description: 'The new color of the category',
311
+ description: 'Color for visual organisation and identification of the category in Mautic',
178
312
  },
179
313
  ],
180
314
  },
@@ -1727,6 +1727,58 @@ exports.contactFields = [
1727
1727
  },
1728
1728
  default: '',
1729
1729
  },
1730
+ {
1731
+ displayName: 'Tokens',
1732
+ name: 'tokensUi',
1733
+ type: 'fixedCollection',
1734
+ typeOptions: {
1735
+ multipleValues: true,
1736
+ },
1737
+ placeholder: 'Add Token',
1738
+ description: 'Custom tokens to pass to the email template. These will be available as {token_name} in your email template.',
1739
+ default: {},
1740
+ displayOptions: {
1741
+ show: {
1742
+ resource: ['contact'],
1743
+ operation: ['sendEmail'],
1744
+ },
1745
+ },
1746
+ options: [
1747
+ {
1748
+ name: 'tokenValues',
1749
+ displayName: 'Token',
1750
+ values: [
1751
+ {
1752
+ displayName: 'Token Name',
1753
+ name: 'tokenKey',
1754
+ type: 'string',
1755
+ default: '',
1756
+ description: 'The token name (e.g., "order_id", "customer_name")',
1757
+ },
1758
+ {
1759
+ displayName: 'Token Value',
1760
+ name: 'tokenValue',
1761
+ type: 'string',
1762
+ default: '',
1763
+ description: 'The token value (e.g., "12345", "John")',
1764
+ },
1765
+ ],
1766
+ },
1767
+ ],
1768
+ },
1769
+ {
1770
+ displayName: 'Asset Attachments',
1771
+ name: 'assetAttachments',
1772
+ type: 'string',
1773
+ description: 'Comma-separated list of asset IDs to attach to the email',
1774
+ default: '',
1775
+ displayOptions: {
1776
+ show: {
1777
+ resource: ['contact'],
1778
+ operation: ['sendEmail'],
1779
+ },
1780
+ },
1781
+ },
1730
1782
  /* -------------------------------------------------------------------------- */
1731
1783
  /* contact:getNotes */
1732
1784
  /* -------------------------------------------------------------------------- */
@@ -162,7 +162,26 @@ exports.segmentFields = [
162
162
  {
163
163
  displayName: 'Type',
164
164
  name: 'type',
165
- type: 'string',
165
+ type: 'options',
166
+ options: [
167
+ { name: 'Boolean', value: 'boolean' },
168
+ { name: 'Date', value: 'date' },
169
+ { name: 'DateTime', value: 'datetime' },
170
+ { name: 'Email', value: 'email' },
171
+ { name: 'Country', value: 'country' },
172
+ { name: 'Locale', value: 'locale' },
173
+ { name: 'Lookup', value: 'lookup' },
174
+ { name: 'Number', value: 'number' },
175
+ { name: 'Tel', value: 'tel' },
176
+ { name: 'Region', value: 'region' },
177
+ { name: 'Select', value: 'select' },
178
+ { name: 'Multiselect', value: 'multiselect' },
179
+ { name: 'Text', value: 'text' },
180
+ { name: 'Textarea', value: 'textarea' },
181
+ { name: 'Time', value: 'time' },
182
+ { name: 'Timezone', value: 'timezone' },
183
+ { name: 'URL', value: 'url' },
184
+ ],
166
185
  default: 'email',
167
186
  },
168
187
  {
@@ -178,6 +197,10 @@ exports.segmentFields = [
178
197
  options: [
179
198
  { name: '=', value: '=' },
180
199
  { name: '!=', value: '!=' },
200
+ { name: '>', value: 'gt' },
201
+ { name: '>=', value: 'gte' },
202
+ { name: '<', value: 'lt' },
203
+ { name: '<=', value: 'lte' },
181
204
  { name: 'Empty', value: 'empty' },
182
205
  { name: 'Not Empty', value: '!empty' },
183
206
  { name: 'Like', value: 'like' },
@@ -187,9 +210,20 @@ exports.segmentFields = [
187
210
  { name: 'Starts With', value: 'startsWith' },
188
211
  { name: 'Ends With', value: 'endsWith' },
189
212
  { name: 'Contains', value: 'contains' },
213
+ { name: 'In', value: 'in' },
214
+ { name: 'Not In', value: '!in' },
215
+ { name: 'Between', value: 'between' },
216
+ { name: 'Not Between', value: '!between' },
190
217
  ],
191
218
  default: 'like',
192
219
  },
220
+ {
221
+ displayName: 'Display',
222
+ name: 'display',
223
+ type: 'string',
224
+ default: '',
225
+ description: 'Optional display name for the filter',
226
+ },
193
227
  ],
194
228
  },
195
229
  ],
@@ -220,8 +220,33 @@ async function deleteContact(context, itemIndex) {
220
220
  }
221
221
  async function sendEmailToContact(context, itemIndex) {
222
222
  const contactId = (0, ApiHelpers_1.getRequiredParam)(context, 'contactId', itemIndex);
223
- const emailId = (0, ApiHelpers_1.getRequiredParam)(context, 'emailId', itemIndex);
224
- const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', `/emails/${emailId}/contact/${contactId}/send`);
223
+ const emailId = (0, ApiHelpers_1.getRequiredParam)(context, 'campaignEmailId', itemIndex);
224
+ const tokensUi = (0, ApiHelpers_1.getOptionalParam)(context, 'tokensUi', itemIndex, {});
225
+ const assetAttachments = (0, ApiHelpers_1.getOptionalParam)(context, 'assetAttachments', itemIndex, '');
226
+ // Build request body
227
+ const body = {};
228
+ // Process tokens from key-value pairs UI
229
+ if (tokensUi?.tokenValues && Array.isArray(tokensUi.tokenValues)) {
230
+ const tokens = {};
231
+ for (const tokenItem of tokensUi.tokenValues) {
232
+ if (tokenItem.tokenKey && tokenItem.tokenValue !== undefined) {
233
+ tokens[tokenItem.tokenKey] = tokenItem.tokenValue;
234
+ }
235
+ }
236
+ if (Object.keys(tokens).length > 0) {
237
+ body.tokens = tokens;
238
+ }
239
+ }
240
+ // Process asset attachments
241
+ if (assetAttachments && assetAttachments.trim()) {
242
+ body.assetAttachments = assetAttachments
243
+ .split(',')
244
+ .map((id) => id.trim())
245
+ .filter((id) => id.length > 0);
246
+ }
247
+ // Only send body if it has content
248
+ const requestBody = Object.keys(body).length > 0 ? body : {};
249
+ const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', `/emails/${emailId}/contact/${contactId}/send`, requestBody);
225
250
  return response;
226
251
  }
227
252
  async function editContactPoints(context, itemIndex) {
@@ -198,8 +198,11 @@ async function createCategory(context, itemIndex) {
198
198
  if (description)
199
199
  body.description = description;
200
200
  const color = (0, ApiHelpers_1.getOptionalParam)(context, 'color', itemIndex, '');
201
- if (color)
202
- body.color = color;
201
+ if (color) {
202
+ // Mautic API expects hex color without # prefix (e.g., "b36262")
203
+ // n8n color picker returns with # prefix, so we strip it if present
204
+ body.color = color.startsWith('#') ? color.substring(1) : color;
205
+ }
203
206
  const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', '/categories/new', body);
204
207
  return response.category;
205
208
  }
@@ -212,8 +215,12 @@ async function updateCategory(context, itemIndex) {
212
215
  body.title = updateFields.title;
213
216
  if (updateFields.description)
214
217
  body.description = updateFields.description;
215
- if (updateFields.color)
216
- body.color = updateFields.color;
218
+ if (updateFields.color) {
219
+ // Mautic API expects hex color without # prefix (e.g., "b36262")
220
+ // n8n color picker returns with # prefix, so we strip it if present
221
+ const color = updateFields.color;
222
+ body.color = color.startsWith('#') ? color.substring(1) : color;
223
+ }
217
224
  if (updateFields.bundle)
218
225
  body.bundle = updateFields.bundle;
219
226
  const method = createIfNotFound ? 'PUT' : 'PATCH';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-mautic-advanced",
3
- "version": "0.3.9",
3
+ "version": "0.4.1",
4
4
  "description": "Enhanced n8n node for Mautic with comprehensive API coverage including tags, campaigns, categories, and advanced contact management",
5
5
  "keywords": [
6
6
  "n8n",