@intelligence-cloud/sdk 0.1.0 → 0.2.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/CHANGELOG.md +45 -0
- package/README.md +122 -64
- package/dist/index.cjs +2618 -968
- package/dist/index.d.cts +923 -476
- package/dist/index.d.ts +923 -476
- package/dist/index.js +2597 -954
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-11-29)
|
|
4
|
+
|
|
5
|
+
Two new layers. `client.accounts` replaces `client.workflows`; `client.conversations` is new. Every generated resource method and every `client.intelligence` helper keeps its name and behaviour. The TypeScript SDK now matches the Python reference.
|
|
6
|
+
|
|
7
|
+
- **Account layer, `client.accounts`** (administrator login): create and maintain a customer on Base User and Base Manager licenses. A customer is a company with teams and a `<Company> - Management` location. Each team gets its own connector, five groups (Customer Threats, Upset Customers, Low Sentiment Calls, Insights Hub Access, Insights Hub Weekly Reports) and three alerts (Customer Threat, Upset Customer, Low Sentiment), each routed to its group. Management gets its own connector, which captures the managers' own lines, and the weekly reports group; it has no alerts. Helpers: `createCustomer`, `getCustomer`, `addTeam`, `setAlerts`, `setConnector`, `addBaseUser`, `addBaseManager`, `addIntegrationUser`, `changeLicense`, `moveUser`, `changeLine`, `removeUser`, `activateAlerts`, `sendInvitations`, `listMembers`, `licenseReport`, `syncLines`, `offboardCustomer`. Optional settings go in one options object as the last argument. Types are exported for every spec and result (`CustomerSpec`, `TeamSpec`, `ConnectorSpec`, `PersonSpec`, `AlertSetting`, `AlertSettings`, `Customer`, `Team`, `Member`, ...).
|
|
8
|
+
- Every account helper finds what exists before it writes: a second run with the same input writes nothing. A helper that stops part-way throws `AccountError` with the step, the result so far and the cause (it replaces `WorkflowError`).
|
|
9
|
+
- A customer can be created without the phrase lists: Low Sentiment and every group are created, `Customer.pending` lists the two phrase alerts, and `setAlerts` creates them when the lists arrive. `AlertSettings` sets the phrases and the sentiment level of each alert; leaving one out keeps what is there. Alerts are created switched off; `activateAlerts` switches them on for every team and lists teams with no Base Manager under `noManager`.
|
|
10
|
+
- Alert email is off for every person the helpers create, managers included (0.1.x switched it on for managers). Insights Hub "monitor all numbers" stays off.
|
|
11
|
+
- `new ConnectorSpec(type, config, { name, timeout })` takes any connector type the API accepts with that type's own settings; `ConnectorSpec.netsapiens(apiUrl, domain, apiKey)` is the shortcut for the documented one. Values whose names contain key, secret, token, password, passwd, pwd, credential or auth are hidden, at any depth, from `JSON.stringify`, `console.log` / `util.inspect` and `String()`, and never appear in an error message. `addTeam` requires a connector; `setConnector` attaches one to a customer created without it.
|
|
12
|
+
- **Conversation layer, `client.conversations`** (the person's own login): `me`, `teams`, `calls`, `brief`, `transcript`, `recordingLink`, `callerHistory`, `openTasks`, `alerts`, `alert`, `teamView`, `topics`, `reference`, `parseFirstAlertEvent`. Caller numbers are masked to their last four digits, and digit runs of five or more inside names too, unless the client is created with `maskNumbers: false`. Windows are at most 31 days and lists at most 200 (`callerHistory` 50), checked before any request. "Today" is worked out per date in the local time zone. Printing a `CallBrief` or `AlertBrief` (`String()`, `console.log`) shows only its id and time. `RecordingLink` hides its URL the same way.
|
|
13
|
+
- `CallBrief.link`, `AlertBrief.link` and `reference()` give the call or alert page in the app. `new Client({ appUrl })` sets the app address (https only; default `https://app.intelligence.cloud`).
|
|
14
|
+
- A connector that does not become running stops `createCustomer`, `addTeam` and `setConnector` with `AccountError` (step `"connectors"`, cause `ConnectorTimeoutError` or `ConnectorError`) once everything else is built; run again to finish. A connector that reports `connected` counts as running, as `active` does; `connectors.createConnector`, `reactivateConnector` and `updateConnector` wait for either.
|
|
15
|
+
- `addBaseUser`, `addBaseManager` and `addIntegrationUser` refuse a person already set up with another license; `changeLicense` converts. `changeLicense` and `moveUser` continue from where an earlier run stopped.
|
|
16
|
+
- `parseFirstAlertEvent` and `FirstAlertEvent` parse the First Alert webhook, beside `parseAfterCallEvent`.
|
|
17
|
+
- New errors: `AccountError`, `WrongLoginError` (an account helper with a user login, or a conversation helper with an administrator login) and `ConnectorTimeoutError` (a connector that did not settle in time used to be a `ConnectorError`). `InvalidRequestError` is the one name for input refused before sending; `FilterError` stays as an alias.
|
|
18
|
+
- `ConnectorError` carries `connectorId`, `status`, `stateReason`, `statusMessage` and `connector`.
|
|
19
|
+
- The generated types and operation table are regenerated from the current `openapi.yaml`.
|
|
20
|
+
- Examples: `examples/node/create-customer.mjs` replaces the provisioning example; `examples/node/my-day.mjs` shows the conversation layer.
|
|
21
|
+
|
|
22
|
+
Removed in 0.2.0, with no aliases:
|
|
23
|
+
|
|
24
|
+
| 0.1.x | 0.2.0 |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `client.workflows`, and the workflow shortcuts on the client | `client.accounts` |
|
|
27
|
+
| the 0.1.x provisioning helper, its spec and result types | `createCustomer`, `CustomerSpec`, `Customer` |
|
|
28
|
+
| `ConnectorSpec` as `{ apiUrl, domain, apiKey }` | `ConnectorSpec.netsapiens(apiUrl, domain, apiKey)`, or `new ConnectorSpec(type, config)` |
|
|
29
|
+
| `threatPhrases` | `alerts` (`AlertSettings`: phrases and sentiment level per alert) |
|
|
30
|
+
| the 0.1.x customer read-back helper | `getCustomer` |
|
|
31
|
+
| `addFrontlineUser` | `addBaseUser` |
|
|
32
|
+
| `addManager` | `addBaseManager` (own line now captured at Management; alert email now off) |
|
|
33
|
+
| the 0.1.x alert activation helper | `activateAlerts` |
|
|
34
|
+
| `changeUserExtension` | `changeLine` |
|
|
35
|
+
| `listFrontlineUsers`, `listManagers`, `listIntegrationUsers` | `listMembers({ license })` |
|
|
36
|
+
| `syncNumbers` | `syncLines` |
|
|
37
|
+
| `WorkflowError` | `AccountError` |
|
|
38
|
+
| the 0.1.x user result and spec types | `Member`, `PersonSpec`, `TeamSpec` |
|
|
39
|
+
| `upsetCustomerRule`, `customerThreatRule`, `THREAT_PHRASES_MISSING`, `MANAGER_ALERTS_GROUP` and the other workflow constants | none; defaults are internal |
|
|
40
|
+
| "Manager Alerts" group, two rules | Three groups and three rules per team |
|
|
41
|
+
|
|
42
|
+
A customer built with 0.1.x is not converted automatically: `getCustomer` lists what its layout is missing in `Customer.pending`.
|
|
43
|
+
|
|
44
|
+
## 0.1.1 (2026-11-29)
|
|
45
|
+
|
|
46
|
+
- Insights Hub "monitor all numbers" is never switched on. `provisionSeatCustomer` used to set `monitor_all_numbers` to true; it now leaves it off and switches it off where an earlier run switched it on. Insights Hub covers the lines listed for the location, which `addFrontlineUser` already adds. Re-run `provisionSeatCustomer` for customers set up with 0.1.0.
|
|
47
|
+
|
|
3
48
|
## 0.1.0: 2026-11-18 (Base Intelligence Seat manager lines)
|
|
4
49
|
|
|
5
50
|
- On the Base Intelligence Seat a manager's own phone line is not captured. `addManager(customer, user, { activateAlerts? })` no longer takes `ownExtension` or a string third argument (a string, or any option other than `activateAlerts`, now throws `FilterError` before any write): a manager is mapped to exactly the end-user lines at the location, and their own extension is never mapped, nor added to First Alert or Insights Hub. `AddManagerOptions` has `activateAlerts` only.
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Intelligence Cloud SDK for TypeScript
|
|
2
2
|
|
|
3
|
-
`@intelligence-cloud/sdk` 0.
|
|
3
|
+
`@intelligence-cloud/sdk` 0.2.0. The partner API for Node.js 20+ and Next.js server code (route handlers, server actions).
|
|
4
4
|
|
|
5
|
-
- **
|
|
6
|
-
- **
|
|
5
|
+
- **Customers** (administrator login): the account layer, `client.accounts`, creates and maintains a customer on Base User and Base Manager licenses, beside one method per API operation (companies, locations, users, products, connectors, First Alert rules, Insights Hub).
|
|
6
|
+
- **Conversations** (a user's own login): the conversation layer, `client.conversations`, gives a signed-in person their own calls, tasks and alerts; `client.intelligence` reads calls, transcripts, recording links, alerts, tasks and insights; and the After Call and First Alert webhooks.
|
|
7
7
|
|
|
8
8
|
Zero runtime dependencies (uses the global `fetch`). ESM and CommonJS builds with full types.
|
|
9
9
|
|
|
@@ -17,11 +17,11 @@ npm install @intelligence-cloud/sdk
|
|
|
17
17
|
|
|
18
18
|
The package holds only the compiled SDK and pulls in no dependencies.
|
|
19
19
|
|
|
20
|
-
Alternative, from the source download: it includes a packed build, `intelligence-cloud-sdk-0.
|
|
20
|
+
Alternative, from the source download: it includes a packed build, `intelligence-cloud-sdk-0.2.0.tgz`.
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
unzip typescript.zip -d vendor-src # creates vendor-src/typescript
|
|
24
|
-
npm install ./vendor-src/typescript/intelligence-cloud-sdk-0.
|
|
24
|
+
npm install ./vendor-src/typescript/intelligence-cloud-sdk-0.2.0.tgz # from your project
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```ts
|
|
@@ -39,10 +39,10 @@ Use one client per credential:
|
|
|
39
39
|
|
|
40
40
|
| Client | Login | For |
|
|
41
41
|
|---|---|---|
|
|
42
|
-
| Admin (`IC_ADMIN_EMAIL`, `IC_ADMIN_PASSWORD` in the examples) | a reseller admin
|
|
43
|
-
| Data (`IC_DATA_EMAIL`, `IC_DATA_PASSWORD` in the examples) | a frontline integration user mapped to the lines you need | calls, alerts, tasks, insights |
|
|
42
|
+
| Admin (`IC_ADMIN_EMAIL`, `IC_ADMIN_PASSWORD` in the examples) | a reseller admin login (`reseller_admin`) | `client.accounts`, `client.companies`, `client.users`, … |
|
|
43
|
+
| Data (`IC_DATA_EMAIL`, `IC_DATA_PASSWORD` in the examples) | a frontline login (`frontline_user`), a person's own or an integration user mapped to the lines you need | `client.conversations` and `client.intelligence` (calls, alerts, tasks, insights) |
|
|
44
44
|
|
|
45
|
-
Admin logins get empty lists from the conversation-data endpoints by design. The intelligence helpers check the role once and throw `FrontlineRequiredError` instead of returning nothing.
|
|
45
|
+
Admin logins get empty lists from the conversation-data endpoints by design. The intelligence helpers check the role once and throw `FrontlineRequiredError` instead of returning nothing; `client.conversations` throws `WrongLoginError`, and `client.accounts` throws it for a user login.
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
48
|
const ic = new Client({
|
|
@@ -53,6 +53,8 @@ const ic = new Client({
|
|
|
53
53
|
// tokenStore: new FileTokenStore("/var/lib/my-app/ic-tokens.json"), (default: memory)
|
|
54
54
|
// loginRateLimitWait: 60, (seconds to wait once on a sign-in 429; 0 throws at once)
|
|
55
55
|
// keepUnknownFields: false, (true keeps fields the reference doesn't list yet)
|
|
56
|
+
// maskNumbers: true, (client.conversations shows caller numbers as their last four digits; false shows them in full)
|
|
57
|
+
// appUrl: "https://app.intelligence.cloud", (links on call and alert briefs; https only)
|
|
56
58
|
// userAgent: "riverbend-bi-sync/1.0",
|
|
57
59
|
});
|
|
58
60
|
```
|
|
@@ -205,10 +207,10 @@ The Next.js route handler in `examples/nextjs/app/api/ic-webhook/[token]/route.t
|
|
|
205
207
|
|
|
206
208
|
Webhooks are how your integration hears about new calls and alerts: the After Call webhook for every call, the First Alert webhook for each alert as it fires. Subscribe to them; don't poll the API for new data.
|
|
207
209
|
|
|
208
|
-
The First Alert webhook posts the alert that fired: the alert id, the rule, the location, the call and the time. Read only the alert id, answer 2xx at once, then fetch the alert and its call with a frontline integration user in
|
|
210
|
+
The First Alert webhook posts the alert that fired: the alert id, the rule, the location, the call and the time. Read only the alert id, answer 2xx at once, then fetch the alert and its call with a frontline integration user in every alert group:
|
|
209
211
|
|
|
210
212
|
```ts
|
|
211
|
-
const alertId = alertIdFrom(await request.text()); // see examples/nextjs/app/api/ic-alert-webhook/[token]/route.ts
|
|
213
|
+
const alertId = alertIdFrom(await request.text()); // parseFirstAlertEvent(body).alertId; see examples/nextjs/app/api/ic-alert-webhook/[token]/route.ts
|
|
212
214
|
if (alertId && !(await alertDedup.isDuplicate(alertId))) { // a second Deduplicator, keyed on the alert id
|
|
213
215
|
after(async () => {
|
|
214
216
|
const alert = await ic.getAlert(alertId, { withCall: true }); // null when this login can't see it
|
|
@@ -225,59 +227,113 @@ for await (const a of ic.iterAlerts({ dateFrom: new Date(wentDown.getTime() - 30
|
|
|
225
227
|
}
|
|
226
228
|
```
|
|
227
229
|
|
|
228
|
-
##
|
|
230
|
+
## Account layer: `client.accounts` (admin)
|
|
231
|
+
|
|
232
|
+
A customer is one company with one or more **teams** (each a location in the API) and a **Management** location named `<Company> - Management`.
|
|
233
|
+
|
|
234
|
+
- Each team has a connector to the phone system, five groups (Customer Threats, Upset Customers, Low Sentiment Calls, Insights Hub Access, Insights Hub Weekly Reports) and three alerts, each routed to its group: Customer Threat (priority high, sentiment below -20 and its phrases), Upset Customer (medium, below -20 and its phrases) and Low Sentiment (low, below -40).
|
|
235
|
+
- Management has its own connector, which captures the managers' own lines, and the Insights Hub Weekly Reports group for the company-wide reports. It has no alerts.
|
|
236
|
+
- A **Base User** has After Call on their own line at one team. A **Base Manager** has all three products, their own line at Management, every Base User line of the teams they run, and those teams' groups.
|
|
229
237
|
|
|
230
238
|
```ts
|
|
231
|
-
|
|
239
|
+
import { Client, ConnectorSpec } from "@intelligence-cloud/sdk";
|
|
232
240
|
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
const admin = new Client({ email: process.env.IC_ADMIN_EMAIL!, password: process.env.IC_ADMIN_PASSWORD! });
|
|
242
|
+
const phoneSystem = ConnectorSpec.netsapiens("https://pbx.example.com/ns-api/v2", "riverbend.example.com", phoneSystemKey);
|
|
243
|
+
|
|
244
|
+
const customer = await admin.accounts.createCustomer({
|
|
245
|
+
companyId: savedCompanyId, // null the first time; store customer.companyId and pass it on re-runs
|
|
246
|
+
companyName: "Riverbend Dental",
|
|
247
|
+
admin: { email: "pat.lee@example.com", firstName: "Pat", lastName: "Lee", phoneNumber: "+15555550100" },
|
|
248
|
+
team: { name: "Riverbend - Main", street: "1 River Rd", city: "Springfield", state: "IL", country: "US", zipcode: "62701", vertical: "<vertical id or key>" },
|
|
249
|
+
connector: phoneSystem, // used for the team and for Management
|
|
250
|
+
alerts: { customerThreat: { phrases: threatPhrases }, upsetCustomer: { phrases: upsetPhrases } },
|
|
251
|
+
mfaOff: true, // the company has an integration user
|
|
242
252
|
});
|
|
253
|
+
const team = customer.teams[0]!;
|
|
243
254
|
|
|
244
|
-
|
|
245
|
-
await admin.
|
|
246
|
-
//
|
|
247
|
-
await admin.addManager(customer, { email: "office.manager@example.com", firstName: "Sam", lastName: "Ortiz" });
|
|
255
|
+
await admin.accounts.addBaseUser(customer, { email: "sam.ortiz@example.com", firstName: "Sam", lastName: "Ortiz" }, { team, line: "2101" });
|
|
256
|
+
await admin.accounts.addBaseManager(customer, { email: "dana.cho@example.com", firstName: "Dana", lastName: "Cho" }, { teams: [team], line: "2001" });
|
|
257
|
+
await admin.accounts.activateAlerts(customer); // once each team has a manager in its alert groups
|
|
248
258
|
```
|
|
249
259
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
-
|
|
260
|
+
Optional settings go in one options object as the last argument; names are the camelCase form of the field names in the other SDKs.
|
|
261
|
+
|
|
262
|
+
- **Phrase lists come from you.** The SDK holds none; ask your Tresic contact for them. A customer can be created without them: Low Sentiment and every group are created, `customer.pending` lists `"customerThreat"` and `"upsetCustomer"`, and `setAlerts` creates those alerts when the lists arrive. `AlertSetting` sets `phrases` and `sentimentBelow` (a whole number from -100 to -1); leaving one out keeps what is there.
|
|
263
|
+
- **Safe to re-run.** Every helper finds what exists before it writes; a second run with the same input writes nothing. A company is never adopted by its name alone: pass `companyId` from the first run. Without it, a same-named company is used only when its primary contact email is `admin.email`; otherwise `ConflictError` (`code: "company_name_conflict"`) is thrown before anything is written.
|
|
264
|
+
- **Stops are reported.** A helper that fails part-way throws `AccountError` with `.step`, `.result` (so far) and `.cause`. Run it again with the same input to continue; `changeLicense` and `moveUser` also recognise a person they left part-way. A connector that does not become active stops `createCustomer`, `addTeam` and `setConnector` at the end, once everything else is built: `.step` is `"connectors"` and `.cause` is `ConnectorTimeoutError` or `ConnectorError` (with `stateReason`).
|
|
265
|
+
- **Existing people keep their license.** `addBaseUser`, `addBaseManager` and `addIntegrationUser` refuse (`InvalidRequestError`, before any write) a person already set up with another license; use `changeLicense`.
|
|
266
|
+
- **Alerts start switched off.** `activateAlerts` switches them on for every team. A team does not need a manager: its alerts then show in the app only, and it is listed under `noManager` with the alert groups that have none.
|
|
267
|
+
- **One at a time.** The helpers for one customer run one at a time within a client (each waits for the one before it). Do not run them at the same time from several clients or processes: lists are read, merged and written back, and two writers lose each other's lines.
|
|
268
|
+
- **Alert email is off** for every person the helpers create, managers included. People switch it on in their own settings.
|
|
269
|
+
- **Insights Hub "monitor all numbers" stays off.** The helpers never switch it on and switch it off where they find it on.
|
|
270
|
+
- **Nothing is deleted.** Companies, locations and people are deactivated; connectors are stopped.
|
|
271
|
+
- **Invitations go last.** People are created without one; it is emailed once their products, groups and lines are in place (`invite: false` holds it back; `sendInvitations` sends it later).
|
|
272
|
+
- **Connectors.** `new ConnectorSpec(type, config, { name, timeout })` takes the phone platform as the API names it and that platform's own settings; `ConnectorSpec.netsapiens(apiUrl, domain, apiKey)` is the shortcut for the documented one. Give the key in full each time: it is sent when a connector is created or repaired and is never kept or logged. Any setting whose name contains key, secret, token, password, passwd, pwd, credential or auth is hidden at any depth from `JSON.stringify`, `console.log` / `util.inspect` and `String()`; `spec.config` is for sending: copying it out (spread, `Object.entries`) exposes its values. Setting names `__proto__`, `constructor` and `prototype` are refused. A new connector is checked every 10 seconds until it settles (`active` or `connected`); its status is recorded on the team (`connectorStatus`, `connectorStateReason`). A re-run with a corrected key repairs a connector in `error`; it never creates a second one.
|
|
273
|
+
|
|
274
|
+
| Helper | Does | Returns |
|
|
275
|
+
|---|---|---|
|
|
276
|
+
| `createCustomer(spec)` | Company with all three products, SSO domain claim (optional), first team and Management, connector on each (if given), groups, alerts (switched off), Insights Hub | `Customer` |
|
|
277
|
+
| `getCustomer(companyId)` | Reads the layout back; a layout it does not recognise is listed in `pending` | `Customer` |
|
|
278
|
+
| `addTeam(customer, team, connector, { alerts?, reactivate? })` | A further team with its connector, groups, alerts (copying the first team's phrases and levels unless `alerts` sets them) and Insights Hub | `Team` |
|
|
279
|
+
| `setAlerts(customer, alerts, { team? })` | Phrases and sentiment levels on one team or all; alerts keep their on or off state | rule ids changed |
|
|
280
|
+
| `setConnector(customer, connector, { team? })` | Attaches a phone system to the named team, or the first team and Management; refuses where an active one exists | `Team[]` |
|
|
281
|
+
| `addBaseUser(customer, person, { team, line, invite? })` | After Call, their line on the team's connector, First Alert and Insights Hub lists and the team's managers | `Member` |
|
|
282
|
+
| `addBaseManager(customer, person, { teams, line?, companyReports?, invite? })` | All three products on each team and Management, own line at Management, the teams' lines and groups; `companyReports: true` adds the company-wide reports group | `Member` |
|
|
283
|
+
| `addIntegrationUser(customer, person, { invite? })` | A data-reading user across every team: password sign-in, tagged `department: "integration"`, every line | `Member` |
|
|
284
|
+
| `changeLicense(customer, userId, to, { teams?, line? })` | `"base_manager"` or `"base_user"`, moving their own line between the team and Management | `Member` |
|
|
285
|
+
| `moveUser(customer, userId, { fromTeam, toTeam })` | Moves a Base User's membership and line, or swaps one of a manager's teams; call history stays with the old team | `Member` |
|
|
286
|
+
| `changeLine(customer, userId, old, new)` | A Base User's line: their mapping and the team's lists (a line another Base User still holds stays listed). A manager's own line at Management only | `Member` |
|
|
287
|
+
| `removeUser(customer, userId, { keepLines? })` | Clears groups and lines, then deactivates; `notes` names teams left with no manager in an alert group (alerts are not changed) | summary |
|
|
288
|
+
| `activateAlerts(customer, { team? })` | Switches alerts on where each alert group has a manager | `{ switchedOn, noManager }` (noManager: teams whose alert groups have no manager, with those groups) |
|
|
289
|
+
| `sendInvitations(customer, { userIds? })` | Sends invitations not yet sent or expired; re-sends to `userIds` | user ids |
|
|
290
|
+
| `listMembers(customer, { license?, team? })` | Everyone, with license (`base_user`, `base_manager`, `integration`, `other`), teams and lines | `Member[]` |
|
|
291
|
+
| `licenseReport(customer)` | People by license and the number of teams (Management not counted) | counts and members |
|
|
292
|
+
| `syncLines(customer, { dryRun? })` | Makes every line list match the people. Someone with After Call and one line who reads back as `other` keeps their line and is listed under `other` | changes |
|
|
293
|
+
| `offboardCustomer(customer, { deactivateCompany? })` | Pauses webhooks, stops every connector, deactivates integration users and the company | summary |
|
|
294
|
+
|
|
295
|
+
Every helper that takes `customer` also takes a company id. `team` is a `Team`, its location id or its name. Lines need a **running** connector: a refused mapping throws `AccountError` whose `.cause` is `ExtensionMappingError`, and no invitation is sent. An extension belongs to one location only: a clash throws `ConflictError` with the message "Extension is already monitored at another location."
|
|
296
|
+
|
|
297
|
+
A customer built with 0.1.x is not converted: `getCustomer` lists what its layout is missing in `pending`.
|
|
298
|
+
|
|
299
|
+
## Conversation layer: `client.conversations` (user login)
|
|
300
|
+
|
|
301
|
+
Sign in as the person. The platform decides what each call returns: a Base User gets their own calls, a Base Manager their teams'.
|
|
253
302
|
|
|
254
|
-
|
|
303
|
+
```ts
|
|
304
|
+
const me = new Client({ email: process.env.IC_USER_EMAIL!, password: process.env.IC_USER_PASSWORD! });
|
|
255
305
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
|
266
|
-
|
|
267
|
-
| `
|
|
268
|
-
| `
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
306
|
+
for (const brief of await me.conversations.calls()) { // today, newest first
|
|
307
|
+
console.log(String(brief)); // CallBrief(id='…', when='…'): no content
|
|
308
|
+
}
|
|
309
|
+
const history = await me.conversations.callerHistory("5555550142", { limit: 5 });
|
|
310
|
+
const detail = await me.conversations.brief(callId); // summary, key points, tasks, sentiment, topics, alerts
|
|
311
|
+
const tasks = await me.conversations.openTasks();
|
|
312
|
+
const board = await me.conversations.teamView(teamId); // for a manager: counts, alerts, open tasks, briefs
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
| Helper | Returns | Limits |
|
|
316
|
+
|---|---|---|
|
|
317
|
+
| `me()`, `teams()` | Who is signed in and the teams they can see. `me().lines` is `null`: the API gives a user login no way to read its own lines | |
|
|
318
|
+
| `calls({ day?, since?, until?, team?, number?, search?, limit? = 50 })` | `CallBrief[]`, newest first; default today | window at most 31 days, `limit` at most 200 |
|
|
319
|
+
| `brief(callId)` | One `CallBrief` with key points, tasks, topics and the alerts it raised (read from one page of that day's alerts, so a day with more than 100 alerts can miss some) | no transcript, no recording |
|
|
320
|
+
| `transcript(callId)` | The transcript of one call | one call per request |
|
|
321
|
+
| `recordingLink(callId)` | A `RecordingLink` that expires (`null` without a recording); the SDK never downloads the audio | |
|
|
322
|
+
| `callerHistory(number, { limit? = 10 })` | Recent briefs for one caller (last 31 days) | `limit` at most 50 |
|
|
323
|
+
| `openTasks({ due?, team? })` | Open tasks with the id of the call each came from | up to 200 |
|
|
324
|
+
| `alerts({ since?, until?, team?, limit? = 50 })` | `AlertBrief[]` on this person's teams. `status` throws `InvalidRequestError` and `holder` is `null`: the API has no alert status or holder yet | as `calls` |
|
|
325
|
+
| `alert(alertId)` | One alert with its call brief (`null` when this login cannot see it) | |
|
|
326
|
+
| `teamView(team, { day?, since?, until? })` | Counts, alerts, open tasks and briefs for one team | as `calls` |
|
|
327
|
+
| `topics({ since?, until?, team? })` | Topic volumes and rising topics (default last 7 days) | needs Insights Hub access |
|
|
328
|
+
| `reference(callOrAlert)` | The id and its page in the app, to pass to another system in place of content | |
|
|
329
|
+
| `parseFirstAlertEvent(payload)` | A `FirstAlertEvent` | |
|
|
330
|
+
|
|
331
|
+
- **Caller numbers are masked** to their last four digits (`***0142`) unless the client was created with `maskNumbers: false`, also where a digit run of five or more appears in a name. Extensions are shown as they are.
|
|
332
|
+
- **Links**: `CallBrief.link`, `AlertBrief.link` and `reference()` give the page in the app, `<app>/after-call-copilot/calls/<id>` or `<app>/first-alert-copilot/alerts/<id>`; they carry only the id. `<app>` is `https://app.intelligence.cloud` unless you pass your own address: `new Client({ …, appUrl: "https://…" })` (https only).
|
|
333
|
+
- **Limits are checked before any request**: a longer window, a larger limit, `number` with `search`, or a date without a time zone offset throws `InvalidRequestError`. Dates are a `Date` or an RFC 3339 string with an offset; `day` is a `Date` (its local calendar day) or `"YYYY-MM-DD"`. "Today" and `day` are midnight to midnight in this machine's time zone, worked out for that date, daylight saving included.
|
|
334
|
+
- `JSON.stringify` of a brief returns all its fields, so do not hand briefs to a JSON logger.
|
|
335
|
+
- **Nothing is logged.** Printing a brief (`String()`, `console.log`) shows its id and time only. Keep summaries, names and numbers out of your own logs too.
|
|
336
|
+
- An administrator login throws `WrongLoginError`. There is no helper that walks every call; for a bounded daily job use `client.intelligence.iterCalls`.
|
|
281
337
|
|
|
282
338
|
## Low-level methods
|
|
283
339
|
|
|
@@ -318,15 +374,15 @@ What the SDK does for you on these:
|
|
|
318
374
|
- **Full-replacement writes** (`enabled_products`, `member_ids`, `group_ids`, rule triggers and groups, First Alert numbers and webhook URL, Insights Hub numbers and groups, user number mappings, user locations) have `add*` / `remove*` / `set*` helpers that read, merge, then write.
|
|
319
375
|
- `users.createCompanyUser` always sends an `Idempotency-Key` (a new UUID per call unless you pass `{ idempotencyKey }`) and reuses it on retries. After a 422 it looks the user up by email and fixes the half-created user with PATCH.
|
|
320
376
|
- Webhook test results and connector dry runs never carry the server's error text.
|
|
321
|
-
- `connectors.createConnector`, `reactivateConnector` and `updateConnector` (when it reconnects) wait until the connector is `active
|
|
377
|
+
- `connectors.createConnector`, `reactivateConnector` and `updateConnector` (when it reconnects) wait until the connector is running (`active` or `connected`), and throw `ConnectorError` with `stateReason` (for example `invalid_permissions` for a key without the permissions the connector needs) when it lands in `error`. If it has not settled in time they throw `ConnectorTimeoutError`. `deactivateConnector` waits for `inactive`. They check the status every 10 seconds for up to 10 minutes. Pass `{ wait: false }` to return at once, or `{ timeout, checkInterval }` in seconds.
|
|
322
378
|
- The connector dry run and the webhook tests return only `success` and the HTTP status.
|
|
323
|
-
- `client.intelligence`
|
|
379
|
+
- `client.intelligence` holds the read helpers; the same methods are also on the client itself. `client.accounts` and `client.conversations` are the two layers above.
|
|
324
380
|
|
|
325
381
|
## Filters and validation
|
|
326
382
|
|
|
327
383
|
The API ignores parameters it doesn't know and returns unfiltered data. The SDK accepts only the documented filters and checks them **before** sending:
|
|
328
384
|
|
|
329
|
-
- An unknown filter throws `FilterError
|
|
385
|
+
- An unknown filter throws `InvalidRequestError` (`FilterError` is kept as an alias).
|
|
330
386
|
- Dates: a `Date` or a full RFC 3339 timestamp, always sent as UTC. `2026-11-01` alone is refused; use `2026-11-01T00:00:00Z`. A `Date` passed as `dueOn` is sent as its local calendar date.
|
|
331
387
|
- `numbers`: at most 25, stripped to digits; a North American number with its leading 1 is sent as the last 10 digits (`+1 555-555-0142` → `5555550142`), because some numbers are stored without the 1. `locationIds`: at most 50 (longer query strings are refused before they reach the API).
|
|
332
388
|
- Enum values, UUIDs, page sizes (1–100) and required filters are checked.
|
|
@@ -341,12 +397,14 @@ IntelligenceCloudError
|
|
|
341
397
|
│ ├── ConflictError 409 (extensions: the refused extensions on a number conflict; code company_name_conflict)
|
|
342
398
|
│ ├── ValidationError 400, 422
|
|
343
399
|
│ └── RateLimitError 429 after retries (retryAfter in seconds)
|
|
344
|
-
├──
|
|
345
|
-
├──
|
|
346
|
-
├── FrontlineRequiredError conversation data requested with an admin login
|
|
347
|
-
├──
|
|
348
|
-
├──
|
|
349
|
-
|
|
400
|
+
├── InvalidRequestError bad input, refused by the SDK before sending (FilterError is an alias)
|
|
401
|
+
├── WrongLoginError an account helper with a user login, or a conversation helper with an administrator login
|
|
402
|
+
├── FrontlineRequiredError conversation data requested with an admin login (client.intelligence)
|
|
403
|
+
├── AccountError an account helper stopped part-way (step, result, cause); run it again
|
|
404
|
+
├── ConnectorError connector ended in error (stateReason)
|
|
405
|
+
├── ConnectorTimeoutError a new connector did not settle in time
|
|
406
|
+
├── ExtensionMappingError a helper could not map a user's numbers (userId, cause)
|
|
407
|
+
└── WebhookPayloadError body isn't a JSON object, or a malformed After Call or First Alert event (400)
|
|
350
408
|
└── PayloadTooLargeError body over 256 KB (413)
|
|
351
409
|
```
|
|
352
410
|
|
|
@@ -370,7 +428,7 @@ try {
|
|
|
370
428
|
|
|
371
429
|
## Secrets
|
|
372
430
|
|
|
373
|
-
Never log access or refresh tokens, passwords, phone-system keys, webhook URLs or recording links. The SDK logs nothing and never returns the one-time sign-in link the API can include when a user is created.
|
|
431
|
+
Never log access or refresh tokens, passwords, phone-system keys, webhook URLs or recording links. The SDK logs nothing and never returns the one-time sign-in link the API can include when a user is created. A connector's key is sent once and never kept: it is hidden from `JSON.stringify`, `console.log` and `String()` on `ConnectorSpec`, and it is not in any error message. A `RecordingLink` hides its URL the same way.
|
|
374
432
|
|
|
375
433
|
## Build from source
|
|
376
434
|
|