@trg-admin/n8n-nodes-zoho-desk 0.1.16 → 0.1.19
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.
|
@@ -111,7 +111,7 @@ async function getContactByEmail(email, itemIndex = 0) {
|
|
|
111
111
|
if (!trimmedEmail) {
|
|
112
112
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), new Error('Contact Email cannot be empty'), { itemIndex });
|
|
113
113
|
}
|
|
114
|
-
const responseData = await zohoDeskApiRequest.call(this, 'GET', '/contacts/search', {}, { email: trimmedEmail
|
|
114
|
+
const responseData = await zohoDeskApiRequest.call(this, 'GET', '/contacts/search', {}, { email: trimmedEmail }, itemIndex);
|
|
115
115
|
const contacts = Array.isArray(responseData.data)
|
|
116
116
|
? responseData.data
|
|
117
117
|
: Array.isArray(responseData)
|
|
@@ -7,6 +7,10 @@ export declare class ZohoDesk implements INodeType {
|
|
|
7
7
|
name: string;
|
|
8
8
|
value: string;
|
|
9
9
|
}[]>;
|
|
10
|
+
getChannels(this: ILoadOptionsFunctions): Promise<{
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[]>;
|
|
10
14
|
};
|
|
11
15
|
};
|
|
12
16
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
@@ -154,6 +154,17 @@ class ZohoDesk {
|
|
|
154
154
|
default: '',
|
|
155
155
|
description: 'Agent ID to assign the ticket to',
|
|
156
156
|
},
|
|
157
|
+
{
|
|
158
|
+
displayName: 'Channel',
|
|
159
|
+
name: 'channel',
|
|
160
|
+
type: 'options',
|
|
161
|
+
typeOptions: {
|
|
162
|
+
loadOptionsMethod: 'getChannels',
|
|
163
|
+
loadOptionsDependsOn: ['organizationId'],
|
|
164
|
+
},
|
|
165
|
+
default: 'Email',
|
|
166
|
+
description: 'Channel through which the ticket was received or created. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
|
167
|
+
},
|
|
157
168
|
{
|
|
158
169
|
displayName: 'Contact ID',
|
|
159
170
|
name: 'contactId',
|
|
@@ -468,6 +479,91 @@ class ZohoDesk {
|
|
|
468
479
|
throw new Error(`Failed to load departments. Error: ${error.message}. Ensure Organization ID is correct and Desk API Base URL matches your region.`);
|
|
469
480
|
}
|
|
470
481
|
},
|
|
482
|
+
async getChannels() {
|
|
483
|
+
const fallbackChannels = [
|
|
484
|
+
{ name: 'Chat', value: 'Chat' },
|
|
485
|
+
{ name: 'Email', value: 'Email' },
|
|
486
|
+
{ name: 'Facebook', value: 'Facebook' },
|
|
487
|
+
{ name: 'Feedback Widget', value: 'Feedback Widget' },
|
|
488
|
+
{ name: 'Forums', value: 'Forums' },
|
|
489
|
+
{ name: 'Help Center', value: 'Help Center' },
|
|
490
|
+
{ name: 'Phone', value: 'Phone' },
|
|
491
|
+
{ name: 'Twitter', value: 'Twitter' },
|
|
492
|
+
{ name: 'Web', value: 'Web' },
|
|
493
|
+
];
|
|
494
|
+
try {
|
|
495
|
+
const responseData = await GenericFunctions_1.zohoDeskApiRequest.call(this, 'GET', '/channels', {}, {}, 0);
|
|
496
|
+
const channels = Array.isArray(responseData.data)
|
|
497
|
+
? responseData.data
|
|
498
|
+
: Array.isArray(responseData)
|
|
499
|
+
? responseData
|
|
500
|
+
: [];
|
|
501
|
+
if (channels.length > 0) {
|
|
502
|
+
const channelMap = new Map();
|
|
503
|
+
for (const c of channels) {
|
|
504
|
+
const name = c.channelName ||
|
|
505
|
+
c.name ||
|
|
506
|
+
c.channelCode ||
|
|
507
|
+
String(c.id);
|
|
508
|
+
const value = c.channelCode ||
|
|
509
|
+
c.name ||
|
|
510
|
+
c.channelName ||
|
|
511
|
+
String(c.id);
|
|
512
|
+
if (value) {
|
|
513
|
+
channelMap.set(value, name || value);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
for (const fb of fallbackChannels) {
|
|
517
|
+
if (!channelMap.has(fb.value)) {
|
|
518
|
+
channelMap.set(fb.value, fb.name);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return Array.from(channelMap.entries())
|
|
522
|
+
.map(([value, name]) => ({ name, value }))
|
|
523
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
catch {
|
|
527
|
+
try {
|
|
528
|
+
const fieldsResponse = await GenericFunctions_1.zohoDeskApiRequest.call(this, 'GET', '/organizationFields', {}, { module: 'tickets' }, 0);
|
|
529
|
+
const fields = Array.isArray(fieldsResponse.data)
|
|
530
|
+
? fieldsResponse.data
|
|
531
|
+
: Array.isArray(fieldsResponse)
|
|
532
|
+
? fieldsResponse
|
|
533
|
+
: [];
|
|
534
|
+
const channelField = fields.find((f) => String(f.apiName || '').toLowerCase() === 'channel');
|
|
535
|
+
if (channelField && Array.isArray(channelField.allowedValues)) {
|
|
536
|
+
const channelMap = new Map();
|
|
537
|
+
for (const val of channelField.allowedValues) {
|
|
538
|
+
if (typeof val === 'string') {
|
|
539
|
+
channelMap.set(val, val);
|
|
540
|
+
}
|
|
541
|
+
else if (val && typeof val === 'object') {
|
|
542
|
+
const name = val.displayValue ||
|
|
543
|
+
val.label ||
|
|
544
|
+
val.value;
|
|
545
|
+
const value = val.value || val.displayValue;
|
|
546
|
+
if (value) {
|
|
547
|
+
channelMap.set(value, name || value);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
for (const fb of fallbackChannels) {
|
|
552
|
+
if (!channelMap.has(fb.value)) {
|
|
553
|
+
channelMap.set(fb.value, fb.name);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return Array.from(channelMap.entries())
|
|
557
|
+
.map(([value, name]) => ({ name, value }))
|
|
558
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
catch {
|
|
562
|
+
// Fall back to predefined list
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return fallbackChannels;
|
|
566
|
+
},
|
|
471
567
|
},
|
|
472
568
|
};
|
|
473
569
|
}
|