@unboundcx/sdk 4.13.24 → 4.13.26
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 +7 -0
- package/package.json +1 -1
- package/services/webchat.js +247 -0
package/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { ContentService } from './services/content.js';
|
|
|
20
20
|
import { VerificationService } from './services/verification.js';
|
|
21
21
|
import { PortalsService } from './services/portals.js';
|
|
22
22
|
import { SipEndpointsService } from './services/sipEndpoints.js';
|
|
23
|
+
import { WebchatService } from './services/webchat.js';
|
|
23
24
|
import { ExternalOAuthService } from './services/externalOAuth.js';
|
|
24
25
|
import { GoogleCalendarService } from './services/googleCalendar.js';
|
|
25
26
|
import { DriveService } from './services/drive.js';
|
|
@@ -105,6 +106,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
105
106
|
this.verification = new VerificationService(this);
|
|
106
107
|
this.portals = new PortalsService(this);
|
|
107
108
|
this.sipEndpoints = new SipEndpointsService(this);
|
|
109
|
+
this.webchat = new WebchatService(this);
|
|
108
110
|
this.externalOAuth = new ExternalOAuthService(this);
|
|
109
111
|
this.googleCalendar = new GoogleCalendarService(this);
|
|
110
112
|
this.drive = new DriveService(this);
|
|
@@ -297,6 +299,11 @@ export {
|
|
|
297
299
|
export { VerificationService } from './services/verification.js';
|
|
298
300
|
export { PortalsService } from './services/portals.js';
|
|
299
301
|
export { SipEndpointsService } from './services/sipEndpoints.js';
|
|
302
|
+
export {
|
|
303
|
+
WebchatService,
|
|
304
|
+
WebchatWidgetsService,
|
|
305
|
+
WebchatWidgetKeysService,
|
|
306
|
+
} from './services/webchat.js';
|
|
300
307
|
export { ExternalOAuthService } from './services/externalOAuth.js';
|
|
301
308
|
export { GoogleCalendarService } from './services/googleCalendar.js';
|
|
302
309
|
export { DriveService } from './services/drive.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.26",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { internalRequest } from '../base.js';
|
|
2
|
+
|
|
3
|
+
// WebChat P0: agent-facing widget CRUD. Endpoints live under
|
|
4
|
+
// /webchat/widgets/ (checkApiAuth) -- deliberately not bare /webchat/, which
|
|
5
|
+
// is reserved for the future unauthenticated visitor surface (plan §5).
|
|
6
|
+
export class WebchatWidgetKeysService {
|
|
7
|
+
constructor(sdk) {
|
|
8
|
+
this.sdk = sdk;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* List signing keys for a widget.
|
|
13
|
+
* @param {string} widgetId
|
|
14
|
+
* @returns {Promise<Array<Object>>}
|
|
15
|
+
*/
|
|
16
|
+
async list(widgetId) {
|
|
17
|
+
this.sdk.validateParams(
|
|
18
|
+
{ widgetId },
|
|
19
|
+
{ widgetId: { type: 'string', required: true } },
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return internalRequest(
|
|
23
|
+
this.sdk,
|
|
24
|
+
`/webchat/widgets/${widgetId}/keys`,
|
|
25
|
+
'GET',
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create a signing key for a widget. The token is server-generated and
|
|
31
|
+
* returned once in this response only.
|
|
32
|
+
* @param {string} widgetId
|
|
33
|
+
* @param {Object} [options]
|
|
34
|
+
* @param {string[]} [options.urls] - allowlisted origins/domains for this key
|
|
35
|
+
* @returns {Promise<Object>}
|
|
36
|
+
*/
|
|
37
|
+
async create(widgetId, options = {}) {
|
|
38
|
+
this.sdk.validateParams(
|
|
39
|
+
{ widgetId },
|
|
40
|
+
{ widgetId: { type: 'string', required: true } },
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const params = { body: { ...options } };
|
|
44
|
+
|
|
45
|
+
return internalRequest(
|
|
46
|
+
this.sdk,
|
|
47
|
+
`/webchat/widgets/${widgetId}/keys`,
|
|
48
|
+
'POST',
|
|
49
|
+
params,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete (soft) a widget signing key.
|
|
55
|
+
* @param {string} widgetId
|
|
56
|
+
* @param {string} keyId
|
|
57
|
+
* @returns {Promise<Object>}
|
|
58
|
+
*/
|
|
59
|
+
async delete(widgetId, keyId) {
|
|
60
|
+
this.sdk.validateParams(
|
|
61
|
+
{ widgetId, keyId },
|
|
62
|
+
{
|
|
63
|
+
widgetId: { type: 'string', required: true },
|
|
64
|
+
keyId: { type: 'string', required: true },
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return internalRequest(
|
|
69
|
+
this.sdk,
|
|
70
|
+
`/webchat/widgets/${widgetId}/keys/${keyId}`,
|
|
71
|
+
'DELETE',
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class WebchatWidgetsService {
|
|
77
|
+
constructor(sdk) {
|
|
78
|
+
this.sdk = sdk;
|
|
79
|
+
this.keys = new WebchatWidgetKeysService(sdk);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* List WebChat widgets for the authenticated account.
|
|
84
|
+
* @returns {Promise<Array<Object>>}
|
|
85
|
+
*/
|
|
86
|
+
async list() {
|
|
87
|
+
return internalRequest(this.sdk, '/webchat/widgets', 'GET');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get a single WebChat widget by id.
|
|
92
|
+
* @param {string} widgetId
|
|
93
|
+
* @returns {Promise<Object>}
|
|
94
|
+
*/
|
|
95
|
+
async get(widgetId) {
|
|
96
|
+
this.sdk.validateParams(
|
|
97
|
+
{ widgetId },
|
|
98
|
+
{ widgetId: { type: 'string', required: true } },
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return internalRequest(this.sdk, `/webchat/widgets/${widgetId}`, 'GET');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a WebChat widget. identitySecret is always server-generated and
|
|
106
|
+
* returned once (plaintext) in this response only -- never on list/get.
|
|
107
|
+
* @param {Object} options
|
|
108
|
+
* @param {string} options.name
|
|
109
|
+
* @param {'draft'|'active'|'paused'} [options.status]
|
|
110
|
+
* @param {'workflow'|'queue'} [options.routeType]
|
|
111
|
+
* @param {'full'|'first'|'firstLastInitial'} [options.agentNameDisplay]
|
|
112
|
+
* @returns {Promise<Object>}
|
|
113
|
+
*/
|
|
114
|
+
async create(options) {
|
|
115
|
+
this.sdk.validateParams(
|
|
116
|
+
{ name: options?.name },
|
|
117
|
+
{ name: { type: 'string', required: true } },
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const params = { body: { ...options } };
|
|
121
|
+
|
|
122
|
+
return internalRequest(this.sdk, '/webchat/widgets', 'POST', params);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Update a WebChat widget. Pass regenerateIdentitySecret:true to rotate
|
|
127
|
+
* the identity secret (returned once, plaintext, in this response).
|
|
128
|
+
* @param {string} widgetId
|
|
129
|
+
* @param {Object} options
|
|
130
|
+
* @returns {Promise<Object>}
|
|
131
|
+
*/
|
|
132
|
+
async update(widgetId, options) {
|
|
133
|
+
this.sdk.validateParams(
|
|
134
|
+
{ widgetId },
|
|
135
|
+
{ widgetId: { type: 'string', required: true } },
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const params = { body: { ...options } };
|
|
139
|
+
|
|
140
|
+
return internalRequest(
|
|
141
|
+
this.sdk,
|
|
142
|
+
`/webchat/widgets/${widgetId}`,
|
|
143
|
+
'PUT',
|
|
144
|
+
params,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Delete (soft) a WebChat widget.
|
|
150
|
+
* @param {string} widgetId
|
|
151
|
+
* @returns {Promise<Object>}
|
|
152
|
+
*/
|
|
153
|
+
async delete(widgetId) {
|
|
154
|
+
this.sdk.validateParams(
|
|
155
|
+
{ widgetId },
|
|
156
|
+
{ widgetId: { type: 'string', required: true } },
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return internalRequest(
|
|
160
|
+
this.sdk,
|
|
161
|
+
`/webchat/widgets/${widgetId}`,
|
|
162
|
+
'DELETE',
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export class WebchatConversationMessagesService {
|
|
168
|
+
constructor(sdk) {
|
|
169
|
+
this.sdk = sdk;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* List messages for a webchat conversation (agent view).
|
|
174
|
+
* @param {string} widgetId
|
|
175
|
+
* @param {string} engagementSessionId
|
|
176
|
+
* @param {Object} [options]
|
|
177
|
+
* @param {string} [options.before] - cursor: return messages created before this
|
|
178
|
+
* @param {number} [options.limit]
|
|
179
|
+
* @returns {Promise<Array<Object>>}
|
|
180
|
+
*/
|
|
181
|
+
async list(widgetId, engagementSessionId, options = {}) {
|
|
182
|
+
this.sdk.validateParams(
|
|
183
|
+
{ widgetId, engagementSessionId },
|
|
184
|
+
{
|
|
185
|
+
widgetId: { type: 'string', required: true },
|
|
186
|
+
engagementSessionId: { type: 'string', required: true },
|
|
187
|
+
},
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const { before, limit } = options;
|
|
191
|
+
|
|
192
|
+
return internalRequest(
|
|
193
|
+
this.sdk,
|
|
194
|
+
`/webchat/widgets/${widgetId}/conversations/${engagementSessionId}/messages`,
|
|
195
|
+
'GET',
|
|
196
|
+
{ query: { before, limit } },
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Send a message into a webchat conversation as an agent.
|
|
202
|
+
* @param {string} widgetId
|
|
203
|
+
* @param {string} engagementSessionId
|
|
204
|
+
* @param {Object} options
|
|
205
|
+
* @param {string} options.message
|
|
206
|
+
* @param {Object} [options.media]
|
|
207
|
+
* @returns {Promise<Object>}
|
|
208
|
+
*/
|
|
209
|
+
async send(widgetId, engagementSessionId, options) {
|
|
210
|
+
this.sdk.validateParams(
|
|
211
|
+
{
|
|
212
|
+
widgetId,
|
|
213
|
+
engagementSessionId,
|
|
214
|
+
message: options?.message,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
widgetId: { type: 'string', required: true },
|
|
218
|
+
engagementSessionId: { type: 'string', required: true },
|
|
219
|
+
message: { type: 'string', required: true },
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const params = { body: { ...options } };
|
|
224
|
+
|
|
225
|
+
return internalRequest(
|
|
226
|
+
this.sdk,
|
|
227
|
+
`/webchat/widgets/${widgetId}/conversations/${engagementSessionId}/messages`,
|
|
228
|
+
'POST',
|
|
229
|
+
params,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export class WebchatConversationsService {
|
|
235
|
+
constructor(sdk) {
|
|
236
|
+
this.sdk = sdk;
|
|
237
|
+
this.messages = new WebchatConversationMessagesService(sdk);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export class WebchatService {
|
|
242
|
+
constructor(sdk) {
|
|
243
|
+
this.sdk = sdk;
|
|
244
|
+
this.widgets = new WebchatWidgetsService(sdk);
|
|
245
|
+
this.conversations = new WebchatConversationsService(sdk);
|
|
246
|
+
}
|
|
247
|
+
}
|