@signalhouse-sms/sdk 1.5.1 → 1.7.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 +1 -1
- package/package.json +1 -1
- package/src/SignalHouseSDK.js +1 -0
- package/src/domains/Agents.js +81 -1
- package/src/domains/Auth.js +427 -8
- package/src/domains/Brands.js +115 -61
- package/src/domains/Campaigns.js +7 -0
- package/src/domains/Groups.js +99 -1
- package/src/domains/Messages.js +5 -5
- package/src/domains/Numbers.js +4 -1
- package/src/domains/Voice.js +2 -0
- package/src/domains/voice/OutboundVoice.js +150 -0
- package/types/domains/Agents.d.ts +123 -2
- package/types/domains/Auth.d.ts +411 -7
- package/types/domains/Brands.d.ts +175 -90
- package/types/domains/Campaigns.d.ts +7 -0
- package/types/domains/Groups.d.ts +97 -1
- package/types/domains/Messages.d.ts +5 -5
- package/types/domains/Numbers.d.ts +4 -1
- package/types/domains/Voice.d.ts +2 -0
- package/types/domains/voice/OutboundVoice.d.ts +128 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/** @typedef {import('../../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {"GROUP"|"SUBGROUP"|"NUMBER"|"TRUNK"|"SIP_PROFILE"|"WEBRTC_IDENTITY"} OutboundScopeType
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const BASE_PATH = "/voice/api/v1/outbound-voice";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Outbound voice policy: Signal House staff switches that turn outbound calling off for a group,
|
|
15
|
+
* subgroup, number, SIP trunk, SIP endpoint or softphone user, plus a group's AI-outbound
|
|
16
|
+
* authorization. Staff only; every method lives under the hidden `admin` namespace.
|
|
17
|
+
* Accessed via `sdk.voice.outboundVoice.admin`.
|
|
18
|
+
*/
|
|
19
|
+
export class OutboundVoice {
|
|
20
|
+
constructor(client, enableAdmin) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.enableAdmin = enableAdmin;
|
|
23
|
+
|
|
24
|
+
// Hidden Admin namespace INSIDE the domain
|
|
25
|
+
if (enableAdmin) {
|
|
26
|
+
this.admin = {
|
|
27
|
+
/**
|
|
28
|
+
* Get the switches that are off in a group, and its AI-outbound authorization.
|
|
29
|
+
* @async
|
|
30
|
+
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
31
|
+
* @param {Object} params - Request parameters.
|
|
32
|
+
* @param {string} params.groupId - The group to read.
|
|
33
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
34
|
+
* @throws {Error} If groupId is missing.
|
|
35
|
+
* @returns {Promise<SdkResponse<any>>} `{ groupId, outboundAiAuthorized, aiAuthorization, blocks: [...] }`.
|
|
36
|
+
*/
|
|
37
|
+
getGroupPolicy: async ({ groupId, options = {} }) => {
|
|
38
|
+
this.client._require({ groupId });
|
|
39
|
+
return this.client(`${BASE_PATH}/groups/${encodeURIComponent(groupId)}`, { method: "GET", ...options });
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* List a group's outbound policy changes, newest first.
|
|
44
|
+
* @async
|
|
45
|
+
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
46
|
+
* @param {Object} params - Request parameters.
|
|
47
|
+
* @param {string} params.groupId - The group to read.
|
|
48
|
+
* @param {number} [params.limit] - Most rows to return (1-200, default 50).
|
|
49
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
50
|
+
* @throws {Error} If groupId is missing.
|
|
51
|
+
* @returns {Promise<SdkResponse<any>>} `{ groupId, events: [...] }`.
|
|
52
|
+
*/
|
|
53
|
+
listHistory: async ({ groupId, limit, options = {} }) => {
|
|
54
|
+
this.client._require({ groupId });
|
|
55
|
+
const queryString = this.client._getQueryString({ limit });
|
|
56
|
+
return this.client(`${BASE_PATH}/groups/${encodeURIComponent(groupId)}/history${queryString}`, { method: "GET", ...options });
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Check whether a call with this context may go out, and which switch blocks it if not.
|
|
61
|
+
* @async
|
|
62
|
+
* @roles signalhouse_admin, signalhouse_api, signalhouse_user
|
|
63
|
+
* @param {Object} params - Request parameters.
|
|
64
|
+
* @param {string} params.groupId - The calling group.
|
|
65
|
+
* @param {string} [params.subgroupId] - The calling subgroup, when known.
|
|
66
|
+
* @param {string} [params.e164] - The caller ID, in E.164.
|
|
67
|
+
* @param {string} [params.sipTrunkId] - The SIP trunk the call comes from.
|
|
68
|
+
* @param {string} [params.sipProfileId] - The SIP endpoint the call comes from.
|
|
69
|
+
* @param {string} [params.webrtcIdentity] - The softphone user's requested identity.
|
|
70
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
71
|
+
* @throws {Error} If groupId is missing.
|
|
72
|
+
* @returns {Promise<SdkResponse<any>>} `{ allowed, blockedBy }`.
|
|
73
|
+
*/
|
|
74
|
+
resolve: async ({ groupId, subgroupId, e164, sipTrunkId, sipProfileId, webrtcIdentity, options = {} }) => {
|
|
75
|
+
this.client._require({ groupId });
|
|
76
|
+
return this.client(`${BASE_PATH}/resolve`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
body: { groupId, subgroupId, e164, sipTrunkId, sipProfileId, webrtcIdentity },
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Turn outbound calling off for one scope. A scope that is already off keeps its original switch.
|
|
85
|
+
* @async
|
|
86
|
+
* @roles signalhouse_admin, signalhouse_api
|
|
87
|
+
* @param {Object} params - Request parameters.
|
|
88
|
+
* @param {string} params.groupId - The group that owns the scope.
|
|
89
|
+
* @param {OutboundScopeType} params.scopeType - What kind of thing is being turned off.
|
|
90
|
+
* @param {string} params.scopeId - The group, subgroup, number, trunk, endpoint or softphone identity.
|
|
91
|
+
* @param {string} params.reason - Why (3-500 characters).
|
|
92
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
93
|
+
* @throws {Error} If groupId, scopeType, scopeId or reason is missing.
|
|
94
|
+
* @returns {Promise<SdkResponse<any>>} `{ created, block }`.
|
|
95
|
+
*/
|
|
96
|
+
block: async ({ groupId, scopeType, scopeId, reason, options = {} }) => {
|
|
97
|
+
this.client._require({ groupId, scopeType, scopeId, reason });
|
|
98
|
+
return this.client(`${BASE_PATH}/groups/${encodeURIComponent(groupId)}/blocks/${encodeURIComponent(scopeType)}/${encodeURIComponent(scopeId)}`, {
|
|
99
|
+
method: "PUT",
|
|
100
|
+
body: { reason },
|
|
101
|
+
...options,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Turn outbound calling back on for one scope.
|
|
107
|
+
* @async
|
|
108
|
+
* @roles signalhouse_admin, signalhouse_api
|
|
109
|
+
* @param {Object} params - Request parameters.
|
|
110
|
+
* @param {string} params.groupId - The group that owns the scope.
|
|
111
|
+
* @param {OutboundScopeType} params.scopeType - What kind of thing is being turned on.
|
|
112
|
+
* @param {string} params.scopeId - The switch's scope id.
|
|
113
|
+
* @param {string} [params.reason] - Optional note for the history.
|
|
114
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
115
|
+
* @throws {Error} If groupId, scopeType or scopeId is missing.
|
|
116
|
+
* @returns {Promise<SdkResponse<any>>} `{ removed, block }`.
|
|
117
|
+
*/
|
|
118
|
+
unblock: async ({ groupId, scopeType, scopeId, reason, options = {} }) => {
|
|
119
|
+
this.client._require({ groupId, scopeType, scopeId });
|
|
120
|
+
return this.client(`${BASE_PATH}/groups/${encodeURIComponent(groupId)}/blocks/${encodeURIComponent(scopeType)}/${encodeURIComponent(scopeId)}`, {
|
|
121
|
+
method: "DELETE",
|
|
122
|
+
...(reason ? { body: { reason } } : {}),
|
|
123
|
+
...options,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Set or clear a group's authorization to place outbound AI-agent calls.
|
|
129
|
+
* @async
|
|
130
|
+
* @roles signalhouse_admin, signalhouse_api
|
|
131
|
+
* @param {Object} params - Request parameters.
|
|
132
|
+
* @param {string} params.groupId - The group to change.
|
|
133
|
+
* @param {boolean} params.authorized - The new value.
|
|
134
|
+
* @param {string} params.reason - Why (3-500 characters).
|
|
135
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
136
|
+
* @throws {Error} If groupId, authorized or reason is missing.
|
|
137
|
+
* @returns {Promise<SdkResponse<any>>} `{ groupId, outboundAiAuthorized, changed }`.
|
|
138
|
+
*/
|
|
139
|
+
setAiAuthorization: async ({ groupId, authorized, reason, options = {} }) => {
|
|
140
|
+
this.client._require({ groupId, authorized, reason });
|
|
141
|
+
return this.client(`${BASE_PATH}/groups/${encodeURIComponent(groupId)}/ai-authorization`, {
|
|
142
|
+
method: "PUT",
|
|
143
|
+
body: { authorized, reason },
|
|
144
|
+
...options,
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -83,6 +83,21 @@
|
|
|
83
83
|
* @property {string} createdAt - Creation timestamp.
|
|
84
84
|
* @property {string} updatedAt - Last-update timestamp.
|
|
85
85
|
*/
|
|
86
|
+
/**
|
|
87
|
+
* A paused agent conversation: a person took over the conversation between an agent's number and
|
|
88
|
+
* one contact, so the agent does not answer that contact on that number until someone resumes it. As returned
|
|
89
|
+
* by the server.
|
|
90
|
+
* @typedef {Object} AgentContactPause
|
|
91
|
+
* @property {string} groupId - The group that owns the agent's number.
|
|
92
|
+
* @property {string|null} subgroupId - The number's subgroup.
|
|
93
|
+
* @property {string} channel - The channel; "sms".
|
|
94
|
+
* @property {string} endpointValue - The agent's number: digits only, country code included, no "+".
|
|
95
|
+
* @property {string} contactIdentifier - The contact's number: digits only, country code included, no "+".
|
|
96
|
+
* @property {string} reason - Why it was paused: "human_reply" (a person replied by hand), "escalation" (the agent asked for a person) or "manual".
|
|
97
|
+
* @property {string|null} pausedBy - The user who paused it, when known.
|
|
98
|
+
* @property {string} createdAt - When the conversation was paused.
|
|
99
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
100
|
+
*/
|
|
86
101
|
/**
|
|
87
102
|
* A reply an SMS agent wrote but did not send, held for a person to approve or reject (the
|
|
88
103
|
* Pending Replies queue), as returned by the server.
|
|
@@ -98,7 +113,7 @@
|
|
|
98
113
|
* @property {string} inboundText - The contact message the agent was answering.
|
|
99
114
|
* @property {string} draftText - The reply as the agent wrote it.
|
|
100
115
|
* @property {string|null} sentText - The text actually sent; differs from draftText when edited.
|
|
101
|
-
* @property {string} reason - Why it was held: "review_mode", "escalation", "fallback" or "guardrail".
|
|
116
|
+
* @property {string} reason - Why it was held: "review_mode", "escalation", "fallback" or "guardrail", or "autopilot" for a confident auto-pilot reply that its channel delivers without a person.
|
|
102
117
|
* @property {string} status - "pending", "sending", "sent", "rejected" or "failed" (the send path accepted nothing, e.g. the contact opted out).
|
|
103
118
|
* @property {string|null} decidedBy - The user who approved or rejected it.
|
|
104
119
|
* @property {string|null} decidedAt - When it was approved or rejected.
|
|
@@ -546,6 +561,69 @@ export class Agents {
|
|
|
546
561
|
endpointValue: string;
|
|
547
562
|
options?: RequestOptions;
|
|
548
563
|
}): Promise<SdkResponse<AgentEndpoint>>;
|
|
564
|
+
/**
|
|
565
|
+
* List paused agent conversations in a group, newest first. A paused conversation is one a person took
|
|
566
|
+
* over; the agent stays out of it until it is resumed.
|
|
567
|
+
* @async
|
|
568
|
+
* @roles api, admin, developer, billing, user
|
|
569
|
+
* @param {Object} params - The parameters for listing paused conversations.
|
|
570
|
+
* @param {string} params.groupId - The group whose paused conversations to list (required).
|
|
571
|
+
* @param {string} [params.subgroupId] - Narrow to one subgroup.
|
|
572
|
+
* @param {string} [params.channel] - Narrow to one channel ("sms").
|
|
573
|
+
* @param {string} [params.endpointValue] - Narrow to one agent number (digits only, no "+").
|
|
574
|
+
* @param {string} [params.contactIdentifier] - Narrow to one contact number (digits only, no "+").
|
|
575
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
576
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
577
|
+
* @returns {Promise<SdkResponse<AgentContactPause[]>>} - The paused conversations returned from the server.
|
|
578
|
+
*/
|
|
579
|
+
getAgentContactPauses({ groupId, subgroupId, channel, endpointValue, contactIdentifier, options }: {
|
|
580
|
+
groupId: string;
|
|
581
|
+
subgroupId?: string;
|
|
582
|
+
channel?: string;
|
|
583
|
+
endpointValue?: string;
|
|
584
|
+
contactIdentifier?: string;
|
|
585
|
+
options?: RequestOptions;
|
|
586
|
+
}): Promise<SdkResponse<AgentContactPause[]>>;
|
|
587
|
+
/**
|
|
588
|
+
* Pause an agent on one conversation (its number + one contact). The agent stops answering that contact
|
|
589
|
+
* on that number until the conversation is resumed; there is no timer. The conversation's pending
|
|
590
|
+
* replies are rejected. Pausing a paused conversation keeps the original pause.
|
|
591
|
+
* @async
|
|
592
|
+
* @roles api, admin, developer, billing, user
|
|
593
|
+
* @param {Object} params - The parameters for the pause.
|
|
594
|
+
* @param {string} params.channel - The channel; must be "sms".
|
|
595
|
+
* @param {string} params.endpointValue - The agent's number: 10 to 15 digits, country code included, no "+".
|
|
596
|
+
* @param {string} params.contactIdentifier - The contact's number: 10 to 15 digits, country code included, no "+".
|
|
597
|
+
* @param {Object} [params.pauseData] - `{ reason? }`: "human_reply" or "manual" (the default).
|
|
598
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
599
|
+
* @throws {Error} Throws an error if channel, endpointValue, or contactIdentifier is missing.
|
|
600
|
+
* @returns {Promise<SdkResponse<AgentContactPause>>} - The pause returned from the server.
|
|
601
|
+
*/
|
|
602
|
+
pauseAgentConversation({ channel, endpointValue, contactIdentifier, pauseData, options }: {
|
|
603
|
+
channel: string;
|
|
604
|
+
endpointValue: string;
|
|
605
|
+
contactIdentifier: string;
|
|
606
|
+
pauseData?: any;
|
|
607
|
+
options?: RequestOptions;
|
|
608
|
+
}): Promise<SdkResponse<AgentContactPause>>;
|
|
609
|
+
/**
|
|
610
|
+
* Resume an agent on a paused conversation, so it answers the contact's next text again.
|
|
611
|
+
* @async
|
|
612
|
+
* @roles api, admin, developer, billing, user
|
|
613
|
+
* @param {Object} params - The parameters for the resume.
|
|
614
|
+
* @param {string} params.channel - The channel; must be "sms".
|
|
615
|
+
* @param {string} params.endpointValue - The agent's number: 10 to 15 digits, country code included, no "+".
|
|
616
|
+
* @param {string} params.contactIdentifier - The contact's number: 10 to 15 digits, country code included, no "+".
|
|
617
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
618
|
+
* @throws {Error} Throws an error if channel, endpointValue, or contactIdentifier is missing.
|
|
619
|
+
* @returns {Promise<SdkResponse<AgentContactPause>>} - The removed pause returned from the server.
|
|
620
|
+
*/
|
|
621
|
+
resumeAgentConversation({ channel, endpointValue, contactIdentifier, options }: {
|
|
622
|
+
channel: string;
|
|
623
|
+
endpointValue: string;
|
|
624
|
+
contactIdentifier: string;
|
|
625
|
+
options?: RequestOptions;
|
|
626
|
+
}): Promise<SdkResponse<AgentContactPause>>;
|
|
549
627
|
/**
|
|
550
628
|
* List held agent replies (the Pending Replies queue) in a group, newest first.
|
|
551
629
|
* @async
|
|
@@ -1172,6 +1250,49 @@ export type AgentEndpoint = {
|
|
|
1172
1250
|
*/
|
|
1173
1251
|
updatedAt: string;
|
|
1174
1252
|
};
|
|
1253
|
+
/**
|
|
1254
|
+
* A paused agent conversation: a person took over the conversation between an agent's number and
|
|
1255
|
+
* one contact, so the agent does not answer that contact on that number until someone resumes it. As returned
|
|
1256
|
+
* by the server.
|
|
1257
|
+
*/
|
|
1258
|
+
export type AgentContactPause = {
|
|
1259
|
+
/**
|
|
1260
|
+
* - The group that owns the agent's number.
|
|
1261
|
+
*/
|
|
1262
|
+
groupId: string;
|
|
1263
|
+
/**
|
|
1264
|
+
* - The number's subgroup.
|
|
1265
|
+
*/
|
|
1266
|
+
subgroupId: string | null;
|
|
1267
|
+
/**
|
|
1268
|
+
* - The channel; "sms".
|
|
1269
|
+
*/
|
|
1270
|
+
channel: string;
|
|
1271
|
+
/**
|
|
1272
|
+
* - The agent's number: digits only, country code included, no "+".
|
|
1273
|
+
*/
|
|
1274
|
+
endpointValue: string;
|
|
1275
|
+
/**
|
|
1276
|
+
* - The contact's number: digits only, country code included, no "+".
|
|
1277
|
+
*/
|
|
1278
|
+
contactIdentifier: string;
|
|
1279
|
+
/**
|
|
1280
|
+
* - Why it was paused: "human_reply" (a person replied by hand), "escalation" (the agent asked for a person) or "manual".
|
|
1281
|
+
*/
|
|
1282
|
+
reason: string;
|
|
1283
|
+
/**
|
|
1284
|
+
* - The user who paused it, when known.
|
|
1285
|
+
*/
|
|
1286
|
+
pausedBy: string | null;
|
|
1287
|
+
/**
|
|
1288
|
+
* - When the conversation was paused.
|
|
1289
|
+
*/
|
|
1290
|
+
createdAt: string;
|
|
1291
|
+
/**
|
|
1292
|
+
* - Last-update timestamp.
|
|
1293
|
+
*/
|
|
1294
|
+
updatedAt: string;
|
|
1295
|
+
};
|
|
1175
1296
|
/**
|
|
1176
1297
|
* A reply an SMS agent wrote but did not send, held for a person to approve or reject (the
|
|
1177
1298
|
* Pending Replies queue), as returned by the server.
|
|
@@ -1222,7 +1343,7 @@ export type AgentReplyDraft = {
|
|
|
1222
1343
|
*/
|
|
1223
1344
|
sentText: string | null;
|
|
1224
1345
|
/**
|
|
1225
|
-
* - Why it was held: "review_mode", "escalation", "fallback" or "guardrail".
|
|
1346
|
+
* - Why it was held: "review_mode", "escalation", "fallback" or "guardrail", or "autopilot" for a confident auto-pilot reply that its channel delivers without a person.
|
|
1226
1347
|
*/
|
|
1227
1348
|
reason: string;
|
|
1228
1349
|
/**
|