@x0333/bitrix24-mcp-server 1.0.0
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 +330 -0
- package/build/bitrix24/client.d.ts +224 -0
- package/build/bitrix24/client.d.ts.map +1 -0
- package/build/bitrix24/client.js +1098 -0
- package/build/bitrix24/client.js.map +1 -0
- package/build/config/index.d.ts +6 -0
- package/build/config/index.d.ts.map +1 -0
- package/build/config/index.js +8 -0
- package/build/config/index.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +56 -0
- package/build/index.js.map +1 -0
- package/build/tools/index.d.ts +67 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +1377 -0
- package/build/tools/index.js.map +1 -0
- package/build/utils/logger.d.ts +7 -0
- package/build/utils/logger.d.ts.map +1 -0
- package/build/utils/logger.js +17 -0
- package/build/utils/logger.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,1377 @@
|
|
|
1
|
+
import { bitrix24Client } from '../bitrix24/client.js';
|
|
2
|
+
// Contact Management Tools
|
|
3
|
+
export const createContactTool = {
|
|
4
|
+
name: 'bitrix24_create_contact',
|
|
5
|
+
description: 'Create a new contact in Bitrix24 CRM',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
name: { type: 'string', description: 'First name' },
|
|
10
|
+
lastName: { type: 'string', description: 'Last name' },
|
|
11
|
+
phone: { type: 'string', description: 'Phone number' },
|
|
12
|
+
email: { type: 'string', description: 'Email address' },
|
|
13
|
+
company: { type: 'string', description: 'Company name' },
|
|
14
|
+
position: { type: 'string', description: 'Job position' },
|
|
15
|
+
comments: { type: 'string', description: 'Additional comments' }
|
|
16
|
+
},
|
|
17
|
+
required: ['name', 'lastName']
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const getContactTool = {
|
|
21
|
+
name: 'bitrix24_get_contact',
|
|
22
|
+
description: 'Retrieve contact information by ID',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
id: { type: 'string', description: 'Contact ID' }
|
|
27
|
+
},
|
|
28
|
+
required: ['id']
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const listContactsTool = {
|
|
32
|
+
name: 'bitrix24_list_contacts',
|
|
33
|
+
description: 'List contacts with optional filtering',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
limit: { type: 'number', description: 'Maximum number of contacts to return', default: 20 },
|
|
38
|
+
filter: { type: 'object', description: 'Filter criteria (e.g., {"NAME": "John"})' }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const getLatestContactsTool = {
|
|
43
|
+
name: 'bitrix24_get_latest_contacts',
|
|
44
|
+
description: 'Get the most recent contacts ordered by creation date',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
limit: { type: 'number', description: 'Maximum number of contacts to return', default: 20 }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const updateContactTool = {
|
|
53
|
+
name: 'bitrix24_update_contact',
|
|
54
|
+
description: 'Update an existing contact in Bitrix24 CRM',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
id: { type: 'string', description: 'Contact ID' },
|
|
59
|
+
name: { type: 'string', description: 'First name' },
|
|
60
|
+
lastName: { type: 'string', description: 'Last name' },
|
|
61
|
+
phone: { type: 'string', description: 'Phone number' },
|
|
62
|
+
email: { type: 'string', description: 'Email address' },
|
|
63
|
+
company: { type: 'string', description: 'Company name' },
|
|
64
|
+
position: { type: 'string', description: 'Job position' },
|
|
65
|
+
comments: { type: 'string', description: 'Additional comments' }
|
|
66
|
+
},
|
|
67
|
+
required: ['id']
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// Deal Management Tools
|
|
71
|
+
export const createDealTool = {
|
|
72
|
+
name: 'bitrix24_create_deal',
|
|
73
|
+
description: 'Create a new deal in Bitrix24 CRM',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
title: { type: 'string', description: 'Deal title' },
|
|
78
|
+
amount: { type: 'string', description: 'Deal amount' },
|
|
79
|
+
currency: { type: 'string', description: 'Currency code (e.g., EUR, USD)', default: 'EUR' },
|
|
80
|
+
contactId: { type: 'string', description: 'Associated contact ID' },
|
|
81
|
+
stageId: { type: 'string', description: 'Deal stage ID' },
|
|
82
|
+
comments: { type: 'string', description: 'Deal comments' }
|
|
83
|
+
},
|
|
84
|
+
required: ['title']
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export const getDealTool = {
|
|
88
|
+
name: 'bitrix24_get_deal',
|
|
89
|
+
description: 'Retrieve deal information by ID',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
id: { type: 'string', description: 'Deal ID' }
|
|
94
|
+
},
|
|
95
|
+
required: ['id']
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export const listDealsTool = {
|
|
99
|
+
name: 'bitrix24_list_deals',
|
|
100
|
+
description: 'List deals with optional filtering and ordering',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
limit: { type: 'number', description: 'Maximum number of deals to return', default: 20 },
|
|
105
|
+
filter: { type: 'object', description: 'Filter criteria (e.g., {"TITLE": "Project"})' },
|
|
106
|
+
orderBy: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE'],
|
|
109
|
+
description: 'Field to order by',
|
|
110
|
+
default: 'DATE_CREATE'
|
|
111
|
+
},
|
|
112
|
+
orderDirection: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
enum: ['ASC', 'DESC'],
|
|
115
|
+
description: 'Order direction',
|
|
116
|
+
default: 'DESC'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
export const updateDealTool = {
|
|
122
|
+
name: 'bitrix24_update_deal',
|
|
123
|
+
description: 'Update an existing deal in Bitrix24 CRM',
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
properties: {
|
|
127
|
+
id: { type: 'string', description: 'Deal ID' },
|
|
128
|
+
title: { type: 'string', description: 'Deal title' },
|
|
129
|
+
amount: { type: 'string', description: 'Deal amount' },
|
|
130
|
+
currency: { type: 'string', description: 'Currency code (e.g., EUR, USD)' },
|
|
131
|
+
contactId: { type: 'string', description: 'Associated contact ID' },
|
|
132
|
+
stageId: { type: 'string', description: 'Deal stage ID' },
|
|
133
|
+
comments: { type: 'string', description: 'Deal comments' }
|
|
134
|
+
},
|
|
135
|
+
required: ['id']
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
export const getLatestDealsTool = {
|
|
139
|
+
name: 'bitrix24_get_latest_deals',
|
|
140
|
+
description: 'Get the most recent deals ordered by creation date',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
limit: { type: 'number', description: 'Maximum number of deals to return', default: 20 }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export const getDealsFromDateRangeTool = {
|
|
149
|
+
name: 'bitrix24_get_deals_from_date_range',
|
|
150
|
+
description: 'Get deals created within a specific date range',
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {
|
|
154
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
155
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional)' },
|
|
156
|
+
limit: { type: 'number', description: 'Maximum number of deals to return', default: 50 }
|
|
157
|
+
},
|
|
158
|
+
required: ['startDate']
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
// Lead Management Tools
|
|
162
|
+
export const createLeadTool = {
|
|
163
|
+
name: 'bitrix24_create_lead',
|
|
164
|
+
description: 'Create a new lead in Bitrix24 CRM',
|
|
165
|
+
inputSchema: {
|
|
166
|
+
type: 'object',
|
|
167
|
+
properties: {
|
|
168
|
+
title: { type: 'string', description: 'Lead title' },
|
|
169
|
+
name: { type: 'string', description: 'First name' },
|
|
170
|
+
lastName: { type: 'string', description: 'Last name' },
|
|
171
|
+
company: { type: 'string', description: 'Company name' },
|
|
172
|
+
phone: { type: 'string', description: 'Phone number' },
|
|
173
|
+
email: { type: 'string', description: 'Email address' },
|
|
174
|
+
sourceId: { type: 'string', description: 'Lead source ID (e.g., CALL, EMAIL, WEB)' },
|
|
175
|
+
statusId: { type: 'string', description: 'Lead status ID' },
|
|
176
|
+
opportunity: { type: 'string', description: 'Expected deal amount' },
|
|
177
|
+
currency: { type: 'string', description: 'Currency code (e.g., EUR, USD)', default: 'EUR' },
|
|
178
|
+
comments: { type: 'string', description: 'Additional comments' }
|
|
179
|
+
},
|
|
180
|
+
required: ['title']
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
export const getLeadTool = {
|
|
184
|
+
name: 'bitrix24_get_lead',
|
|
185
|
+
description: 'Retrieve lead information by ID',
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
id: { type: 'string', description: 'Lead ID' }
|
|
190
|
+
},
|
|
191
|
+
required: ['id']
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
export const listLeadsTool = {
|
|
195
|
+
name: 'bitrix24_list_leads',
|
|
196
|
+
description: 'List leads with optional filtering and ordering',
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: 'object',
|
|
199
|
+
properties: {
|
|
200
|
+
limit: { type: 'number', description: 'Maximum number of leads to return', default: 20 },
|
|
201
|
+
filter: { type: 'object', description: 'Filter criteria (e.g., {"STATUS_ID": "NEW"})' },
|
|
202
|
+
orderBy: {
|
|
203
|
+
type: 'string',
|
|
204
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE'],
|
|
205
|
+
description: 'Field to order by',
|
|
206
|
+
default: 'DATE_CREATE'
|
|
207
|
+
},
|
|
208
|
+
orderDirection: {
|
|
209
|
+
type: 'string',
|
|
210
|
+
enum: ['ASC', 'DESC'],
|
|
211
|
+
description: 'Order direction',
|
|
212
|
+
default: 'DESC'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
export const getLatestLeadsTool = {
|
|
218
|
+
name: 'bitrix24_get_latest_leads',
|
|
219
|
+
description: 'Get the most recent leads ordered by creation date',
|
|
220
|
+
inputSchema: {
|
|
221
|
+
type: 'object',
|
|
222
|
+
properties: {
|
|
223
|
+
limit: { type: 'number', description: 'Maximum number of leads to return', default: 20 }
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
export const getLeadsFromDateRangeTool = {
|
|
228
|
+
name: 'bitrix24_get_leads_from_date_range',
|
|
229
|
+
description: 'Get leads created within a specific date range',
|
|
230
|
+
inputSchema: {
|
|
231
|
+
type: 'object',
|
|
232
|
+
properties: {
|
|
233
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
234
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional)' },
|
|
235
|
+
limit: { type: 'number', description: 'Maximum number of leads to return', default: 50 }
|
|
236
|
+
},
|
|
237
|
+
required: ['startDate']
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
export const updateLeadTool = {
|
|
241
|
+
name: 'bitrix24_update_lead',
|
|
242
|
+
description: 'Update an existing lead in Bitrix24 CRM',
|
|
243
|
+
inputSchema: {
|
|
244
|
+
type: 'object',
|
|
245
|
+
properties: {
|
|
246
|
+
id: { type: 'string', description: 'Lead ID' },
|
|
247
|
+
title: { type: 'string', description: 'Lead title' },
|
|
248
|
+
name: { type: 'string', description: 'First name' },
|
|
249
|
+
lastName: { type: 'string', description: 'Last name' },
|
|
250
|
+
company: { type: 'string', description: 'Company name' },
|
|
251
|
+
phone: { type: 'string', description: 'Phone number' },
|
|
252
|
+
email: { type: 'string', description: 'Email address' },
|
|
253
|
+
sourceId: { type: 'string', description: 'Lead source ID' },
|
|
254
|
+
statusId: { type: 'string', description: 'Lead status ID' },
|
|
255
|
+
opportunity: { type: 'string', description: 'Expected deal amount' },
|
|
256
|
+
currency: { type: 'string', description: 'Currency code' },
|
|
257
|
+
comments: { type: 'string', description: 'Additional comments' }
|
|
258
|
+
},
|
|
259
|
+
required: ['id']
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
// Company Management Tools
|
|
263
|
+
export const createCompanyTool = {
|
|
264
|
+
name: 'bitrix24_create_company',
|
|
265
|
+
description: 'Create a new company in Bitrix24 CRM',
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
title: { type: 'string', description: 'Company name' },
|
|
270
|
+
companyType: { type: 'string', description: 'Company type (e.g., CLIENT, SUPPLIER, PARTNER)' },
|
|
271
|
+
industry: { type: 'string', description: 'Industry sector' },
|
|
272
|
+
phone: { type: 'string', description: 'Company phone number' },
|
|
273
|
+
email: { type: 'string', description: 'Company email address' },
|
|
274
|
+
website: { type: 'string', description: 'Company website URL' },
|
|
275
|
+
address: { type: 'string', description: 'Company address' },
|
|
276
|
+
employees: { type: 'string', description: 'Number of employees' },
|
|
277
|
+
revenue: { type: 'string', description: 'Annual revenue' },
|
|
278
|
+
comments: { type: 'string', description: 'Additional comments' },
|
|
279
|
+
assignedById: { type: 'string', description: 'Assigned user ID' }
|
|
280
|
+
},
|
|
281
|
+
required: ['title']
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
export const getCompanyTool = {
|
|
285
|
+
name: 'bitrix24_get_company',
|
|
286
|
+
description: 'Retrieve company information by ID',
|
|
287
|
+
inputSchema: {
|
|
288
|
+
type: 'object',
|
|
289
|
+
properties: {
|
|
290
|
+
id: { type: 'string', description: 'Company ID' }
|
|
291
|
+
},
|
|
292
|
+
required: ['id']
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
export const listCompaniesTool = {
|
|
296
|
+
name: 'bitrix24_list_companies',
|
|
297
|
+
description: 'List companies with optional filtering and ordering',
|
|
298
|
+
inputSchema: {
|
|
299
|
+
type: 'object',
|
|
300
|
+
properties: {
|
|
301
|
+
limit: { type: 'number', description: 'Maximum number of companies to return', default: 20 },
|
|
302
|
+
filter: { type: 'object', description: 'Filter criteria (e.g., {"TITLE": "Tech Corp"})' },
|
|
303
|
+
orderBy: {
|
|
304
|
+
type: 'string',
|
|
305
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE'],
|
|
306
|
+
description: 'Field to order by',
|
|
307
|
+
default: 'DATE_CREATE'
|
|
308
|
+
},
|
|
309
|
+
orderDirection: {
|
|
310
|
+
type: 'string',
|
|
311
|
+
enum: ['ASC', 'DESC'],
|
|
312
|
+
description: 'Order direction',
|
|
313
|
+
default: 'DESC'
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
export const updateCompanyTool = {
|
|
319
|
+
name: 'bitrix24_update_company',
|
|
320
|
+
description: 'Update an existing company in Bitrix24 CRM',
|
|
321
|
+
inputSchema: {
|
|
322
|
+
type: 'object',
|
|
323
|
+
properties: {
|
|
324
|
+
id: { type: 'string', description: 'Company ID' },
|
|
325
|
+
title: { type: 'string', description: 'Company name' },
|
|
326
|
+
companyType: { type: 'string', description: 'Company type' },
|
|
327
|
+
industry: { type: 'string', description: 'Industry sector' },
|
|
328
|
+
phone: { type: 'string', description: 'Company phone number' },
|
|
329
|
+
email: { type: 'string', description: 'Company email address' },
|
|
330
|
+
website: { type: 'string', description: 'Company website URL' },
|
|
331
|
+
address: { type: 'string', description: 'Company address' },
|
|
332
|
+
employees: { type: 'string', description: 'Number of employees' },
|
|
333
|
+
revenue: { type: 'string', description: 'Annual revenue' },
|
|
334
|
+
comments: { type: 'string', description: 'Additional comments' },
|
|
335
|
+
assignedById: { type: 'string', description: 'Assigned user ID' }
|
|
336
|
+
},
|
|
337
|
+
required: ['id']
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
export const getLatestCompaniesTool = {
|
|
341
|
+
name: 'bitrix24_get_latest_companies',
|
|
342
|
+
description: 'Get the most recent companies ordered by creation date',
|
|
343
|
+
inputSchema: {
|
|
344
|
+
type: 'object',
|
|
345
|
+
properties: {
|
|
346
|
+
limit: { type: 'number', description: 'Maximum number of companies to return', default: 20 }
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
export const getCompaniesFromDateRangeTool = {
|
|
351
|
+
name: 'bitrix24_get_companies_from_date_range',
|
|
352
|
+
description: 'Get companies created within a specific date range',
|
|
353
|
+
inputSchema: {
|
|
354
|
+
type: 'object',
|
|
355
|
+
properties: {
|
|
356
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
357
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional)' },
|
|
358
|
+
limit: { type: 'number', description: 'Maximum number of companies to return', default: 50 }
|
|
359
|
+
},
|
|
360
|
+
required: ['startDate']
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
// Search and Utility Tools
|
|
364
|
+
export const searchCRMTool = {
|
|
365
|
+
name: 'bitrix24_search_crm',
|
|
366
|
+
description: 'Search across CRM entities (contacts, companies, deals, leads)',
|
|
367
|
+
inputSchema: {
|
|
368
|
+
type: 'object',
|
|
369
|
+
properties: {
|
|
370
|
+
query: { type: 'string', description: 'Search query (email, phone, name)' },
|
|
371
|
+
entityTypes: {
|
|
372
|
+
type: 'array',
|
|
373
|
+
items: { type: 'string', enum: ['contact', 'company', 'deal', 'lead'] },
|
|
374
|
+
description: 'Entity types to search',
|
|
375
|
+
default: ['contact', 'company', 'deal', 'lead']
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
required: ['query']
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
export const validateWebhookTool = {
|
|
382
|
+
name: 'bitrix24_validate_webhook',
|
|
383
|
+
description: 'Validate the Bitrix24 webhook connection',
|
|
384
|
+
inputSchema: {
|
|
385
|
+
type: 'object',
|
|
386
|
+
properties: {}
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
// Diagnostic Tools
|
|
390
|
+
export const diagnosePermissionsTool = {
|
|
391
|
+
name: 'bitrix24_diagnose_permissions',
|
|
392
|
+
description: 'Diagnose webhook permissions and access to different CRM entities',
|
|
393
|
+
inputSchema: {
|
|
394
|
+
type: 'object',
|
|
395
|
+
properties: {}
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
export const checkCRMSettingsTool = {
|
|
399
|
+
name: 'bitrix24_check_crm_settings',
|
|
400
|
+
description: 'Check CRM settings including lead fields, statuses, and mode',
|
|
401
|
+
inputSchema: {
|
|
402
|
+
type: 'object',
|
|
403
|
+
properties: {}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
export const testLeadsAPITool = {
|
|
407
|
+
name: 'bitrix24_test_leads_api',
|
|
408
|
+
description: 'Test various leads API endpoints to identify specific issues',
|
|
409
|
+
inputSchema: {
|
|
410
|
+
type: 'object',
|
|
411
|
+
properties: {}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
// Enhanced Deal Filtering Tools (Phase 1)
|
|
415
|
+
export const getDealPipelinesTool = {
|
|
416
|
+
name: 'bitrix24_get_deal_pipelines',
|
|
417
|
+
description: 'Get all available deal pipelines/categories with their IDs and names',
|
|
418
|
+
inputSchema: {
|
|
419
|
+
type: 'object',
|
|
420
|
+
properties: {}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
export const getDealStagesTool = {
|
|
424
|
+
name: 'bitrix24_get_deal_stages',
|
|
425
|
+
description: 'Get all deal stages for a specific pipeline or all pipelines',
|
|
426
|
+
inputSchema: {
|
|
427
|
+
type: 'object',
|
|
428
|
+
properties: {
|
|
429
|
+
pipelineId: {
|
|
430
|
+
type: 'string',
|
|
431
|
+
description: 'Pipeline ID to get stages for (optional - if not provided, gets all stages)'
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
export const filterDealsByPipelineTool = {
|
|
437
|
+
name: 'bitrix24_filter_deals_by_pipeline',
|
|
438
|
+
description: 'Filter deals by specific pipeline/category ID',
|
|
439
|
+
inputSchema: {
|
|
440
|
+
type: 'object',
|
|
441
|
+
properties: {
|
|
442
|
+
pipelineId: {
|
|
443
|
+
type: 'string',
|
|
444
|
+
description: 'Pipeline/Category ID to filter by'
|
|
445
|
+
},
|
|
446
|
+
limit: {
|
|
447
|
+
type: 'number',
|
|
448
|
+
description: 'Maximum number of deals to return',
|
|
449
|
+
default: 50
|
|
450
|
+
},
|
|
451
|
+
orderBy: {
|
|
452
|
+
type: 'string',
|
|
453
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE', 'OPPORTUNITY'],
|
|
454
|
+
description: 'Field to order by',
|
|
455
|
+
default: 'DATE_CREATE'
|
|
456
|
+
},
|
|
457
|
+
orderDirection: {
|
|
458
|
+
type: 'string',
|
|
459
|
+
enum: ['ASC', 'DESC'],
|
|
460
|
+
description: 'Order direction',
|
|
461
|
+
default: 'DESC'
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
required: ['pipelineId']
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
export const filterDealsByBudgetTool = {
|
|
468
|
+
name: 'bitrix24_filter_deals_by_budget',
|
|
469
|
+
description: 'Filter deals by budget/opportunity amount range',
|
|
470
|
+
inputSchema: {
|
|
471
|
+
type: 'object',
|
|
472
|
+
properties: {
|
|
473
|
+
minBudget: {
|
|
474
|
+
type: 'number',
|
|
475
|
+
description: 'Minimum budget amount'
|
|
476
|
+
},
|
|
477
|
+
maxBudget: {
|
|
478
|
+
type: 'number',
|
|
479
|
+
description: 'Maximum budget amount (optional)'
|
|
480
|
+
},
|
|
481
|
+
currency: {
|
|
482
|
+
type: 'string',
|
|
483
|
+
description: 'Currency code (e.g., EUR, USD)',
|
|
484
|
+
default: 'EUR'
|
|
485
|
+
},
|
|
486
|
+
limit: {
|
|
487
|
+
type: 'number',
|
|
488
|
+
description: 'Maximum number of deals to return',
|
|
489
|
+
default: 50
|
|
490
|
+
},
|
|
491
|
+
orderBy: {
|
|
492
|
+
type: 'string',
|
|
493
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE', 'OPPORTUNITY'],
|
|
494
|
+
description: 'Field to order by',
|
|
495
|
+
default: 'OPPORTUNITY'
|
|
496
|
+
},
|
|
497
|
+
orderDirection: {
|
|
498
|
+
type: 'string',
|
|
499
|
+
enum: ['ASC', 'DESC'],
|
|
500
|
+
description: 'Order direction',
|
|
501
|
+
default: 'DESC'
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
required: ['minBudget']
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
export const filterDealsByStatusTool = {
|
|
508
|
+
name: 'bitrix24_filter_deals_by_status',
|
|
509
|
+
description: 'Filter deals by stage/status IDs',
|
|
510
|
+
inputSchema: {
|
|
511
|
+
type: 'object',
|
|
512
|
+
properties: {
|
|
513
|
+
stageIds: {
|
|
514
|
+
type: 'array',
|
|
515
|
+
items: { type: 'string' },
|
|
516
|
+
description: 'Array of stage IDs to filter by'
|
|
517
|
+
},
|
|
518
|
+
pipelineId: {
|
|
519
|
+
type: 'string',
|
|
520
|
+
description: 'Pipeline ID to limit search to (optional)'
|
|
521
|
+
},
|
|
522
|
+
limit: {
|
|
523
|
+
type: 'number',
|
|
524
|
+
description: 'Maximum number of deals to return',
|
|
525
|
+
default: 50
|
|
526
|
+
},
|
|
527
|
+
orderBy: {
|
|
528
|
+
type: 'string',
|
|
529
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE', 'OPPORTUNITY'],
|
|
530
|
+
description: 'Field to order by',
|
|
531
|
+
default: 'DATE_CREATE'
|
|
532
|
+
},
|
|
533
|
+
orderDirection: {
|
|
534
|
+
type: 'string',
|
|
535
|
+
enum: ['ASC', 'DESC'],
|
|
536
|
+
description: 'Order direction',
|
|
537
|
+
default: 'DESC'
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
required: ['stageIds']
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
// Sales Team Monitoring Tools
|
|
544
|
+
export const monitorUserActivitiesTool = {
|
|
545
|
+
name: 'bitrix24_monitor_user_activities',
|
|
546
|
+
description: 'Monitor user activities including calls, emails, timeline interactions, and response times',
|
|
547
|
+
inputSchema: {
|
|
548
|
+
type: 'object',
|
|
549
|
+
properties: {
|
|
550
|
+
userId: { type: 'string', description: 'User ID to monitor (optional - if not provided, monitors all users)' },
|
|
551
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
552
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
553
|
+
includeCallVolume: { type: 'boolean', description: 'Include call volume metrics', default: true },
|
|
554
|
+
includeEmailActivity: { type: 'boolean', description: 'Include email activity metrics', default: true },
|
|
555
|
+
includeTimelineActivity: { type: 'boolean', description: 'Include timeline interactions', default: true },
|
|
556
|
+
includeResponseTimes: { type: 'boolean', description: 'Calculate response times', default: true }
|
|
557
|
+
},
|
|
558
|
+
required: ['startDate']
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
export const getUserPerformanceSummaryTool = {
|
|
562
|
+
name: 'bitrix24_get_user_performance_summary',
|
|
563
|
+
description: 'Get comprehensive performance summary for users including deal metrics and conversion rates',
|
|
564
|
+
inputSchema: {
|
|
565
|
+
type: 'object',
|
|
566
|
+
properties: {
|
|
567
|
+
userId: { type: 'string', description: 'User ID to analyze (optional - if not provided, analyzes all users)' },
|
|
568
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
569
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
570
|
+
includeDealMetrics: { type: 'boolean', description: 'Include deal creation/conversion metrics', default: true },
|
|
571
|
+
includeActivityRatios: { type: 'boolean', description: 'Include activity type ratios', default: true },
|
|
572
|
+
includeConversionRates: { type: 'boolean', description: 'Calculate conversion rates', default: true }
|
|
573
|
+
},
|
|
574
|
+
required: ['startDate']
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
export const analyzeAccountPerformanceTool = {
|
|
578
|
+
name: 'bitrix24_analyze_account_performance',
|
|
579
|
+
description: 'Analyze performance and activities for specific accounts (companies/contacts)',
|
|
580
|
+
inputSchema: {
|
|
581
|
+
type: 'object',
|
|
582
|
+
properties: {
|
|
583
|
+
accountId: { type: 'string', description: 'Account ID (company or contact ID)' },
|
|
584
|
+
accountType: { type: 'string', enum: ['company', 'contact'], description: 'Type of account to analyze' },
|
|
585
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
586
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
587
|
+
includeAllInteractions: { type: 'boolean', description: 'Include all user interactions with this account', default: true },
|
|
588
|
+
includeDealProgression: { type: 'boolean', description: 'Include deal progression analysis', default: true },
|
|
589
|
+
includeTimelineHistory: { type: 'boolean', description: 'Include complete timeline history', default: true }
|
|
590
|
+
},
|
|
591
|
+
required: ['accountId', 'accountType', 'startDate']
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
export const compareUserPerformanceTool = {
|
|
595
|
+
name: 'bitrix24_compare_user_performance',
|
|
596
|
+
description: 'Compare performance metrics between multiple users',
|
|
597
|
+
inputSchema: {
|
|
598
|
+
type: 'object',
|
|
599
|
+
properties: {
|
|
600
|
+
userIds: { type: 'array', items: { type: 'string' }, description: 'Array of user IDs to compare (optional - if not provided, compares all users)' },
|
|
601
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
602
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
603
|
+
metrics: {
|
|
604
|
+
type: 'array',
|
|
605
|
+
items: { type: 'string', enum: ['activities', 'deals', 'conversions', 'response_times', 'timeline_engagement'] },
|
|
606
|
+
description: 'Specific metrics to compare',
|
|
607
|
+
default: ['activities', 'deals', 'conversions']
|
|
608
|
+
},
|
|
609
|
+
includeRankings: { type: 'boolean', description: 'Include performance rankings', default: true },
|
|
610
|
+
includeTrends: { type: 'boolean', description: 'Include trend analysis', default: true }
|
|
611
|
+
},
|
|
612
|
+
required: ['startDate']
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
export const trackDealProgressionTool = {
|
|
616
|
+
name: 'bitrix24_track_deal_progression',
|
|
617
|
+
description: 'Track deal progression through pipeline stages with timing analysis',
|
|
618
|
+
inputSchema: {
|
|
619
|
+
type: 'object',
|
|
620
|
+
properties: {
|
|
621
|
+
dealId: { type: 'string', description: 'Specific deal ID to track (optional - if not provided, tracks all deals)' },
|
|
622
|
+
userId: { type: 'string', description: 'User ID to filter deals (optional)' },
|
|
623
|
+
pipelineId: { type: 'string', description: 'Pipeline ID to filter deals (optional)' },
|
|
624
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
625
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
626
|
+
includeStageDuration: { type: 'boolean', description: 'Calculate time spent in each stage', default: true },
|
|
627
|
+
identifyStalled: { type: 'boolean', description: 'Identify stalled deals', default: true },
|
|
628
|
+
calculateVelocity: { type: 'boolean', description: 'Calculate pipeline velocity', default: true }
|
|
629
|
+
},
|
|
630
|
+
required: ['startDate']
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
export const monitorSalesActivitiesTool = {
|
|
634
|
+
name: 'bitrix24_monitor_sales_activities',
|
|
635
|
+
description: 'Monitor sales-related activities including tasks, follow-ups, and meetings',
|
|
636
|
+
inputSchema: {
|
|
637
|
+
type: 'object',
|
|
638
|
+
properties: {
|
|
639
|
+
userId: { type: 'string', description: 'User ID to monitor (optional - if not provided, monitors all users)' },
|
|
640
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
641
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
642
|
+
includeTaskCompletion: { type: 'boolean', description: 'Include task completion rates', default: true },
|
|
643
|
+
includeFollowUpTracking: { type: 'boolean', description: 'Include follow-up tracking', default: true },
|
|
644
|
+
includeMeetingTracking: { type: 'boolean', description: 'Include meeting tracking', default: true },
|
|
645
|
+
includeQuoteActivity: { type: 'boolean', description: 'Include quote/proposal activity', default: true }
|
|
646
|
+
},
|
|
647
|
+
required: ['startDate']
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
export const generateSalesReportTool = {
|
|
651
|
+
name: 'bitrix24_generate_sales_report',
|
|
652
|
+
description: 'Generate comprehensive sales report with customizable metrics and date ranges',
|
|
653
|
+
inputSchema: {
|
|
654
|
+
type: 'object',
|
|
655
|
+
properties: {
|
|
656
|
+
reportType: {
|
|
657
|
+
type: 'string',
|
|
658
|
+
enum: ['user_performance', 'account_analysis', 'team_summary', 'pipeline_analysis', 'activity_report'],
|
|
659
|
+
description: 'Type of report to generate'
|
|
660
|
+
},
|
|
661
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
662
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
663
|
+
userIds: { type: 'array', items: { type: 'string' }, description: 'Specific user IDs to include (optional)' },
|
|
664
|
+
includeMetrics: {
|
|
665
|
+
type: 'array',
|
|
666
|
+
items: { type: 'string', enum: ['revenue', 'conversion_rates', 'activity_volumes', 'response_times', 'deal_progression'] },
|
|
667
|
+
description: 'Specific metrics to include in report',
|
|
668
|
+
default: ['revenue', 'conversion_rates', 'activity_volumes']
|
|
669
|
+
},
|
|
670
|
+
includeTrendAnalysis: { type: 'boolean', description: 'Include trend analysis', default: true },
|
|
671
|
+
includeComparisons: { type: 'boolean', description: 'Include performance comparisons', default: true }
|
|
672
|
+
},
|
|
673
|
+
required: ['reportType', 'startDate']
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
export const getTeamDashboardTool = {
|
|
677
|
+
name: 'bitrix24_get_team_dashboard',
|
|
678
|
+
description: 'Get real-time team performance dashboard with key metrics and alerts',
|
|
679
|
+
inputSchema: {
|
|
680
|
+
type: 'object',
|
|
681
|
+
properties: {
|
|
682
|
+
includeRealTimeMetrics: { type: 'boolean', description: 'Include real-time performance metrics', default: true },
|
|
683
|
+
includeTopPerformers: { type: 'boolean', description: 'Include top performers identification', default: true },
|
|
684
|
+
includeAttentionNeeded: { type: 'boolean', description: 'Include accounts/deals needing attention', default: true },
|
|
685
|
+
includeWorkloadDistribution: { type: 'boolean', description: 'Include workload distribution analysis', default: true },
|
|
686
|
+
timeframe: {
|
|
687
|
+
type: 'string',
|
|
688
|
+
enum: ['today', 'week', 'month', 'quarter'],
|
|
689
|
+
description: 'Timeframe for dashboard metrics',
|
|
690
|
+
default: 'today'
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
export const analyzeCustomerEngagementTool = {
|
|
696
|
+
name: 'bitrix24_analyze_customer_engagement',
|
|
697
|
+
description: 'Analyze customer engagement patterns and relationship health',
|
|
698
|
+
inputSchema: {
|
|
699
|
+
type: 'object',
|
|
700
|
+
properties: {
|
|
701
|
+
accountId: { type: 'string', description: 'Account ID (company or contact ID) - optional' },
|
|
702
|
+
accountType: { type: 'string', enum: ['company', 'contact'], description: 'Type of account' },
|
|
703
|
+
userId: { type: 'string', description: 'User ID to filter analysis (optional)' },
|
|
704
|
+
startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' },
|
|
705
|
+
endDate: { type: 'string', description: 'End date in YYYY-MM-DD format (optional - defaults to today)' },
|
|
706
|
+
includeCommunicationPatterns: { type: 'boolean', description: 'Include communication pattern analysis', default: true },
|
|
707
|
+
includeResponseQuality: { type: 'boolean', description: 'Include response quality metrics', default: true },
|
|
708
|
+
includeEngagementScores: { type: 'boolean', description: 'Calculate engagement scores', default: true },
|
|
709
|
+
includeRelationshipHealth: { type: 'boolean', description: 'Assess relationship health', default: true }
|
|
710
|
+
},
|
|
711
|
+
required: ['startDate']
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
export const forecastPerformanceTool = {
|
|
715
|
+
name: 'bitrix24_forecast_performance',
|
|
716
|
+
description: 'Generate performance forecasts and predictive analytics',
|
|
717
|
+
inputSchema: {
|
|
718
|
+
type: 'object',
|
|
719
|
+
properties: {
|
|
720
|
+
forecastType: {
|
|
721
|
+
type: 'string',
|
|
722
|
+
enum: ['pipeline_forecast', 'user_performance', 'revenue_prediction', 'goal_achievement'],
|
|
723
|
+
description: 'Type of forecast to generate'
|
|
724
|
+
},
|
|
725
|
+
userId: { type: 'string', description: 'User ID to forecast (optional - if not provided, forecasts for all users)' },
|
|
726
|
+
historicalPeriod: {
|
|
727
|
+
type: 'string',
|
|
728
|
+
enum: ['3_months', '6_months', '1_year'],
|
|
729
|
+
description: 'Historical period to use for forecasting',
|
|
730
|
+
default: '6_months'
|
|
731
|
+
},
|
|
732
|
+
forecastPeriod: {
|
|
733
|
+
type: 'string',
|
|
734
|
+
enum: ['1_month', '3_months', '6_months'],
|
|
735
|
+
description: 'Period to forecast into the future',
|
|
736
|
+
default: '1_month'
|
|
737
|
+
},
|
|
738
|
+
includePipelineAnalysis: { type: 'boolean', description: 'Include pipeline forecasting', default: true },
|
|
739
|
+
includeRiskAssessment: { type: 'boolean', description: 'Include risk assessment', default: true },
|
|
740
|
+
includeGoalTracking: { type: 'boolean', description: 'Include goal achievement tracking', default: true }
|
|
741
|
+
},
|
|
742
|
+
required: ['forecastType']
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
// User Management Tools
|
|
746
|
+
export const getUserTool = {
|
|
747
|
+
name: 'bitrix24_get_user',
|
|
748
|
+
description: 'Get user information by ID',
|
|
749
|
+
inputSchema: {
|
|
750
|
+
type: 'object',
|
|
751
|
+
properties: {
|
|
752
|
+
userId: { type: 'string', description: 'User ID to retrieve' }
|
|
753
|
+
},
|
|
754
|
+
required: ['userId']
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
export const getAllUsersTool = {
|
|
758
|
+
name: 'bitrix24_get_all_users',
|
|
759
|
+
description: 'Get all users in the system with their names and details',
|
|
760
|
+
inputSchema: {
|
|
761
|
+
type: 'object',
|
|
762
|
+
properties: {
|
|
763
|
+
includeInactive: { type: 'boolean', description: 'Include inactive users', default: false }
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
export const resolveUserNamesTool = {
|
|
768
|
+
name: 'bitrix24_resolve_user_names',
|
|
769
|
+
description: 'Resolve user IDs to user names',
|
|
770
|
+
inputSchema: {
|
|
771
|
+
type: 'object',
|
|
772
|
+
properties: {
|
|
773
|
+
userIds: {
|
|
774
|
+
type: 'array',
|
|
775
|
+
items: { type: 'string' },
|
|
776
|
+
description: 'Array of user IDs to resolve to names'
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
required: ['userIds']
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
export const getContactsWithUserNamesTool = {
|
|
783
|
+
name: 'bitrix24_get_contacts_with_user_names',
|
|
784
|
+
description: 'Get contacts with user names resolved (assigned, created, modified by)',
|
|
785
|
+
inputSchema: {
|
|
786
|
+
type: 'object',
|
|
787
|
+
properties: {
|
|
788
|
+
limit: { type: 'number', description: 'Maximum number of contacts to return', default: 20 },
|
|
789
|
+
filter: { type: 'object', description: 'Filter criteria' }
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
export const getDealsWithUserNamesTool = {
|
|
794
|
+
name: 'bitrix24_get_deals_with_user_names',
|
|
795
|
+
description: 'Get deals with user names resolved (assigned, created, modified by)',
|
|
796
|
+
inputSchema: {
|
|
797
|
+
type: 'object',
|
|
798
|
+
properties: {
|
|
799
|
+
limit: { type: 'number', description: 'Maximum number of deals to return', default: 20 },
|
|
800
|
+
filter: { type: 'object', description: 'Filter criteria' },
|
|
801
|
+
orderBy: {
|
|
802
|
+
type: 'string',
|
|
803
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE', 'OPPORTUNITY'],
|
|
804
|
+
description: 'Field to order by',
|
|
805
|
+
default: 'DATE_CREATE'
|
|
806
|
+
},
|
|
807
|
+
orderDirection: {
|
|
808
|
+
type: 'string',
|
|
809
|
+
enum: ['ASC', 'DESC'],
|
|
810
|
+
description: 'Order direction',
|
|
811
|
+
default: 'DESC'
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
export const getLeadsWithUserNamesTool = {
|
|
817
|
+
name: 'bitrix24_get_leads_with_user_names',
|
|
818
|
+
description: 'Get leads with user names resolved (assigned, created, modified by)',
|
|
819
|
+
inputSchema: {
|
|
820
|
+
type: 'object',
|
|
821
|
+
properties: {
|
|
822
|
+
limit: { type: 'number', description: 'Maximum number of leads to return', default: 20 },
|
|
823
|
+
filter: { type: 'object', description: 'Filter criteria' },
|
|
824
|
+
orderBy: {
|
|
825
|
+
type: 'string',
|
|
826
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE'],
|
|
827
|
+
description: 'Field to order by',
|
|
828
|
+
default: 'DATE_CREATE'
|
|
829
|
+
},
|
|
830
|
+
orderDirection: {
|
|
831
|
+
type: 'string',
|
|
832
|
+
enum: ['ASC', 'DESC'],
|
|
833
|
+
description: 'Order direction',
|
|
834
|
+
default: 'DESC'
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
export const getCompaniesWithUserNamesTool = {
|
|
840
|
+
name: 'bitrix24_get_companies_with_user_names',
|
|
841
|
+
description: 'Get companies with user names resolved (assigned, created, modified by)',
|
|
842
|
+
inputSchema: {
|
|
843
|
+
type: 'object',
|
|
844
|
+
properties: {
|
|
845
|
+
limit: { type: 'number', description: 'Maximum number of companies to return', default: 20 },
|
|
846
|
+
filter: { type: 'object', description: 'Filter criteria' },
|
|
847
|
+
orderBy: {
|
|
848
|
+
type: 'string',
|
|
849
|
+
enum: ['DATE_CREATE', 'DATE_MODIFY', 'ID', 'TITLE'],
|
|
850
|
+
description: 'Field to order by',
|
|
851
|
+
default: 'DATE_CREATE'
|
|
852
|
+
},
|
|
853
|
+
orderDirection: {
|
|
854
|
+
type: 'string',
|
|
855
|
+
enum: ['ASC', 'DESC'],
|
|
856
|
+
description: 'Order direction',
|
|
857
|
+
default: 'DESC'
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
// Export all tools
|
|
863
|
+
export const allTools = [
|
|
864
|
+
createContactTool,
|
|
865
|
+
getContactTool,
|
|
866
|
+
listContactsTool,
|
|
867
|
+
getLatestContactsTool,
|
|
868
|
+
updateContactTool,
|
|
869
|
+
createDealTool,
|
|
870
|
+
getDealTool,
|
|
871
|
+
listDealsTool,
|
|
872
|
+
getLatestDealsTool,
|
|
873
|
+
getDealsFromDateRangeTool,
|
|
874
|
+
updateDealTool,
|
|
875
|
+
createLeadTool,
|
|
876
|
+
getLeadTool,
|
|
877
|
+
listLeadsTool,
|
|
878
|
+
getLatestLeadsTool,
|
|
879
|
+
getLeadsFromDateRangeTool,
|
|
880
|
+
updateLeadTool,
|
|
881
|
+
createCompanyTool,
|
|
882
|
+
getCompanyTool,
|
|
883
|
+
listCompaniesTool,
|
|
884
|
+
updateCompanyTool,
|
|
885
|
+
getLatestCompaniesTool,
|
|
886
|
+
getCompaniesFromDateRangeTool,
|
|
887
|
+
searchCRMTool,
|
|
888
|
+
validateWebhookTool,
|
|
889
|
+
diagnosePermissionsTool,
|
|
890
|
+
checkCRMSettingsTool,
|
|
891
|
+
testLeadsAPITool,
|
|
892
|
+
// Phase 1: Enhanced Deal Filtering Tools
|
|
893
|
+
getDealPipelinesTool,
|
|
894
|
+
getDealStagesTool,
|
|
895
|
+
filterDealsByPipelineTool,
|
|
896
|
+
filterDealsByBudgetTool,
|
|
897
|
+
filterDealsByStatusTool,
|
|
898
|
+
// Sales Team Monitoring Tools
|
|
899
|
+
monitorUserActivitiesTool,
|
|
900
|
+
getUserPerformanceSummaryTool,
|
|
901
|
+
analyzeAccountPerformanceTool,
|
|
902
|
+
compareUserPerformanceTool,
|
|
903
|
+
trackDealProgressionTool,
|
|
904
|
+
monitorSalesActivitiesTool,
|
|
905
|
+
generateSalesReportTool,
|
|
906
|
+
getTeamDashboardTool,
|
|
907
|
+
analyzeCustomerEngagementTool,
|
|
908
|
+
forecastPerformanceTool,
|
|
909
|
+
// User Management Tools
|
|
910
|
+
getUserTool,
|
|
911
|
+
getAllUsersTool,
|
|
912
|
+
resolveUserNamesTool,
|
|
913
|
+
getContactsWithUserNamesTool,
|
|
914
|
+
getDealsWithUserNamesTool,
|
|
915
|
+
getLeadsWithUserNamesTool,
|
|
916
|
+
getCompaniesWithUserNamesTool
|
|
917
|
+
];
|
|
918
|
+
// Tool execution handlers
|
|
919
|
+
export async function executeToolCall(name, args) {
|
|
920
|
+
try {
|
|
921
|
+
switch (name) {
|
|
922
|
+
case 'bitrix24_create_contact':
|
|
923
|
+
const contact = {
|
|
924
|
+
NAME: args.name,
|
|
925
|
+
LAST_NAME: args.lastName,
|
|
926
|
+
PHONE: args.phone ? [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }] : undefined,
|
|
927
|
+
EMAIL: args.email ? [{ VALUE: args.email, VALUE_TYPE: 'WORK' }] : undefined,
|
|
928
|
+
COMPANY_TITLE: args.company,
|
|
929
|
+
POST: args.position,
|
|
930
|
+
COMMENTS: args.comments
|
|
931
|
+
};
|
|
932
|
+
const contactId = await bitrix24Client.createContact(contact);
|
|
933
|
+
return { success: true, contactId, message: `Contact created with ID: ${contactId}` };
|
|
934
|
+
case 'bitrix24_get_contact':
|
|
935
|
+
const contactData = await bitrix24Client.getContact(args.id);
|
|
936
|
+
return { success: true, contact: contactData };
|
|
937
|
+
case 'bitrix24_list_contacts':
|
|
938
|
+
const contacts = await bitrix24Client.listContacts({
|
|
939
|
+
start: 0,
|
|
940
|
+
filter: args.filter
|
|
941
|
+
});
|
|
942
|
+
return { success: true, contacts: contacts.slice(0, args.limit || 20) };
|
|
943
|
+
case 'bitrix24_get_latest_contacts':
|
|
944
|
+
const latestContacts = await bitrix24Client.getLatestContacts(args.limit || 20);
|
|
945
|
+
return { success: true, contacts: latestContacts };
|
|
946
|
+
case 'bitrix24_update_contact':
|
|
947
|
+
const updateContact = {};
|
|
948
|
+
if (args.name)
|
|
949
|
+
updateContact.NAME = args.name;
|
|
950
|
+
if (args.lastName)
|
|
951
|
+
updateContact.LAST_NAME = args.lastName;
|
|
952
|
+
if (args.phone)
|
|
953
|
+
updateContact.PHONE = [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }];
|
|
954
|
+
if (args.email)
|
|
955
|
+
updateContact.EMAIL = [{ VALUE: args.email, VALUE_TYPE: 'WORK' }];
|
|
956
|
+
if (args.company)
|
|
957
|
+
updateContact.COMPANY_TITLE = args.company;
|
|
958
|
+
if (args.position)
|
|
959
|
+
updateContact.POST = args.position;
|
|
960
|
+
if (args.comments)
|
|
961
|
+
updateContact.COMMENTS = args.comments;
|
|
962
|
+
const contactUpdated = await bitrix24Client.updateContact(args.id, updateContact);
|
|
963
|
+
return { success: true, updated: contactUpdated, message: `Contact ${args.id} updated successfully` };
|
|
964
|
+
case 'bitrix24_create_deal':
|
|
965
|
+
const deal = {
|
|
966
|
+
TITLE: args.title,
|
|
967
|
+
OPPORTUNITY: args.amount,
|
|
968
|
+
CURRENCY_ID: args.currency || 'EUR',
|
|
969
|
+
CONTACT_ID: args.contactId,
|
|
970
|
+
STAGE_ID: args.stageId,
|
|
971
|
+
COMMENTS: args.comments
|
|
972
|
+
};
|
|
973
|
+
const dealId = await bitrix24Client.createDeal(deal);
|
|
974
|
+
return { success: true, dealId, message: `Deal created with ID: ${dealId}` };
|
|
975
|
+
case 'bitrix24_get_deal':
|
|
976
|
+
const dealData = await bitrix24Client.getDeal(args.id);
|
|
977
|
+
return { success: true, deal: dealData };
|
|
978
|
+
case 'bitrix24_list_deals':
|
|
979
|
+
const dealOrder = {};
|
|
980
|
+
dealOrder[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
981
|
+
const deals = await bitrix24Client.listDeals({
|
|
982
|
+
start: 0,
|
|
983
|
+
filter: args.filter,
|
|
984
|
+
order: dealOrder,
|
|
985
|
+
select: ['*']
|
|
986
|
+
});
|
|
987
|
+
return { success: true, deals: deals.slice(0, args.limit || 20) };
|
|
988
|
+
case 'bitrix24_get_latest_deals':
|
|
989
|
+
const latestDeals = await bitrix24Client.getLatestDeals(args.limit || 20);
|
|
990
|
+
return { success: true, deals: latestDeals };
|
|
991
|
+
case 'bitrix24_get_deals_from_date_range':
|
|
992
|
+
const dateRangeDeals = await bitrix24Client.getDealsFromDateRange(args.startDate, args.endDate, args.limit || 50);
|
|
993
|
+
return { success: true, deals: dateRangeDeals };
|
|
994
|
+
case 'bitrix24_update_deal':
|
|
995
|
+
const updateDeal = {};
|
|
996
|
+
if (args.title)
|
|
997
|
+
updateDeal.TITLE = args.title;
|
|
998
|
+
if (args.amount)
|
|
999
|
+
updateDeal.OPPORTUNITY = args.amount;
|
|
1000
|
+
if (args.currency)
|
|
1001
|
+
updateDeal.CURRENCY_ID = args.currency;
|
|
1002
|
+
if (args.contactId)
|
|
1003
|
+
updateDeal.CONTACT_ID = args.contactId;
|
|
1004
|
+
if (args.stageId)
|
|
1005
|
+
updateDeal.STAGE_ID = args.stageId;
|
|
1006
|
+
if (args.comments)
|
|
1007
|
+
updateDeal.COMMENTS = args.comments;
|
|
1008
|
+
const dealUpdated = await bitrix24Client.updateDeal(args.id, updateDeal);
|
|
1009
|
+
return { success: true, updated: dealUpdated, message: `Deal ${args.id} updated successfully` };
|
|
1010
|
+
case 'bitrix24_create_lead':
|
|
1011
|
+
const lead = {
|
|
1012
|
+
TITLE: args.title,
|
|
1013
|
+
NAME: args.name,
|
|
1014
|
+
LAST_NAME: args.lastName,
|
|
1015
|
+
COMPANY_TITLE: args.company,
|
|
1016
|
+
PHONE: args.phone ? [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }] : undefined,
|
|
1017
|
+
EMAIL: args.email ? [{ VALUE: args.email, VALUE_TYPE: 'WORK' }] : undefined,
|
|
1018
|
+
SOURCE_ID: args.sourceId,
|
|
1019
|
+
STATUS_ID: args.statusId,
|
|
1020
|
+
OPPORTUNITY: args.opportunity,
|
|
1021
|
+
CURRENCY_ID: args.currency || 'EUR',
|
|
1022
|
+
COMMENTS: args.comments
|
|
1023
|
+
};
|
|
1024
|
+
const leadId = await bitrix24Client.createLead(lead);
|
|
1025
|
+
return { success: true, leadId, message: `Lead created with ID: ${leadId}` };
|
|
1026
|
+
case 'bitrix24_get_lead':
|
|
1027
|
+
const leadData = await bitrix24Client.getLead(args.id);
|
|
1028
|
+
return { success: true, lead: leadData };
|
|
1029
|
+
case 'bitrix24_list_leads':
|
|
1030
|
+
const leadOrder = {};
|
|
1031
|
+
leadOrder[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
1032
|
+
const leads = await bitrix24Client.listLeads({
|
|
1033
|
+
start: 0,
|
|
1034
|
+
filter: args.filter,
|
|
1035
|
+
order: leadOrder,
|
|
1036
|
+
select: ['*']
|
|
1037
|
+
});
|
|
1038
|
+
return { success: true, leads: leads.slice(0, args.limit || 20) };
|
|
1039
|
+
case 'bitrix24_get_latest_leads':
|
|
1040
|
+
const latestLeads = await bitrix24Client.getLatestLeads(args.limit || 20);
|
|
1041
|
+
return { success: true, leads: latestLeads };
|
|
1042
|
+
case 'bitrix24_get_leads_from_date_range':
|
|
1043
|
+
const dateRangeLeads = await bitrix24Client.getLeadsFromDateRange(args.startDate, args.endDate, args.limit || 50);
|
|
1044
|
+
return { success: true, leads: dateRangeLeads };
|
|
1045
|
+
case 'bitrix24_update_lead':
|
|
1046
|
+
const updateLead = {};
|
|
1047
|
+
if (args.title)
|
|
1048
|
+
updateLead.TITLE = args.title;
|
|
1049
|
+
if (args.name)
|
|
1050
|
+
updateLead.NAME = args.name;
|
|
1051
|
+
if (args.lastName)
|
|
1052
|
+
updateLead.LAST_NAME = args.lastName;
|
|
1053
|
+
if (args.company)
|
|
1054
|
+
updateLead.COMPANY_TITLE = args.company;
|
|
1055
|
+
if (args.phone)
|
|
1056
|
+
updateLead.PHONE = [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }];
|
|
1057
|
+
if (args.email)
|
|
1058
|
+
updateLead.EMAIL = [{ VALUE: args.email, VALUE_TYPE: 'WORK' }];
|
|
1059
|
+
if (args.sourceId)
|
|
1060
|
+
updateLead.SOURCE_ID = args.sourceId;
|
|
1061
|
+
if (args.statusId)
|
|
1062
|
+
updateLead.STATUS_ID = args.statusId;
|
|
1063
|
+
if (args.opportunity)
|
|
1064
|
+
updateLead.OPPORTUNITY = args.opportunity;
|
|
1065
|
+
if (args.currency)
|
|
1066
|
+
updateLead.CURRENCY_ID = args.currency;
|
|
1067
|
+
if (args.comments)
|
|
1068
|
+
updateLead.COMMENTS = args.comments;
|
|
1069
|
+
const leadUpdated = await bitrix24Client.updateLead(args.id, updateLead);
|
|
1070
|
+
return { success: true, updated: leadUpdated, message: `Lead ${args.id} updated successfully` };
|
|
1071
|
+
case 'bitrix24_create_company':
|
|
1072
|
+
const company = {
|
|
1073
|
+
TITLE: args.title,
|
|
1074
|
+
COMPANY_TYPE: args.companyType,
|
|
1075
|
+
INDUSTRY: args.industry,
|
|
1076
|
+
PHONE: args.phone ? [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }] : undefined,
|
|
1077
|
+
EMAIL: args.email ? [{ VALUE: args.email, VALUE_TYPE: 'WORK' }] : undefined,
|
|
1078
|
+
WEB: args.website ? [{ VALUE: args.website, VALUE_TYPE: 'WORK' }] : undefined,
|
|
1079
|
+
ADDRESS: args.address,
|
|
1080
|
+
EMPLOYEES: args.employees,
|
|
1081
|
+
REVENUE: args.revenue,
|
|
1082
|
+
COMMENTS: args.comments,
|
|
1083
|
+
ASSIGNED_BY_ID: args.assignedById
|
|
1084
|
+
};
|
|
1085
|
+
const companyId = await bitrix24Client.createCompany(company);
|
|
1086
|
+
return { success: true, companyId, message: `Company created with ID: ${companyId}` };
|
|
1087
|
+
case 'bitrix24_get_company':
|
|
1088
|
+
const companyData = await bitrix24Client.getCompany(args.id);
|
|
1089
|
+
return { success: true, company: companyData };
|
|
1090
|
+
case 'bitrix24_list_companies':
|
|
1091
|
+
const companyOrder = {};
|
|
1092
|
+
companyOrder[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
1093
|
+
const companies = await bitrix24Client.listCompanies({
|
|
1094
|
+
start: 0,
|
|
1095
|
+
filter: args.filter,
|
|
1096
|
+
order: companyOrder,
|
|
1097
|
+
select: ['*']
|
|
1098
|
+
});
|
|
1099
|
+
return { success: true, companies: companies.slice(0, args.limit || 20) };
|
|
1100
|
+
case 'bitrix24_update_company':
|
|
1101
|
+
const updateCompany = {};
|
|
1102
|
+
if (args.title)
|
|
1103
|
+
updateCompany.TITLE = args.title;
|
|
1104
|
+
if (args.companyType)
|
|
1105
|
+
updateCompany.COMPANY_TYPE = args.companyType;
|
|
1106
|
+
if (args.industry)
|
|
1107
|
+
updateCompany.INDUSTRY = args.industry;
|
|
1108
|
+
if (args.phone)
|
|
1109
|
+
updateCompany.PHONE = [{ VALUE: args.phone, VALUE_TYPE: 'WORK' }];
|
|
1110
|
+
if (args.email)
|
|
1111
|
+
updateCompany.EMAIL = [{ VALUE: args.email, VALUE_TYPE: 'WORK' }];
|
|
1112
|
+
if (args.website)
|
|
1113
|
+
updateCompany.WEB = [{ VALUE: args.website, VALUE_TYPE: 'WORK' }];
|
|
1114
|
+
if (args.address)
|
|
1115
|
+
updateCompany.ADDRESS = args.address;
|
|
1116
|
+
if (args.employees)
|
|
1117
|
+
updateCompany.EMPLOYEES = args.employees;
|
|
1118
|
+
if (args.revenue)
|
|
1119
|
+
updateCompany.REVENUE = args.revenue;
|
|
1120
|
+
if (args.comments)
|
|
1121
|
+
updateCompany.COMMENTS = args.comments;
|
|
1122
|
+
if (args.assignedById)
|
|
1123
|
+
updateCompany.ASSIGNED_BY_ID = args.assignedById;
|
|
1124
|
+
const companyUpdated = await bitrix24Client.updateCompany(args.id, updateCompany);
|
|
1125
|
+
return { success: true, updated: companyUpdated, message: `Company ${args.id} updated successfully` };
|
|
1126
|
+
case 'bitrix24_get_latest_companies':
|
|
1127
|
+
const latestCompanies = await bitrix24Client.getLatestCompanies(args.limit || 20);
|
|
1128
|
+
return { success: true, companies: latestCompanies };
|
|
1129
|
+
case 'bitrix24_get_companies_from_date_range':
|
|
1130
|
+
const dateRangeCompanies = await bitrix24Client.getCompaniesFromDateRange(args.startDate, args.endDate, args.limit || 50);
|
|
1131
|
+
return { success: true, companies: dateRangeCompanies };
|
|
1132
|
+
case 'bitrix24_search_crm':
|
|
1133
|
+
const searchResults = await bitrix24Client.searchCRM(args.query, args.entityTypes);
|
|
1134
|
+
return { success: true, results: searchResults };
|
|
1135
|
+
case 'bitrix24_validate_webhook':
|
|
1136
|
+
const isValid = await bitrix24Client.validateWebhook();
|
|
1137
|
+
return { success: true, valid: isValid, message: isValid ? 'Webhook is valid' : 'Webhook validation failed' };
|
|
1138
|
+
case 'bitrix24_diagnose_permissions':
|
|
1139
|
+
const permissionResults = await bitrix24Client.diagnosePermissions();
|
|
1140
|
+
return { success: true, diagnosis: permissionResults };
|
|
1141
|
+
case 'bitrix24_check_crm_settings':
|
|
1142
|
+
const crmSettings = await bitrix24Client.checkCRMSettings();
|
|
1143
|
+
return { success: true, settings: crmSettings };
|
|
1144
|
+
case 'bitrix24_test_leads_api':
|
|
1145
|
+
const leadsTest = await bitrix24Client.testLeadsAPI();
|
|
1146
|
+
return { success: true, tests: leadsTest };
|
|
1147
|
+
// Phase 1: Enhanced Deal Filtering Tools
|
|
1148
|
+
case 'bitrix24_get_deal_pipelines':
|
|
1149
|
+
const pipelines = await bitrix24Client.getDealPipelines();
|
|
1150
|
+
return { success: true, pipelines, message: `Found ${pipelines.length} deal pipelines` };
|
|
1151
|
+
case 'bitrix24_get_deal_stages':
|
|
1152
|
+
const stages = await bitrix24Client.getDealStages(args.pipelineId);
|
|
1153
|
+
return { success: true, stages, message: `Found ${stages.length} deal stages` };
|
|
1154
|
+
case 'bitrix24_filter_deals_by_pipeline':
|
|
1155
|
+
const pipelineDeals = await bitrix24Client.filterDealsByPipeline(args.pipelineId, {
|
|
1156
|
+
limit: args.limit,
|
|
1157
|
+
orderBy: args.orderBy,
|
|
1158
|
+
orderDirection: args.orderDirection
|
|
1159
|
+
});
|
|
1160
|
+
return {
|
|
1161
|
+
success: true,
|
|
1162
|
+
deals: pipelineDeals,
|
|
1163
|
+
count: pipelineDeals.length,
|
|
1164
|
+
message: `Found ${pipelineDeals.length} deals in pipeline ${args.pipelineId}`
|
|
1165
|
+
};
|
|
1166
|
+
case 'bitrix24_filter_deals_by_budget':
|
|
1167
|
+
const budgetDeals = await bitrix24Client.filterDealsByBudget(args.minBudget, args.maxBudget, args.currency || 'EUR', {
|
|
1168
|
+
limit: args.limit,
|
|
1169
|
+
orderBy: args.orderBy,
|
|
1170
|
+
orderDirection: args.orderDirection
|
|
1171
|
+
});
|
|
1172
|
+
const budgetMessage = args.maxBudget
|
|
1173
|
+
? `Found ${budgetDeals.length} deals with budget between ${args.minBudget} and ${args.maxBudget} ${args.currency || 'EUR'}`
|
|
1174
|
+
: `Found ${budgetDeals.length} deals with budget ≥ ${args.minBudget} ${args.currency || 'EUR'}`;
|
|
1175
|
+
return {
|
|
1176
|
+
success: true,
|
|
1177
|
+
deals: budgetDeals,
|
|
1178
|
+
count: budgetDeals.length,
|
|
1179
|
+
message: budgetMessage
|
|
1180
|
+
};
|
|
1181
|
+
case 'bitrix24_filter_deals_by_status':
|
|
1182
|
+
const statusDeals = await bitrix24Client.filterDealsByStatus(args.stageIds, args.pipelineId, {
|
|
1183
|
+
limit: args.limit,
|
|
1184
|
+
orderBy: args.orderBy,
|
|
1185
|
+
orderDirection: args.orderDirection
|
|
1186
|
+
});
|
|
1187
|
+
const statusMessage = args.pipelineId
|
|
1188
|
+
? `Found ${statusDeals.length} deals with stages [${args.stageIds.join(', ')}] in pipeline ${args.pipelineId}`
|
|
1189
|
+
: `Found ${statusDeals.length} deals with stages [${args.stageIds.join(', ')}]`;
|
|
1190
|
+
return {
|
|
1191
|
+
success: true,
|
|
1192
|
+
deals: statusDeals,
|
|
1193
|
+
count: statusDeals.length,
|
|
1194
|
+
message: statusMessage
|
|
1195
|
+
};
|
|
1196
|
+
// Sales Team Monitoring Tools
|
|
1197
|
+
case 'bitrix24_monitor_user_activities':
|
|
1198
|
+
const userActivities = await bitrix24Client.monitorUserActivities(args.userId, args.startDate, args.endDate, {
|
|
1199
|
+
includeCallVolume: args.includeCallVolume,
|
|
1200
|
+
includeEmailActivity: args.includeEmailActivity,
|
|
1201
|
+
includeTimelineActivity: args.includeTimelineActivity,
|
|
1202
|
+
includeResponseTimes: args.includeResponseTimes
|
|
1203
|
+
});
|
|
1204
|
+
return {
|
|
1205
|
+
success: true,
|
|
1206
|
+
activities: userActivities,
|
|
1207
|
+
message: `User activity monitoring completed for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1208
|
+
};
|
|
1209
|
+
case 'bitrix24_get_user_performance_summary':
|
|
1210
|
+
const performanceSummary = await bitrix24Client.getUserPerformanceSummary(args.userId, args.startDate, args.endDate, {
|
|
1211
|
+
includeDealMetrics: args.includeDealMetrics,
|
|
1212
|
+
includeActivityRatios: args.includeActivityRatios,
|
|
1213
|
+
includeConversionRates: args.includeConversionRates
|
|
1214
|
+
});
|
|
1215
|
+
return {
|
|
1216
|
+
success: true,
|
|
1217
|
+
performance: performanceSummary,
|
|
1218
|
+
message: `Performance summary generated for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1219
|
+
};
|
|
1220
|
+
case 'bitrix24_analyze_account_performance':
|
|
1221
|
+
const accountPerformance = await bitrix24Client.analyzeAccountPerformance(args.accountId, args.accountType, args.startDate, args.endDate, {
|
|
1222
|
+
includeAllInteractions: args.includeAllInteractions,
|
|
1223
|
+
includeDealProgression: args.includeDealProgression,
|
|
1224
|
+
includeTimelineHistory: args.includeTimelineHistory
|
|
1225
|
+
});
|
|
1226
|
+
return {
|
|
1227
|
+
success: true,
|
|
1228
|
+
accountAnalysis: accountPerformance,
|
|
1229
|
+
message: `Account performance analysis completed for ${args.accountType} ${args.accountId}`
|
|
1230
|
+
};
|
|
1231
|
+
case 'bitrix24_compare_user_performance':
|
|
1232
|
+
const userComparison = await bitrix24Client.compareUserPerformance(args.userIds, args.startDate, args.endDate, {
|
|
1233
|
+
metrics: args.metrics,
|
|
1234
|
+
includeRankings: args.includeRankings,
|
|
1235
|
+
includeTrends: args.includeTrends
|
|
1236
|
+
});
|
|
1237
|
+
return {
|
|
1238
|
+
success: true,
|
|
1239
|
+
comparison: userComparison,
|
|
1240
|
+
message: `User performance comparison completed for ${args.userIds?.length || 'all'} users`
|
|
1241
|
+
};
|
|
1242
|
+
case 'bitrix24_track_deal_progression':
|
|
1243
|
+
const dealProgression = await bitrix24Client.trackDealProgression(args.dealId, args.userId, args.pipelineId, args.startDate, args.endDate, {
|
|
1244
|
+
includeStageDuration: args.includeStageDuration,
|
|
1245
|
+
identifyStalled: args.identifyStalled,
|
|
1246
|
+
calculateVelocity: args.calculateVelocity
|
|
1247
|
+
});
|
|
1248
|
+
return {
|
|
1249
|
+
success: true,
|
|
1250
|
+
progression: dealProgression,
|
|
1251
|
+
message: `Deal progression tracking completed for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1252
|
+
};
|
|
1253
|
+
case 'bitrix24_monitor_sales_activities':
|
|
1254
|
+
const salesActivities = await bitrix24Client.monitorSalesActivities(args.userId, args.startDate, args.endDate, {
|
|
1255
|
+
includeTaskCompletion: args.includeTaskCompletion,
|
|
1256
|
+
includeFollowUpTracking: args.includeFollowUpTracking,
|
|
1257
|
+
includeMeetingTracking: args.includeMeetingTracking,
|
|
1258
|
+
includeQuoteActivity: args.includeQuoteActivity
|
|
1259
|
+
});
|
|
1260
|
+
return {
|
|
1261
|
+
success: true,
|
|
1262
|
+
salesActivities: salesActivities,
|
|
1263
|
+
message: `Sales activities monitoring completed for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1264
|
+
};
|
|
1265
|
+
case 'bitrix24_generate_sales_report':
|
|
1266
|
+
const salesReport = await bitrix24Client.generateSalesReport(args.reportType, args.startDate, args.endDate, {
|
|
1267
|
+
userIds: args.userIds,
|
|
1268
|
+
includeMetrics: args.includeMetrics,
|
|
1269
|
+
includeTrendAnalysis: args.includeTrendAnalysis,
|
|
1270
|
+
includeComparisons: args.includeComparisons
|
|
1271
|
+
});
|
|
1272
|
+
return {
|
|
1273
|
+
success: true,
|
|
1274
|
+
report: salesReport,
|
|
1275
|
+
message: `${args.reportType} report generated for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1276
|
+
};
|
|
1277
|
+
case 'bitrix24_get_team_dashboard':
|
|
1278
|
+
const teamDashboard = await bitrix24Client.getTeamDashboard({
|
|
1279
|
+
includeRealTimeMetrics: args.includeRealTimeMetrics,
|
|
1280
|
+
includeTopPerformers: args.includeTopPerformers,
|
|
1281
|
+
includeAttentionNeeded: args.includeAttentionNeeded,
|
|
1282
|
+
includeWorkloadDistribution: args.includeWorkloadDistribution,
|
|
1283
|
+
timeframe: args.timeframe
|
|
1284
|
+
});
|
|
1285
|
+
return {
|
|
1286
|
+
success: true,
|
|
1287
|
+
dashboard: teamDashboard,
|
|
1288
|
+
message: `Team dashboard generated for timeframe: ${args.timeframe || 'today'}`
|
|
1289
|
+
};
|
|
1290
|
+
case 'bitrix24_analyze_customer_engagement':
|
|
1291
|
+
const customerEngagement = await bitrix24Client.analyzeCustomerEngagement(args.accountId, args.accountType, args.userId, args.startDate, args.endDate, {
|
|
1292
|
+
includeCommunicationPatterns: args.includeCommunicationPatterns,
|
|
1293
|
+
includeResponseQuality: args.includeResponseQuality,
|
|
1294
|
+
includeEngagementScores: args.includeEngagementScores,
|
|
1295
|
+
includeRelationshipHealth: args.includeRelationshipHealth
|
|
1296
|
+
});
|
|
1297
|
+
return {
|
|
1298
|
+
success: true,
|
|
1299
|
+
engagement: customerEngagement,
|
|
1300
|
+
message: `Customer engagement analysis completed for period ${args.startDate} to ${args.endDate || 'today'}`
|
|
1301
|
+
};
|
|
1302
|
+
case 'bitrix24_forecast_performance':
|
|
1303
|
+
const performanceForecast = await bitrix24Client.forecastPerformance(args.forecastType, args.userId, {
|
|
1304
|
+
historicalPeriod: args.historicalPeriod,
|
|
1305
|
+
forecastPeriod: args.forecastPeriod,
|
|
1306
|
+
includePipelineAnalysis: args.includePipelineAnalysis,
|
|
1307
|
+
includeRiskAssessment: args.includeRiskAssessment,
|
|
1308
|
+
includeGoalTracking: args.includeGoalTracking
|
|
1309
|
+
});
|
|
1310
|
+
return {
|
|
1311
|
+
success: true,
|
|
1312
|
+
forecast: performanceForecast,
|
|
1313
|
+
message: `${args.forecastType} forecast generated using ${args.historicalPeriod || '6_months'} of historical data`
|
|
1314
|
+
};
|
|
1315
|
+
// User Management Tools
|
|
1316
|
+
case 'bitrix24_get_user':
|
|
1317
|
+
const userData = await bitrix24Client.getUser(args.userId);
|
|
1318
|
+
return { success: true, user: userData };
|
|
1319
|
+
case 'bitrix24_get_all_users':
|
|
1320
|
+
const allUsers = await bitrix24Client.getAllUsers();
|
|
1321
|
+
return { success: true, users: allUsers, message: `Found ${allUsers.length} users` };
|
|
1322
|
+
case 'bitrix24_resolve_user_names':
|
|
1323
|
+
const userNames = await bitrix24Client.resolveUserNames(args.userIds);
|
|
1324
|
+
return { success: true, userNames, message: `Resolved ${Object.keys(userNames).length} user names` };
|
|
1325
|
+
case 'bitrix24_get_contacts_with_user_names':
|
|
1326
|
+
const contactsRaw = await bitrix24Client.listContacts({
|
|
1327
|
+
start: 0,
|
|
1328
|
+
filter: args.filter
|
|
1329
|
+
});
|
|
1330
|
+
const contactsWithNames = await bitrix24Client.enhanceWithUserNames(contactsRaw.slice(0, args.limit || 20));
|
|
1331
|
+
return { success: true, contacts: contactsWithNames, message: `Retrieved ${contactsWithNames.length} contacts with user names resolved` };
|
|
1332
|
+
case 'bitrix24_get_deals_with_user_names':
|
|
1333
|
+
const dealOrderWithNames = {};
|
|
1334
|
+
dealOrderWithNames[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
1335
|
+
const dealsRaw = await bitrix24Client.listDeals({
|
|
1336
|
+
start: 0,
|
|
1337
|
+
filter: args.filter,
|
|
1338
|
+
order: dealOrderWithNames,
|
|
1339
|
+
select: ['*']
|
|
1340
|
+
});
|
|
1341
|
+
const dealsWithNames = await bitrix24Client.enhanceWithUserNames(dealsRaw.slice(0, args.limit || 20));
|
|
1342
|
+
return { success: true, deals: dealsWithNames, message: `Retrieved ${dealsWithNames.length} deals with user names resolved` };
|
|
1343
|
+
case 'bitrix24_get_leads_with_user_names':
|
|
1344
|
+
const leadOrderWithNames = {};
|
|
1345
|
+
leadOrderWithNames[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
1346
|
+
const leadsRaw = await bitrix24Client.listLeads({
|
|
1347
|
+
start: 0,
|
|
1348
|
+
filter: args.filter,
|
|
1349
|
+
order: leadOrderWithNames,
|
|
1350
|
+
select: ['*']
|
|
1351
|
+
});
|
|
1352
|
+
const leadsWithNames = await bitrix24Client.enhanceWithUserNames(leadsRaw.slice(0, args.limit || 20));
|
|
1353
|
+
return { success: true, leads: leadsWithNames, message: `Retrieved ${leadsWithNames.length} leads with user names resolved` };
|
|
1354
|
+
case 'bitrix24_get_companies_with_user_names':
|
|
1355
|
+
const companyOrderWithNames = {};
|
|
1356
|
+
companyOrderWithNames[args.orderBy || 'DATE_CREATE'] = args.orderDirection || 'DESC';
|
|
1357
|
+
const companiesRaw = await bitrix24Client.listCompanies({
|
|
1358
|
+
start: 0,
|
|
1359
|
+
filter: args.filter,
|
|
1360
|
+
order: companyOrderWithNames,
|
|
1361
|
+
select: ['*']
|
|
1362
|
+
});
|
|
1363
|
+
const companiesWithNames = await bitrix24Client.enhanceWithUserNames(companiesRaw.slice(0, args.limit || 20));
|
|
1364
|
+
return { success: true, companies: companiesWithNames, message: `Retrieved ${companiesWithNames.length} companies with user names resolved` };
|
|
1365
|
+
default:
|
|
1366
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
catch (error) {
|
|
1370
|
+
console.error(`Tool execution error [${name}]:`, error);
|
|
1371
|
+
return {
|
|
1372
|
+
success: false,
|
|
1373
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
//# sourceMappingURL=index.js.map
|