n8n-nodes-richpanel 1.1.1 → 1.1.3
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RichpanelTool = void 0;
|
|
4
|
+
const tools_1 = require("@langchain/core/tools");
|
|
5
|
+
const zod_1 = require("zod");
|
|
4
6
|
class RichpanelTool {
|
|
5
7
|
constructor() {
|
|
6
8
|
this.description = {
|
|
@@ -103,203 +105,206 @@ class RichpanelTool {
|
|
|
103
105
|
}
|
|
104
106
|
async supplyData() {
|
|
105
107
|
const operations = this.getNodeParameter('operations', 0, []);
|
|
106
|
-
const
|
|
108
|
+
const credentials = await this.getCredentials('richpanelApi');
|
|
109
|
+
const apiKey = credentials.apiKey;
|
|
110
|
+
const tools = [];
|
|
111
|
+
// Helper function to make API requests
|
|
112
|
+
const makeApiRequest = async (method, endpoint, body) => {
|
|
113
|
+
const options = {
|
|
114
|
+
method,
|
|
115
|
+
url: `https://api.richpanel.com/v1${endpoint}`,
|
|
116
|
+
headers: {
|
|
117
|
+
'x-richpanel-key': apiKey,
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
Accept: 'application/json',
|
|
120
|
+
},
|
|
121
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
122
|
+
json: true,
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
const response = await this.helpers.httpRequest(options);
|
|
126
|
+
return response;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
throw new Error(`Richpanel API error: ${error.message}`);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
107
132
|
// Create Conversation Tool
|
|
108
133
|
if (operations.includes('createConversation')) {
|
|
109
|
-
|
|
134
|
+
const createConversationTool = new tools_1.DynamicStructuredTool({
|
|
110
135
|
name: 'richpanel_create_conversation',
|
|
111
136
|
description: 'Create a new support conversation/ticket in Richpanel. Use this when a customer needs help, reports an issue, or has a question that needs tracking.',
|
|
112
|
-
schema: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
required: ['messageBody', 'customerEmail'],
|
|
137
|
+
schema: zod_1.z.object({
|
|
138
|
+
messageBody: zod_1.z.string().describe('The customer message content or issue description'),
|
|
139
|
+
customerEmail: zod_1.z.string().email().describe('Customer email address'),
|
|
140
|
+
subject: zod_1.z.string().optional().describe('Subject line for the conversation/ticket'),
|
|
141
|
+
priority: zod_1.z
|
|
142
|
+
.enum(['HIGH', 'LOW'])
|
|
143
|
+
.optional()
|
|
144
|
+
.describe('Priority level (HIGH for urgent issues, LOW for general questions)'),
|
|
145
|
+
}),
|
|
146
|
+
func: async (input) => {
|
|
147
|
+
const { messageBody, customerEmail, subject, priority } = input;
|
|
148
|
+
const body = {
|
|
149
|
+
message_body: messageBody,
|
|
150
|
+
customer_email: customerEmail,
|
|
151
|
+
};
|
|
152
|
+
if (subject)
|
|
153
|
+
body.subject = subject;
|
|
154
|
+
if (priority)
|
|
155
|
+
body.priority = priority;
|
|
156
|
+
const result = await makeApiRequest('POST', '/conversations', body);
|
|
157
|
+
return JSON.stringify(result);
|
|
134
158
|
},
|
|
135
159
|
});
|
|
160
|
+
tools.push(createConversationTool);
|
|
136
161
|
}
|
|
137
162
|
// Get Conversation Tool
|
|
138
163
|
if (operations.includes('getConversation')) {
|
|
139
|
-
|
|
164
|
+
const getConversationTool = new tools_1.DynamicStructuredTool({
|
|
140
165
|
name: 'richpanel_get_conversation',
|
|
141
166
|
description: 'Retrieve details about an existing conversation/ticket by ID. Use this to check ticket status, see assigned agent, read conversation history, or verify if an issue is resolved.',
|
|
142
|
-
schema: {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
required: ['conversationId'],
|
|
167
|
+
schema: zod_1.z.object({
|
|
168
|
+
conversationId: zod_1.z.string().describe('The unique ID of the conversation/ticket'),
|
|
169
|
+
}),
|
|
170
|
+
func: async (input) => {
|
|
171
|
+
const { conversationId } = input;
|
|
172
|
+
const result = await makeApiRequest('GET', `/conversations/${conversationId}`);
|
|
173
|
+
return JSON.stringify(result);
|
|
151
174
|
},
|
|
152
175
|
});
|
|
176
|
+
tools.push(getConversationTool);
|
|
153
177
|
}
|
|
154
178
|
// Update Conversation Tool
|
|
155
179
|
if (operations.includes('updateConversation')) {
|
|
156
|
-
|
|
180
|
+
const updateConversationTool = new tools_1.DynamicStructuredTool({
|
|
157
181
|
name: 'richpanel_update_conversation',
|
|
158
182
|
description: 'Update conversation properties like status or priority. Use this to close resolved tickets, change priority levels, or update conversation state.',
|
|
159
|
-
schema: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
required: ['conversationId'],
|
|
183
|
+
schema: zod_1.z.object({
|
|
184
|
+
conversationId: zod_1.z.string().describe('The unique ID of the conversation to update'),
|
|
185
|
+
status: zod_1.z
|
|
186
|
+
.enum(['OPEN', 'CLOSED'])
|
|
187
|
+
.optional()
|
|
188
|
+
.describe('New status (CLOSED when issue is resolved, OPEN otherwise)'),
|
|
189
|
+
priority: zod_1.z.enum(['HIGH', 'LOW']).optional().describe('New priority level'),
|
|
190
|
+
}),
|
|
191
|
+
func: async (input) => {
|
|
192
|
+
const { conversationId, status, priority } = input;
|
|
193
|
+
const body = {};
|
|
194
|
+
if (status)
|
|
195
|
+
body.status = status;
|
|
196
|
+
if (priority)
|
|
197
|
+
body.priority = priority;
|
|
198
|
+
const result = await makeApiRequest('PUT', `/conversations/${conversationId}`, body);
|
|
199
|
+
return JSON.stringify(result);
|
|
178
200
|
},
|
|
179
201
|
});
|
|
202
|
+
tools.push(updateConversationTool);
|
|
180
203
|
}
|
|
181
204
|
// Get Customer Tool
|
|
182
205
|
if (operations.includes('getCustomer')) {
|
|
183
|
-
|
|
206
|
+
const getCustomerTool = new tools_1.DynamicStructuredTool({
|
|
184
207
|
name: 'richpanel_get_customer',
|
|
185
208
|
description: 'Retrieve customer information by email or phone number. Use this to look up customer details, see order history, check customer status, or verify customer information.',
|
|
186
|
-
schema: {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
required: ['identifier'],
|
|
209
|
+
schema: zod_1.z.object({
|
|
210
|
+
identifier: zod_1.z.string().describe('Customer email address or phone number'),
|
|
211
|
+
type: zod_1.z
|
|
212
|
+
.enum(['email', 'phone'])
|
|
213
|
+
.default('email')
|
|
214
|
+
.describe('Type of identifier (email or phone)'),
|
|
215
|
+
}),
|
|
216
|
+
func: async (input) => {
|
|
217
|
+
const { identifier, type } = input;
|
|
218
|
+
const endpoint = type === 'email' ? `/customers/${identifier}` : `/customers/phone/${identifier}`;
|
|
219
|
+
const result = await makeApiRequest('GET', endpoint);
|
|
220
|
+
return JSON.stringify(result);
|
|
201
221
|
},
|
|
202
222
|
});
|
|
223
|
+
tools.push(getCustomerTool);
|
|
203
224
|
}
|
|
204
225
|
// Create/Update Customer Tool
|
|
205
226
|
if (operations.includes('upsertCustomer')) {
|
|
206
|
-
|
|
227
|
+
const upsertCustomerTool = new tools_1.DynamicStructuredTool({
|
|
207
228
|
name: 'richpanel_create_update_customer',
|
|
208
229
|
description: 'Create a new customer or update existing customer information. Use this when a customer provides updated details or to add a new customer to the system.',
|
|
209
|
-
schema: {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
country: {
|
|
233
|
-
type: 'string',
|
|
234
|
-
description: 'Customer country',
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
required: ['email'],
|
|
230
|
+
schema: zod_1.z.object({
|
|
231
|
+
email: zod_1.z.string().email().describe('Customer email address (required)'),
|
|
232
|
+
firstName: zod_1.z.string().optional().describe('Customer first name'),
|
|
233
|
+
lastName: zod_1.z.string().optional().describe('Customer last name'),
|
|
234
|
+
phone: zod_1.z.string().optional().describe('Customer phone number'),
|
|
235
|
+
city: zod_1.z.string().optional().describe('Customer city'),
|
|
236
|
+
country: zod_1.z.string().optional().describe('Customer country'),
|
|
237
|
+
}),
|
|
238
|
+
func: async (input) => {
|
|
239
|
+
const { email, firstName, lastName, phone, city, country } = input;
|
|
240
|
+
const body = { email };
|
|
241
|
+
if (firstName)
|
|
242
|
+
body.first_name = firstName;
|
|
243
|
+
if (lastName)
|
|
244
|
+
body.last_name = lastName;
|
|
245
|
+
if (phone)
|
|
246
|
+
body.phone = phone;
|
|
247
|
+
if (city)
|
|
248
|
+
body.city = city;
|
|
249
|
+
if (country)
|
|
250
|
+
body.country = country;
|
|
251
|
+
const result = await makeApiRequest('POST', '/customers', body);
|
|
252
|
+
return JSON.stringify(result);
|
|
238
253
|
},
|
|
239
254
|
});
|
|
255
|
+
tools.push(upsertCustomerTool);
|
|
240
256
|
}
|
|
241
257
|
// Get Order Tool
|
|
242
258
|
if (operations.includes('getOrder')) {
|
|
243
|
-
|
|
259
|
+
const getOrderTool = new tools_1.DynamicStructuredTool({
|
|
244
260
|
name: 'richpanel_get_order',
|
|
245
261
|
description: 'Retrieve order information by order ID. Use this when a customer asks about order status, shipping, tracking, or order details.',
|
|
246
|
-
schema: {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
},
|
|
254
|
-
required: ['orderId'],
|
|
262
|
+
schema: zod_1.z.object({
|
|
263
|
+
orderId: zod_1.z.string().describe('The unique order ID/number'),
|
|
264
|
+
}),
|
|
265
|
+
func: async (input) => {
|
|
266
|
+
const { orderId } = input;
|
|
267
|
+
const result = await makeApiRequest('GET', `/orders/${orderId}`);
|
|
268
|
+
return JSON.stringify(result);
|
|
255
269
|
},
|
|
256
270
|
});
|
|
271
|
+
tools.push(getOrderTool);
|
|
257
272
|
}
|
|
258
273
|
// Add Tags Tool
|
|
259
274
|
if (operations.includes('addTags')) {
|
|
260
|
-
|
|
275
|
+
const addTagsTool = new tools_1.DynamicStructuredTool({
|
|
261
276
|
name: 'richpanel_add_tags',
|
|
262
277
|
description: 'Add tags to a conversation for categorization and organization. Use this to tag tickets by issue type, urgency, department, or any other category.',
|
|
263
|
-
schema: {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
},
|
|
275
|
-
description: 'Array of tag names (e.g., ["billing", "urgent", "refund"])',
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
required: ['conversationId', 'tags'],
|
|
278
|
+
schema: zod_1.z.object({
|
|
279
|
+
conversationId: zod_1.z.string().describe('The conversation ID to add tags to'),
|
|
280
|
+
tags: zod_1.z
|
|
281
|
+
.array(zod_1.z.string())
|
|
282
|
+
.describe('Array of tag names (e.g., ["billing", "urgent", "refund"])'),
|
|
283
|
+
}),
|
|
284
|
+
func: async (input) => {
|
|
285
|
+
const { conversationId, tags } = input;
|
|
286
|
+
const body = { tags };
|
|
287
|
+
const result = await makeApiRequest('POST', `/conversations/${conversationId}/tags`, body);
|
|
288
|
+
return JSON.stringify(result);
|
|
279
289
|
},
|
|
280
290
|
});
|
|
291
|
+
tools.push(addTagsTool);
|
|
281
292
|
}
|
|
282
293
|
// List Users Tool
|
|
283
294
|
if (operations.includes('listUsers')) {
|
|
284
|
-
|
|
295
|
+
const listUsersTool = new tools_1.DynamicStructuredTool({
|
|
285
296
|
name: 'richpanel_list_users',
|
|
286
297
|
description: 'Get a list of all support agents/users in Richpanel. Use this when a customer asks to speak with an agent, or to find available support staff.',
|
|
287
|
-
schema: {
|
|
288
|
-
|
|
289
|
-
|
|
298
|
+
schema: zod_1.z.object({}),
|
|
299
|
+
func: async () => {
|
|
300
|
+
const result = await makeApiRequest('GET', '/users');
|
|
301
|
+
return JSON.stringify(result);
|
|
290
302
|
},
|
|
291
303
|
});
|
|
304
|
+
tools.push(listUsersTool);
|
|
292
305
|
}
|
|
293
|
-
// Return tool definitions for AI agent
|
|
294
306
|
return {
|
|
295
|
-
response:
|
|
296
|
-
type: 'function',
|
|
297
|
-
function: {
|
|
298
|
-
name: tool.name,
|
|
299
|
-
description: tool.description,
|
|
300
|
-
parameters: tool.schema,
|
|
301
|
-
},
|
|
302
|
-
})),
|
|
307
|
+
response: tools,
|
|
303
308
|
};
|
|
304
309
|
}
|
|
305
310
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-richpanel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "n8n community node for Richpanel customer support platform - manage conversations, customers, orders, and subscriptions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n",
|
|
@@ -53,13 +53,15 @@
|
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@langchain/core": "^0.3.80",
|
|
56
57
|
"@typescript-eslint/parser": "^5.59.0",
|
|
57
58
|
"eslint": "^8.40.0",
|
|
58
59
|
"eslint-plugin-n8n-nodes-base": "^1.12.0",
|
|
59
60
|
"gulp": "^4.0.2",
|
|
60
61
|
"n8n-workflow": "^1.0.0",
|
|
61
62
|
"prettier": "^2.8.8",
|
|
62
|
-
"typescript": "^5.0.4"
|
|
63
|
+
"typescript": "^5.0.4",
|
|
64
|
+
"zod": "^4.3.2"
|
|
63
65
|
},
|
|
64
66
|
"peerDependencies": {
|
|
65
67
|
"n8n-workflow": "*"
|