@unboundcx/sdk 4.13.37 → 4.13.39
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 +2 -0
- package/package.json +1 -1
- package/services/messaging/SmsService.js +22 -0
- package/services/phoneNumbers.js +14 -0
- package/services/taskRouter/TaskService.js +61 -0
- package/services/text.js +107 -0
package/index.js
CHANGED
|
@@ -43,6 +43,7 @@ import { SearchService } from './services/search.js';
|
|
|
43
43
|
import { DirectoryService } from './services/directory.js';
|
|
44
44
|
import { ChatService } from './services/chat.js';
|
|
45
45
|
import { DeveloperApisService } from './services/developerApis.js';
|
|
46
|
+
import { TextService } from './services/text.js';
|
|
46
47
|
import {
|
|
47
48
|
DataImportService,
|
|
48
49
|
DataExportService,
|
|
@@ -120,6 +121,7 @@ class UnboundSDK extends BaseSDK {
|
|
|
120
121
|
this.generateId = new GenerateIdService(this);
|
|
121
122
|
this.engagementMetrics = new EngagementMetricsService(this);
|
|
122
123
|
this.taskRouter = new TaskRouterService(this);
|
|
124
|
+
this.text = new TextService(this);
|
|
123
125
|
this.knowledgeBase = new KnowledgeBaseService(this);
|
|
124
126
|
this.fax = new FaxService(this);
|
|
125
127
|
this.documents = new DocumentsService(this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.39",
|
|
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",
|
|
@@ -108,4 +108,26 @@ export class SmsService {
|
|
|
108
108
|
);
|
|
109
109
|
return result;
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Re-send a failed message as a new row, linked back via retryOfId
|
|
114
|
+
* (sms-routing-plan.md §5.1, contract C2).
|
|
115
|
+
* @param {string} id - The failed message's id (required)
|
|
116
|
+
* @returns {Promise<Object>} The new message's { id, status }
|
|
117
|
+
*/
|
|
118
|
+
async retry(id) {
|
|
119
|
+
this.sdk.validateParams(
|
|
120
|
+
{ id },
|
|
121
|
+
{
|
|
122
|
+
id: { type: 'string', required: true },
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const result = await internalRequest(
|
|
127
|
+
this.sdk,
|
|
128
|
+
`/messaging/sms/${id}/retry`,
|
|
129
|
+
'POST',
|
|
130
|
+
);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
111
133
|
}
|
package/services/phoneNumbers.js
CHANGED
|
@@ -112,6 +112,9 @@ export class PhoneNumbersService {
|
|
|
112
112
|
voiceRecordTypeId,
|
|
113
113
|
messagingRecordTypeId,
|
|
114
114
|
recordCalls,
|
|
115
|
+
textApp,
|
|
116
|
+
textAppMetaData,
|
|
117
|
+
textChatVisibility,
|
|
115
118
|
},
|
|
116
119
|
) {
|
|
117
120
|
this.sdk.validateParams(
|
|
@@ -125,6 +128,9 @@ export class PhoneNumbersService {
|
|
|
125
128
|
voiceRecordTypeId,
|
|
126
129
|
messagingRecordTypeId,
|
|
127
130
|
recordCalls,
|
|
131
|
+
textApp,
|
|
132
|
+
textAppMetaData,
|
|
133
|
+
textChatVisibility,
|
|
128
134
|
},
|
|
129
135
|
{
|
|
130
136
|
id: { type: 'string', required: true },
|
|
@@ -137,6 +143,9 @@ export class PhoneNumbersService {
|
|
|
137
143
|
voiceRecordTypeId: { type: 'string', required: false },
|
|
138
144
|
messagingRecordTypeId: { type: 'string', required: false },
|
|
139
145
|
recordCalls: { type: 'boolean', required: false },
|
|
146
|
+
textApp: { type: 'string', required: false },
|
|
147
|
+
textAppMetaData: { type: 'string', required: false },
|
|
148
|
+
textChatVisibility: { type: 'string', required: false },
|
|
140
149
|
},
|
|
141
150
|
);
|
|
142
151
|
|
|
@@ -155,6 +164,11 @@ export class PhoneNumbersService {
|
|
|
155
164
|
if (messagingRecordTypeId)
|
|
156
165
|
updateData.messagingRecordTypeId = messagingRecordTypeId;
|
|
157
166
|
if (recordCalls !== undefined) updateData.recordCalls = recordCalls;
|
|
167
|
+
if (textApp !== undefined) updateData.textApp = textApp;
|
|
168
|
+
if (textAppMetaData !== undefined)
|
|
169
|
+
updateData.textAppMetaData = textAppMetaData;
|
|
170
|
+
if (textChatVisibility !== undefined)
|
|
171
|
+
updateData.textChatVisibility = textChatVisibility;
|
|
158
172
|
|
|
159
173
|
const params = {
|
|
160
174
|
body: updateData,
|
|
@@ -845,6 +845,67 @@ export class TaskService {
|
|
|
845
845
|
return result;
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
+
/**
|
|
849
|
+
* Park a task ("waiting for customer"). Clears the worker (freeing
|
|
850
|
+
* capacity) and stamps preferredWorkerId with the parking worker so
|
|
851
|
+
* unpark can offer the task back to them first.
|
|
852
|
+
*
|
|
853
|
+
* @param {Object} options - Parameters
|
|
854
|
+
* @param {string} options.taskId - The task ID to park (required)
|
|
855
|
+
* @returns {Promise<Object>} { taskId, status: 'parked' }
|
|
856
|
+
*/
|
|
857
|
+
async park(options = {}) {
|
|
858
|
+
const { taskId } = options;
|
|
859
|
+
|
|
860
|
+
this.sdk.validateParams(
|
|
861
|
+
{ taskId },
|
|
862
|
+
{ taskId: { type: 'string', required: true } },
|
|
863
|
+
);
|
|
864
|
+
|
|
865
|
+
const params = { body: { taskId } };
|
|
866
|
+
|
|
867
|
+
return await internalRequest(
|
|
868
|
+
this.sdk,
|
|
869
|
+
'/taskRouter/tasks/park',
|
|
870
|
+
'PUT',
|
|
871
|
+
params,
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Transfer a task to a different queue and/or worker. Passing queueId
|
|
877
|
+
* moves the task back to 'pending' status for re-distribution.
|
|
878
|
+
*
|
|
879
|
+
* @param {Object} options - Parameters
|
|
880
|
+
* @param {string} options.taskId - The task ID to transfer (required)
|
|
881
|
+
* @param {string} [options.queueId] - Destination queue ID
|
|
882
|
+
* @param {string} [options.workerId] - Destination worker ID
|
|
883
|
+
* @returns {Promise<Object>} { taskId }
|
|
884
|
+
*/
|
|
885
|
+
async transfer(options = {}) {
|
|
886
|
+
const { taskId, queueId, workerId } = options;
|
|
887
|
+
|
|
888
|
+
this.sdk.validateParams(
|
|
889
|
+
{ taskId, queueId, workerId },
|
|
890
|
+
{
|
|
891
|
+
taskId: { type: 'string', required: true },
|
|
892
|
+
queueId: { type: 'string', required: false },
|
|
893
|
+
workerId: { type: 'string', required: false },
|
|
894
|
+
},
|
|
895
|
+
);
|
|
896
|
+
|
|
897
|
+
const params = { body: { taskId } };
|
|
898
|
+
if (queueId !== undefined) params.body.queueId = queueId;
|
|
899
|
+
if (workerId !== undefined) params.body.workerId = workerId;
|
|
900
|
+
|
|
901
|
+
return await internalRequest(
|
|
902
|
+
this.sdk,
|
|
903
|
+
'/taskRouter/tasks/transfer',
|
|
904
|
+
'PUT',
|
|
905
|
+
params,
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
|
|
848
909
|
/**
|
|
849
910
|
* Get the voice transcript for a task, keyed by the media-manager
|
|
850
911
|
* bridgeId (not sipCallId) so it works across requeue/transfer.
|
package/services/text.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { internalRequest } from '../base.js';
|
|
2
|
+
|
|
3
|
+
// Text routing (sms-routing-plan.md §2/§3.2/§3.4): read-only lookups for the
|
|
4
|
+
// durable textConversations row. Mutations (send, park, transfer) go through
|
|
5
|
+
// sdk.messaging.sms / sdk.taskRouter.task — this service is for resolving
|
|
6
|
+
// "what conversation is this" from the client/CC UI.
|
|
7
|
+
export class TextConversationsService {
|
|
8
|
+
constructor(sdk) {
|
|
9
|
+
this.sdk = sdk;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get a single text conversation by id.
|
|
14
|
+
* @param {string} id - textConversations id (required)
|
|
15
|
+
* @returns {Promise<Object>}
|
|
16
|
+
*/
|
|
17
|
+
async get(id) {
|
|
18
|
+
this.sdk.validateParams(
|
|
19
|
+
{ id },
|
|
20
|
+
{ id: { type: 'string', required: true } },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return internalRequest(this.sdk, `/text/conversations/${id}`, 'GET');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the currently-open conversation for an (identity, counterparty)
|
|
28
|
+
* pair, if any.
|
|
29
|
+
* @param {Object} options - Parameters
|
|
30
|
+
* @param {string} options.phoneNumberId - our-side identity id (required)
|
|
31
|
+
* @param {string} options.counterparty - external address (required)
|
|
32
|
+
* @returns {Promise<Object|null>} the open conversation row, or null
|
|
33
|
+
*/
|
|
34
|
+
async resolve(options = {}) {
|
|
35
|
+
const { phoneNumberId, counterparty } = options;
|
|
36
|
+
|
|
37
|
+
this.sdk.validateParams(
|
|
38
|
+
{ phoneNumberId, counterparty },
|
|
39
|
+
{
|
|
40
|
+
phoneNumberId: { type: 'string', required: true },
|
|
41
|
+
counterparty: { type: 'string', required: true },
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return internalRequest(this.sdk, '/text/conversations/resolve', 'GET', {
|
|
46
|
+
query: { phoneNumberId, counterparty },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Join a UC-Chat-owned conversation's text channel (sms-routing-plan.md
|
|
52
|
+
* §3.3, contract C5) -- private channels aren't joinable via
|
|
53
|
+
* sdk.chat.channels.join (public-only); public-visibility text channels
|
|
54
|
+
* still require `messaging:sms:send`, which this route enforces.
|
|
55
|
+
* @param {string} id - textConversations id (required)
|
|
56
|
+
* @returns {Promise<Object>} { channel, membership }
|
|
57
|
+
*/
|
|
58
|
+
async join(id) {
|
|
59
|
+
this.sdk.validateParams(
|
|
60
|
+
{ id },
|
|
61
|
+
{ id: { type: 'string', required: true } },
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return internalRequest(this.sdk, `/text/conversations/${id}/join`, 'POST');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Escalate a UC-Chat-owned ('user') conversation to a queue or a
|
|
69
|
+
* workflow (sms-routing-plan.md §3.3/§3.4 "Send to queue" / "Send to
|
|
70
|
+
* workflow"). Pass exactly one of queueId or workflowId/workflowVersionId.
|
|
71
|
+
* @param {string} id - textConversations id (required)
|
|
72
|
+
* @param {Object} options - Parameters
|
|
73
|
+
* @param {string} [options.queueId] - Escalate to a queue (new task)
|
|
74
|
+
* @param {string} [options.workflowId] - Escalate to a workflow's current version
|
|
75
|
+
* @param {string} [options.workflowVersionId] - Escalate to a pinned workflow version
|
|
76
|
+
* @returns {Promise<Object>} The updated conversation row
|
|
77
|
+
*/
|
|
78
|
+
async escalate(id, options = {}) {
|
|
79
|
+
const { queueId, workflowId, workflowVersionId } = options;
|
|
80
|
+
|
|
81
|
+
this.sdk.validateParams(
|
|
82
|
+
{ id, queueId, workflowId, workflowVersionId },
|
|
83
|
+
{
|
|
84
|
+
id: { type: 'string', required: true },
|
|
85
|
+
queueId: { type: 'string', required: false },
|
|
86
|
+
workflowId: { type: 'string', required: false },
|
|
87
|
+
workflowVersionId: { type: 'string', required: false },
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
if (!queueId && !workflowId && !workflowVersionId) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
'escalate requires queueId or workflowId/workflowVersionId',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return internalRequest(this.sdk, `/text/conversations/${id}/escalate`, 'POST', {
|
|
97
|
+
body: { queueId, workflowId, workflowVersionId },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export class TextService {
|
|
103
|
+
constructor(sdk) {
|
|
104
|
+
this.sdk = sdk;
|
|
105
|
+
this.conversations = new TextConversationsService(sdk);
|
|
106
|
+
}
|
|
107
|
+
}
|