@unboundcx/sdk 4.8.12 → 4.8.13
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/package.json +1 -1
- package/services/chat.js +241 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.13",
|
|
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",
|
package/services/chat.js
CHANGED
|
@@ -2,7 +2,8 @@ import { internalRequest } from '../base.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* ChatService — channels, DMs, membership, unreads, DND, messages, search,
|
|
4
4
|
* webhooks, card actions, reports, admin review, admin export, record feeds,
|
|
5
|
-
* channel meet, push devices, and
|
|
5
|
+
* channel meet, threads, bots, group default channels, push devices, and
|
|
6
|
+
* notifyLevel.
|
|
6
7
|
* Backed by /chat/* on app1-api (checkApiAuth). Incoming webhook POST
|
|
7
8
|
* (HMAC) is external and is not an SDK method.
|
|
8
9
|
*/
|
|
@@ -387,6 +388,8 @@ export class ChatService {
|
|
|
387
388
|
* @param {string} [params.threadRootId]
|
|
388
389
|
* @param {boolean} [params.alsoSendToChannel]
|
|
389
390
|
* @param {string[]} [params.storageIds]
|
|
391
|
+
* @param {string[]} [params.tools]
|
|
392
|
+
* @param {Object} [params.toolConfig]
|
|
390
393
|
* @returns {Promise<Object>} Created message
|
|
391
394
|
*/
|
|
392
395
|
async sendMessage(
|
|
@@ -398,6 +401,8 @@ export class ChatService {
|
|
|
398
401
|
storageIds,
|
|
399
402
|
suppressUnfurlUrls,
|
|
400
403
|
unfurls,
|
|
404
|
+
tools,
|
|
405
|
+
toolConfig,
|
|
401
406
|
} = {},
|
|
402
407
|
) {
|
|
403
408
|
this.sdk.validateParams(
|
|
@@ -409,6 +414,8 @@ export class ChatService {
|
|
|
409
414
|
storageIds,
|
|
410
415
|
suppressUnfurlUrls,
|
|
411
416
|
unfurls,
|
|
417
|
+
tools,
|
|
418
|
+
toolConfig,
|
|
412
419
|
},
|
|
413
420
|
{
|
|
414
421
|
channelId: { type: 'string', required: true },
|
|
@@ -418,6 +425,8 @@ export class ChatService {
|
|
|
418
425
|
storageIds: { type: 'array', required: false },
|
|
419
426
|
suppressUnfurlUrls: { type: 'array', required: false },
|
|
420
427
|
unfurls: { type: 'array', required: false },
|
|
428
|
+
tools: { type: 'array', required: false },
|
|
429
|
+
toolConfig: { type: 'object', required: false },
|
|
421
430
|
},
|
|
422
431
|
);
|
|
423
432
|
|
|
@@ -431,6 +440,8 @@ export class ChatService {
|
|
|
431
440
|
body.suppressUnfurlUrls = suppressUnfurlUrls;
|
|
432
441
|
}
|
|
433
442
|
if (unfurls !== undefined) body.unfurls = unfurls;
|
|
443
|
+
if (tools !== undefined) body.tools = tools;
|
|
444
|
+
if (toolConfig !== undefined) body.toolConfig = toolConfig;
|
|
434
445
|
|
|
435
446
|
return internalRequest(this.sdk, `/chat/channels/${channelId}/messages`, 'POST', {
|
|
436
447
|
body,
|
|
@@ -1034,6 +1045,235 @@ export class ChatService {
|
|
|
1034
1045
|
return internalRequest(this.sdk, '/chat/mentions', 'GET', { query });
|
|
1035
1046
|
}
|
|
1036
1047
|
|
|
1048
|
+
/**
|
|
1049
|
+
* List thread roots the caller participates in.
|
|
1050
|
+
* @param {Object} [params]
|
|
1051
|
+
* @param {'public'|'private'|'dm'|'group_dm'|'record'} [params.kind]
|
|
1052
|
+
* @param {number} [params.limit]
|
|
1053
|
+
* @returns {Promise<Object>}
|
|
1054
|
+
*/
|
|
1055
|
+
async listThreads({ kind, limit } = {}) {
|
|
1056
|
+
const query = {};
|
|
1057
|
+
if (kind) query.kind = kind;
|
|
1058
|
+
if (limit != null) query.limit = limit;
|
|
1059
|
+
return internalRequest(this.sdk, '/chat/threads', 'GET', { query });
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* List default channels for a group (auto-join on membership).
|
|
1064
|
+
* @param {string} groupId
|
|
1065
|
+
* @returns {Promise<Object>}
|
|
1066
|
+
*/
|
|
1067
|
+
async getGroupDefaultChannels(groupId) {
|
|
1068
|
+
this.sdk.validateParams(
|
|
1069
|
+
{ groupId },
|
|
1070
|
+
{ groupId: { type: 'string', required: true } },
|
|
1071
|
+
);
|
|
1072
|
+
return internalRequest(
|
|
1073
|
+
this.sdk,
|
|
1074
|
+
`/chat/groups/${groupId}/default-channels`,
|
|
1075
|
+
'GET',
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Replace default channels for a group.
|
|
1081
|
+
* @param {string} groupId
|
|
1082
|
+
* @param {Object} [params]
|
|
1083
|
+
* @param {string[]} [params.channelIds]
|
|
1084
|
+
* @returns {Promise<Object>}
|
|
1085
|
+
*/
|
|
1086
|
+
async setGroupDefaultChannels(groupId, { channelIds } = {}) {
|
|
1087
|
+
this.sdk.validateParams(
|
|
1088
|
+
{ groupId, channelIds },
|
|
1089
|
+
{
|
|
1090
|
+
groupId: { type: 'string', required: true },
|
|
1091
|
+
channelIds: { type: 'array', required: false },
|
|
1092
|
+
},
|
|
1093
|
+
);
|
|
1094
|
+
return internalRequest(
|
|
1095
|
+
this.sdk,
|
|
1096
|
+
`/chat/groups/${groupId}/default-channels`,
|
|
1097
|
+
'PUT',
|
|
1098
|
+
{ body: { channelIds } },
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Create a Meet/Call room for a channel.
|
|
1104
|
+
* @param {string} channelId
|
|
1105
|
+
* @returns {Promise<Object>}
|
|
1106
|
+
*/
|
|
1107
|
+
async createChannelMeet(channelId) {
|
|
1108
|
+
this.sdk.validateParams(
|
|
1109
|
+
{ channelId },
|
|
1110
|
+
{ channelId: { type: 'string', required: true } },
|
|
1111
|
+
);
|
|
1112
|
+
return internalRequest(
|
|
1113
|
+
this.sdk,
|
|
1114
|
+
`/chat/channels/${channelId}/meet`,
|
|
1115
|
+
'POST',
|
|
1116
|
+
{ body: {} },
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Update a channel Meet/Call room.
|
|
1122
|
+
* @param {string} channelId
|
|
1123
|
+
* @param {Object} [patch]
|
|
1124
|
+
* @param {string} [patch.slug]
|
|
1125
|
+
* @param {string} [patch.password]
|
|
1126
|
+
* @param {boolean} [patch.guestsCanStart]
|
|
1127
|
+
* @param {boolean} [patch.startRecordingOn]
|
|
1128
|
+
* @param {boolean} [patch.startTranscribingOn]
|
|
1129
|
+
* @param {number} [patch.endMeetingWithoutHostTimeLimit]
|
|
1130
|
+
* @returns {Promise<Object>}
|
|
1131
|
+
*/
|
|
1132
|
+
async updateChannelMeet(channelId, patch = {}) {
|
|
1133
|
+
this.sdk.validateParams(
|
|
1134
|
+
{ channelId },
|
|
1135
|
+
{ channelId: { type: 'string', required: true } },
|
|
1136
|
+
);
|
|
1137
|
+
const body = {};
|
|
1138
|
+
for (const key of [
|
|
1139
|
+
'slug',
|
|
1140
|
+
'password',
|
|
1141
|
+
'guestsCanStart',
|
|
1142
|
+
'startRecordingOn',
|
|
1143
|
+
'startTranscribingOn',
|
|
1144
|
+
'endMeetingWithoutHostTimeLimit',
|
|
1145
|
+
]) {
|
|
1146
|
+
if (patch[key] !== undefined) body[key] = patch[key];
|
|
1147
|
+
}
|
|
1148
|
+
return internalRequest(
|
|
1149
|
+
this.sdk,
|
|
1150
|
+
`/chat/channels/${channelId}/meet`,
|
|
1151
|
+
'PATCH',
|
|
1152
|
+
{ body },
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Check whether a Meet slug is available for a channel.
|
|
1158
|
+
* @param {string} channelId
|
|
1159
|
+
* @param {string} slug
|
|
1160
|
+
* @returns {Promise<Object>}
|
|
1161
|
+
*/
|
|
1162
|
+
async checkChannelMeetSlug(channelId, slug) {
|
|
1163
|
+
this.sdk.validateParams(
|
|
1164
|
+
{ channelId, slug },
|
|
1165
|
+
{
|
|
1166
|
+
channelId: { type: 'string', required: true },
|
|
1167
|
+
slug: { type: 'string', required: true },
|
|
1168
|
+
},
|
|
1169
|
+
);
|
|
1170
|
+
return internalRequest(
|
|
1171
|
+
this.sdk,
|
|
1172
|
+
`/chat/channels/${channelId}/meet/slug-available`,
|
|
1173
|
+
'GET',
|
|
1174
|
+
{ query: { slug } },
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Regenerate the Meet room password for a channel.
|
|
1180
|
+
* @param {string} channelId
|
|
1181
|
+
* @returns {Promise<Object>}
|
|
1182
|
+
*/
|
|
1183
|
+
async regenerateChannelMeetPassword(channelId) {
|
|
1184
|
+
this.sdk.validateParams(
|
|
1185
|
+
{ channelId },
|
|
1186
|
+
{ channelId: { type: 'string', required: true } },
|
|
1187
|
+
);
|
|
1188
|
+
return internalRequest(
|
|
1189
|
+
this.sdk,
|
|
1190
|
+
`/chat/channels/${channelId}/meet/regenerate-password`,
|
|
1191
|
+
'POST',
|
|
1192
|
+
{ body: {} },
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* List chat bots for the account.
|
|
1198
|
+
* @returns {Promise<Object>}
|
|
1199
|
+
*/
|
|
1200
|
+
async listBots() {
|
|
1201
|
+
return internalRequest(this.sdk, '/chat/bots', 'GET');
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Update a chat bot.
|
|
1206
|
+
* @param {string} id
|
|
1207
|
+
* @param {Object} [params]
|
|
1208
|
+
* @param {string} [params.name]
|
|
1209
|
+
* @returns {Promise<Object>}
|
|
1210
|
+
*/
|
|
1211
|
+
async updateBot(id, { name } = {}) {
|
|
1212
|
+
this.sdk.validateParams(
|
|
1213
|
+
{ id, name },
|
|
1214
|
+
{
|
|
1215
|
+
id: { type: 'string', required: true },
|
|
1216
|
+
name: { type: 'string', required: false },
|
|
1217
|
+
},
|
|
1218
|
+
);
|
|
1219
|
+
return internalRequest(this.sdk, `/chat/bots/${id}`, 'PATCH', {
|
|
1220
|
+
body: { name },
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Get bot memory for a channel.
|
|
1226
|
+
* @param {string} channelId
|
|
1227
|
+
* @returns {Promise<Object>}
|
|
1228
|
+
*/
|
|
1229
|
+
async getBotMemory(channelId) {
|
|
1230
|
+
this.sdk.validateParams(
|
|
1231
|
+
{ channelId },
|
|
1232
|
+
{ channelId: { type: 'string', required: true } },
|
|
1233
|
+
);
|
|
1234
|
+
return internalRequest(
|
|
1235
|
+
this.sdk,
|
|
1236
|
+
`/chat/channels/${channelId}/bot-memory`,
|
|
1237
|
+
'GET',
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* Reset bot memory for a channel.
|
|
1243
|
+
* @param {string} channelId
|
|
1244
|
+
* @returns {Promise<Object>}
|
|
1245
|
+
*/
|
|
1246
|
+
async resetBotMemory(channelId) {
|
|
1247
|
+
this.sdk.validateParams(
|
|
1248
|
+
{ channelId },
|
|
1249
|
+
{ channelId: { type: 'string', required: true } },
|
|
1250
|
+
);
|
|
1251
|
+
return internalRequest(
|
|
1252
|
+
this.sdk,
|
|
1253
|
+
`/chat/channels/${channelId}/bot-memory/reset`,
|
|
1254
|
+
'POST',
|
|
1255
|
+
{ body: {} },
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Compact bot memory for a channel.
|
|
1261
|
+
* @param {string} channelId
|
|
1262
|
+
* @returns {Promise<Object>}
|
|
1263
|
+
*/
|
|
1264
|
+
async compactBotMemory(channelId) {
|
|
1265
|
+
this.sdk.validateParams(
|
|
1266
|
+
{ channelId },
|
|
1267
|
+
{ channelId: { type: 'string', required: true } },
|
|
1268
|
+
);
|
|
1269
|
+
return internalRequest(
|
|
1270
|
+
this.sdk,
|
|
1271
|
+
`/chat/channels/${channelId}/bot-memory/compact`,
|
|
1272
|
+
'POST',
|
|
1273
|
+
{ body: {} },
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1037
1277
|
async listAdminChannels(query) {
|
|
1038
1278
|
return this.adminListChannels(query);
|
|
1039
1279
|
}
|