@unboundcx/sdk 2.8.7 → 2.8.8
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/index.js +6 -0
- package/package.json +1 -1
- package/services/ai.js +242 -2
- package/services/externalOAuth.js +45 -0
- package/services/fax.js +249 -0
- package/services/knowledgeBase.js +229 -0
- package/services/messaging/EmailTemplatesService.js +31 -11
- package/services/messaging/TenDlcCampaignManagementService.js +187 -105
- package/services/messaging/TollFreeCampaignsService.js +263 -110
- package/services/notes.js +27 -2
- package/services/objects.js +80 -0
- package/services/portals.js +89 -0
- package/services/storage.js +134 -0
- package/services/taskRouter/TaskService.js +8 -0
- package/services/workflows.js +133 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
export class KnowledgeBaseService {
|
|
2
|
+
constructor(sdk) {
|
|
3
|
+
this.sdk = sdk;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hybrid search across knowledge base content
|
|
8
|
+
* Combines keyword (FULLTEXT) and semantic (vector) search with optional LLM reranking
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} params
|
|
11
|
+
* @param {string} params.query - Search query text
|
|
12
|
+
* @param {string} [params.knowledgeBaseId] - Specific KB to search (omit to search all)
|
|
13
|
+
* @param {number} [params.limit] - Max results to return
|
|
14
|
+
* @param {Object} [params.filters] - Optional filters
|
|
15
|
+
* @param {string} [params.filters.categoryId] - Filter by category
|
|
16
|
+
* @param {string} [params.filters.sourceType] - Filter by source type (article, document, source)
|
|
17
|
+
* @param {Array} [params.filters.tags] - Filter by tags
|
|
18
|
+
* @param {boolean} [params.rerank] - Whether to apply LLM reranking (default: true)
|
|
19
|
+
* @returns {Promise<Object>} Search results with source attribution
|
|
20
|
+
*/
|
|
21
|
+
async search({ query, knowledgeBaseId, limit, filters, rerank }) {
|
|
22
|
+
this.sdk.validateParams(
|
|
23
|
+
{ query },
|
|
24
|
+
{
|
|
25
|
+
query: { type: 'string', required: true },
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const params = {
|
|
30
|
+
body: { query, knowledgeBaseId, limit, filters, rerank },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const result = await this.sdk._fetch(
|
|
34
|
+
'/knowledgeBase/search',
|
|
35
|
+
'POST',
|
|
36
|
+
params,
|
|
37
|
+
);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Discover pages available at a URL
|
|
43
|
+
* Checks for sitemaps (auto-discovery + direct sitemap URLs) and returns
|
|
44
|
+
* a list of pages the user can select from before ingesting.
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} params
|
|
47
|
+
* @param {string} params.url - URL to discover (base URL or sitemap URL)
|
|
48
|
+
* @returns {Promise<Object>} { url, type, sitemapUrl, pages[], pageCount }
|
|
49
|
+
*/
|
|
50
|
+
async discoverUrl({ url }) {
|
|
51
|
+
this.sdk.validateParams(
|
|
52
|
+
{ url },
|
|
53
|
+
{
|
|
54
|
+
url: { type: 'string', required: true },
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const params = {
|
|
59
|
+
body: { url },
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = await this.sdk._fetch(
|
|
63
|
+
'/knowledgeBase/discover-url',
|
|
64
|
+
'POST',
|
|
65
|
+
params,
|
|
66
|
+
);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ingest a URL into a knowledge base
|
|
72
|
+
* Creates a kbSources record and triggers async crawl + processing
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} params
|
|
75
|
+
* @param {string} params.knowledgeBaseId - Target knowledge base
|
|
76
|
+
* @param {string} params.url - URL to crawl and ingest
|
|
77
|
+
* @param {string} [params.categoryId] - Category to assign
|
|
78
|
+
* @param {string} [params.title] - Display title (auto-detected from page if omitted)
|
|
79
|
+
* @param {string} [params.refreshInterval] - Recrawl interval: manual, daily, weekly, monthly
|
|
80
|
+
* @returns {Promise<Object>} Created kbSources record
|
|
81
|
+
*/
|
|
82
|
+
async ingestUrl({ knowledgeBaseId, url, categoryId, title, refreshInterval }) {
|
|
83
|
+
this.sdk.validateParams(
|
|
84
|
+
{ knowledgeBaseId, url },
|
|
85
|
+
{
|
|
86
|
+
knowledgeBaseId: { type: 'string', required: true },
|
|
87
|
+
url: { type: 'string', required: true },
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const params = {
|
|
92
|
+
body: { knowledgeBaseId, url, categoryId, title, refreshInterval },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const result = await this.sdk._fetch(
|
|
96
|
+
'/knowledgeBase/ingest/url',
|
|
97
|
+
'POST',
|
|
98
|
+
params,
|
|
99
|
+
);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Trigger (re)processing of a knowledge base source
|
|
105
|
+
* Sets processingStatus to pending and publishes NATS event
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} params
|
|
108
|
+
* @param {string} params.sourceType - Type: article, document, or source
|
|
109
|
+
* @param {string} params.id - Source record ID
|
|
110
|
+
* @returns {Promise<Object>} Updated source record
|
|
111
|
+
*/
|
|
112
|
+
async processSource({ sourceType, id }) {
|
|
113
|
+
this.sdk.validateParams(
|
|
114
|
+
{ sourceType, id },
|
|
115
|
+
{
|
|
116
|
+
sourceType: { type: 'string', required: true },
|
|
117
|
+
id: { type: 'string', required: true },
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const result = await this.sdk._fetch(
|
|
122
|
+
`/knowledgeBase/process/${sourceType}/${id}`,
|
|
123
|
+
'POST',
|
|
124
|
+
);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check the processing status of a source
|
|
130
|
+
*
|
|
131
|
+
* @param {Object} params
|
|
132
|
+
* @param {string} params.id - Source record ID
|
|
133
|
+
* @returns {Promise<Object>} Processing status { id, processingStatus, processingError }
|
|
134
|
+
*/
|
|
135
|
+
async checkProcessingStatus({ id }) {
|
|
136
|
+
this.sdk.validateParams(
|
|
137
|
+
{ id },
|
|
138
|
+
{
|
|
139
|
+
id: { type: 'string', required: true },
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const result = await this.sdk._fetch(
|
|
144
|
+
`/knowledgeBase/process/${id}/status`,
|
|
145
|
+
'GET',
|
|
146
|
+
);
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Publish a draft article
|
|
152
|
+
* Changes status to published, creates version snapshot, triggers processing
|
|
153
|
+
*
|
|
154
|
+
* @param {Object} params
|
|
155
|
+
* @param {string} params.id - Article ID
|
|
156
|
+
* @returns {Promise<Object>} Updated article record
|
|
157
|
+
*/
|
|
158
|
+
async publishArticle({ id }) {
|
|
159
|
+
this.sdk.validateParams(
|
|
160
|
+
{ id },
|
|
161
|
+
{
|
|
162
|
+
id: { type: 'string', required: true },
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const result = await this.sdk._fetch(
|
|
167
|
+
`/knowledgeBase/articles/${id}/publish`,
|
|
168
|
+
'POST',
|
|
169
|
+
);
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Get analytics for a knowledge base
|
|
175
|
+
*
|
|
176
|
+
* @param {Object} params
|
|
177
|
+
* @param {string} params.knowledgeBaseId - Knowledge base ID
|
|
178
|
+
* @param {Object} [params.filters] - Optional date range, source type filters
|
|
179
|
+
* @returns {Promise<Object>} Analytics data
|
|
180
|
+
*/
|
|
181
|
+
async getAnalytics({ knowledgeBaseId, ...filters }) {
|
|
182
|
+
this.sdk.validateParams(
|
|
183
|
+
{ knowledgeBaseId },
|
|
184
|
+
{
|
|
185
|
+
knowledgeBaseId: { type: 'string', required: true },
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const params = {
|
|
190
|
+
query: filters,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const result = await this.sdk._fetch(
|
|
194
|
+
`/knowledgeBase/${knowledgeBaseId}/analytics`,
|
|
195
|
+
'GET',
|
|
196
|
+
params,
|
|
197
|
+
);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get content gap analysis for a knowledge base
|
|
203
|
+
* Identifies failed/low-result searches that indicate missing content
|
|
204
|
+
*
|
|
205
|
+
* @param {Object} params
|
|
206
|
+
* @param {string} params.knowledgeBaseId - Knowledge base ID
|
|
207
|
+
* @param {Object} [params.filters] - Optional date range filters
|
|
208
|
+
* @returns {Promise<Object>} Gap analysis data
|
|
209
|
+
*/
|
|
210
|
+
async getGaps({ knowledgeBaseId, ...filters }) {
|
|
211
|
+
this.sdk.validateParams(
|
|
212
|
+
{ knowledgeBaseId },
|
|
213
|
+
{
|
|
214
|
+
knowledgeBaseId: { type: 'string', required: true },
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const params = {
|
|
219
|
+
query: filters,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const result = await this.sdk._fetch(
|
|
223
|
+
`/knowledgeBase/${knowledgeBaseId}/analytics/gaps`,
|
|
224
|
+
'GET',
|
|
225
|
+
params,
|
|
226
|
+
);
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -10,18 +10,26 @@ export class EmailTemplatesService {
|
|
|
10
10
|
* @param {string} params.subject - Template subject (required)
|
|
11
11
|
* @param {string} [params.html] - HTML template body
|
|
12
12
|
* @param {string} [params.text] - Plain text template body
|
|
13
|
-
* @
|
|
13
|
+
* @param {Array<Object>} [params.variables] - Variable metadata definitions
|
|
14
|
+
* @param {string} params.variables[].key - Variable key (unique, alphanumeric + underscores)
|
|
15
|
+
* @param {string} params.variables[].label - Human-readable display name
|
|
16
|
+
* @param {string} params.variables[].type - One of: text, textarea, url, image, richtext
|
|
17
|
+
* @param {string} [params.variables[].defaultValue] - Default value
|
|
18
|
+
* @param {boolean} [params.variables[].required] - Whether variable is required
|
|
19
|
+
* @returns {Promise<Object>} Created template details with merged variables
|
|
14
20
|
* @example
|
|
15
|
-
* // Create template with variables in the content
|
|
16
21
|
* const template = await sdk.messaging.email.templates.create({
|
|
17
22
|
* name: 'Welcome Email',
|
|
18
23
|
* subject: 'Welcome {{firstName}}!',
|
|
19
|
-
* html: '<h1>Hello {{firstName}}
|
|
20
|
-
* text: 'Hello {{firstName}}
|
|
24
|
+
* html: '<h1>Hello {{firstName}}</h1><p>{{body}}</p>',
|
|
25
|
+
* text: 'Hello {{firstName}}',
|
|
26
|
+
* variables: [
|
|
27
|
+
* { key: 'firstName', label: 'First Name', type: 'text', required: true },
|
|
28
|
+
* { key: 'body', label: 'Email Body', type: 'richtext' },
|
|
29
|
+
* ],
|
|
21
30
|
* });
|
|
22
|
-
* // Returns: { id, name, variables: ['firstName', 'lastName'] }
|
|
23
31
|
*/
|
|
24
|
-
async create({ name, subject, html, text }) {
|
|
32
|
+
async create({ name, subject, html, text, variables }) {
|
|
25
33
|
this.sdk.validateParams(
|
|
26
34
|
{ name, subject },
|
|
27
35
|
{
|
|
@@ -29,12 +37,14 @@ export class EmailTemplatesService {
|
|
|
29
37
|
subject: { type: 'string', required: true },
|
|
30
38
|
html: { type: 'string', required: false },
|
|
31
39
|
text: { type: 'string', required: false },
|
|
40
|
+
variables: { type: 'array', required: false },
|
|
32
41
|
},
|
|
33
42
|
);
|
|
34
43
|
|
|
35
44
|
const templateData = { name, subject };
|
|
36
45
|
if (html) templateData.html = html;
|
|
37
46
|
if (text) templateData.text = text;
|
|
47
|
+
if (variables) templateData.variables = variables;
|
|
38
48
|
|
|
39
49
|
const options = {
|
|
40
50
|
body: templateData,
|
|
@@ -56,15 +66,23 @@ export class EmailTemplatesService {
|
|
|
56
66
|
* @param {string} [params.subject] - Template subject
|
|
57
67
|
* @param {string} [params.html] - HTML template body
|
|
58
68
|
* @param {string} [params.text] - Plain text template body
|
|
59
|
-
* @
|
|
69
|
+
* @param {Array<Object>} [params.variables] - Variable metadata definitions
|
|
70
|
+
* @param {string} params.variables[].key - Variable key (unique, alphanumeric + underscores)
|
|
71
|
+
* @param {string} params.variables[].label - Human-readable display name
|
|
72
|
+
* @param {string} params.variables[].type - One of: text, textarea, url, image, richtext
|
|
73
|
+
* @param {string} [params.variables[].defaultValue] - Default value
|
|
74
|
+
* @param {boolean} [params.variables[].required] - Whether variable is required
|
|
75
|
+
* @returns {Promise<Object>} Updated template details with merged variables
|
|
60
76
|
* @example
|
|
61
|
-
* // Update template - variables are auto-extracted from content
|
|
62
77
|
* const updated = await sdk.messaging.email.templates.update('tpl_123', {
|
|
63
|
-
* subject: 'Hi {{firstName}}, welcome to {{companyName}}!'
|
|
78
|
+
* subject: 'Hi {{firstName}}, welcome to {{companyName}}!',
|
|
79
|
+
* variables: [
|
|
80
|
+
* { key: 'firstName', label: 'First Name', type: 'text', required: true },
|
|
81
|
+
* { key: 'companyName', label: 'Company Name', type: 'text' },
|
|
82
|
+
* ],
|
|
64
83
|
* });
|
|
65
|
-
* // Returns updated template with variables: ['firstName', 'companyName']
|
|
66
84
|
*/
|
|
67
|
-
async update(id, { name, subject, html, text }) {
|
|
85
|
+
async update(id, { name, subject, html, text, variables }) {
|
|
68
86
|
this.sdk.validateParams(
|
|
69
87
|
{ id },
|
|
70
88
|
{
|
|
@@ -73,6 +91,7 @@ export class EmailTemplatesService {
|
|
|
73
91
|
subject: { type: 'string', required: false },
|
|
74
92
|
html: { type: 'string', required: false },
|
|
75
93
|
text: { type: 'string', required: false },
|
|
94
|
+
variables: { type: 'array', required: false },
|
|
76
95
|
},
|
|
77
96
|
);
|
|
78
97
|
|
|
@@ -81,6 +100,7 @@ export class EmailTemplatesService {
|
|
|
81
100
|
if (subject) updateData.subject = subject;
|
|
82
101
|
if (html) updateData.html = html;
|
|
83
102
|
if (text) updateData.text = text;
|
|
103
|
+
if (variables) updateData.variables = variables;
|
|
84
104
|
|
|
85
105
|
const options = {
|
|
86
106
|
body: updateData,
|