intelligence-cloud 0.1.0__tar.gz → 0.2.0__tar.gz
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.
- intelligence_cloud-0.2.0/CHANGELOG.md +84 -0
- intelligence_cloud-0.2.0/CONTRIBUTING.md +19 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/PKG-INFO +119 -61
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/README.md +118 -60
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/_common.py +1 -1
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/alert_webhook_receiver.py +1 -1
- intelligence_cloud-0.2.0/examples/create_customer.py +68 -0
- intelligence_cloud-0.2.0/examples/my_day.py +33 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/pyproject.toml +1 -1
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/__init__.py +38 -15
- intelligence_cloud-0.2.0/src/intelligence_cloud/_version.py +1 -0
- intelligence_cloud-0.2.0/src/intelligence_cloud/accounts.py +1958 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/client.py +43 -9
- intelligence_cloud-0.2.0/src/intelligence_cloud/conversations.py +529 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/data/spec.json +2 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/errors.py +51 -4
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/receiver.py +85 -1
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/resources.py +10 -4
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/live/test_live.py +248 -112
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/unit/fake_api.py +147 -18
- intelligence_cloud-0.2.0/tests/unit/test_accounts.py +629 -0
- intelligence_cloud-0.2.0/tests/unit/test_conversations.py +203 -0
- intelligence_cloud-0.2.0/tests/unit/test_review2.py +197 -0
- intelligence_cloud-0.2.0/tests/unit/test_review_fixes.py +549 -0
- intelligence_cloud-0.1.0/CHANGELOG.md +0 -42
- intelligence_cloud-0.1.0/examples/provision_seat.py +0 -48
- intelligence_cloud-0.1.0/src/intelligence_cloud/_version.py +0 -1
- intelligence_cloud-0.1.0/src/intelligence_cloud/workflows.py +0 -791
- intelligence_cloud-0.1.0/tests/unit/test_review2.py +0 -408
- intelligence_cloud-0.1.0/tests/unit/test_workflows.py +0 -362
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/.gitignore +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/LICENSE +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/SECURITY.md +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/after-call-sample.json +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/export_calls.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/webhook_receiver.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/examples/whoami.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_base.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_generated.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_spec.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/auth.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/intelligence.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/src/intelligence_cloud/py.typed +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/__init__.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/unit/__init__.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/unit/test_client.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tests/unit/test_intelligence.py +0 -0
- {intelligence_cloud-0.1.0 → intelligence_cloud-0.2.0}/tools/generate.py +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Changelog
|
|
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.
|
|
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: `create_customer`, `get_customer`, `add_team`, `set_alerts`, `set_connector`, `add_base_user`, `add_base_manager`, `add_integration_user`, `change_license`, `move_user`, `change_line`, `remove_user`, `activate_alerts`, `send_invitations`, `list_members`, `license_report`, `sync_lines`, `offboard_customer`.
|
|
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 raises `AccountError` with the step, the result so far and the cause.
|
|
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 `set_alerts` creates them when the lists arrive. `AlertSettings` sets the phrases and the sentiment level of each alert; `None` keeps what is there. Alerts are created switched off; `activate_alerts` switches them on for teams with a Base Manager in each alert group.
|
|
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
|
+
- `ConnectorSpec(type, config, name=None, timeout=600)` takes any connector type the API accepts with that type's own settings; `ConnectorSpec.netsapiens(api_url, domain, api_key)` is the shortcut for the documented one. Values whose names contain key, secret, token or password are hidden when the spec is printed. `add_team` requires a connector; `set_connector` attaches one to a customer created without it.
|
|
12
|
+
- **Conversation layer, `client.conversations`** (the person's own login): `me`, `teams`, `calls`, `brief`, `transcript`, `recording_link`, `caller_history`, `open_tasks`, `alerts`, `alert`, `team_view`, `topics`, `reference`, `parse_first_alert_event`. Caller numbers are masked to their last four digits unless the client is created with `mask_numbers=False`. Windows are at most 31 days and lists at most 200 (`caller_history` 50), checked before any request. Printing a `CallBrief` or `AlertBrief` shows only its id and time.
|
|
13
|
+
- **Network failures raise `NetworkError`** (an `ApiError` with status 0) in place of the HTTP library's own error, which held the request: a request can hold a password, a token or a connection key.
|
|
14
|
+
- `CallBrief.link`, `AlertBrief.link` and `reference()` give the call or alert page in the app. `Client(app_url=...)` sets the app address (https only; default `https://app.intelligence.cloud`).
|
|
15
|
+
- A connector that does not become active stops `create_customer`, `add_team` and `set_connector` with `AccountError` (step `"connectors"`, cause `ConnectorTimeoutError` or `ConnectorError`) once everything else is built; run again to finish.
|
|
16
|
+
- `add_base_user`, `add_base_manager` and `add_integration_user` refuse a person already set up with another license; `change_license` converts. `change_license` and `move_user` continue from where an earlier run stopped.
|
|
17
|
+
- `parse_first_alert_event` and `FirstAlertEvent` parse the First Alert webhook, beside `parse_after_call_event`.
|
|
18
|
+
- New errors: `AccountError` and `WrongLoginError` (an account helper with a user login, or a conversation helper with an administrator login).
|
|
19
|
+
- Examples: `examples/create_customer.py` replaces the provisioning example; `examples/my_day.py` shows the conversation layer.
|
|
20
|
+
|
|
21
|
+
Removed in 0.2.0, with no aliases:
|
|
22
|
+
|
|
23
|
+
| 0.1.x | 0.2.0 |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `client.workflows` | `client.accounts` |
|
|
26
|
+
| the 0.1.x provisioning helper and its spec and result types | `create_customer`, `CustomerSpec`, `Customer` |
|
|
27
|
+
| `ConnectorSpec(api_url, domain, api_key)` | `ConnectorSpec.netsapiens(api_url, domain, api_key)`, or `ConnectorSpec(type, config)` |
|
|
28
|
+
| `threat_phrases` | `alerts` (`AlertSettings`: phrases and sentiment level per alert) |
|
|
29
|
+
| the 0.1.x customer read-back helper | `get_customer` |
|
|
30
|
+
| `add_frontline_user` | `add_base_user` |
|
|
31
|
+
| `add_manager` | `add_base_manager` (own line now captured at Management; alert email now off) |
|
|
32
|
+
| the 0.1.x alert activation helper | `activate_alerts` |
|
|
33
|
+
| `change_user_extension` | `change_line` |
|
|
34
|
+
| `list_frontline_users`, `list_managers`, `list_integration_users` | `list_members(license=...)` |
|
|
35
|
+
| `sync_numbers` | `sync_lines` |
|
|
36
|
+
| the 0.1.x user result type, `UserSpec`, `LocationSpec` | `Member`, `PersonSpec`, `TeamSpec` |
|
|
37
|
+
| "Manager Alerts" group, two rules | Three groups and three rules per team |
|
|
38
|
+
|
|
39
|
+
A customer built with 0.1.x is not converted automatically: `get_customer` lists what its layout is missing in `Customer.pending`.
|
|
40
|
+
|
|
41
|
+
## 0.1.1 (2026-11-29)
|
|
42
|
+
|
|
43
|
+
- Insights Hub "monitor all numbers" is never switched on. `provision_seat_customer` 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 `add_frontline_user` already adds. Re-run `provision_seat_customer` for customers set up with 0.1.0.
|
|
44
|
+
|
|
45
|
+
## 0.1.0: Base Intelligence Seat manager lines (2026-11-18)
|
|
46
|
+
|
|
47
|
+
- On the Base Intelligence Seat a manager's own phone line is not captured. `add_manager(customer, user, *, activate_alerts=True)` no longer takes `own_extension` (`activate_alerts` is keyword-only, so an extension passed positionally raises `TypeError`): 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.
|
|
48
|
+
- `sync_numbers` sets every manager's mapping to exactly the lines (as for integration users); a number on a manager that is not a line is removed.
|
|
49
|
+
|
|
50
|
+
## 0.1.0: review changes (2026-11-17)
|
|
51
|
+
|
|
52
|
+
- Licence: the Intelligence Cloud SDK Licence (Copyright (c) 2026 Creo Solutions, Inc. d/b/a Tresic), the same text in every SDK: partners, their customers and contractors may use, copy, modify and distribute the SDK solely to access Intelligence Cloud; provided as is.
|
|
53
|
+
- **Python 3.10 or later, `httpx` 0.27 or later.** The package ships `py.typed`.
|
|
54
|
+
- `provision_seat_customer` never adopts a company by its name alone. Pass `SeatCustomerSpec.company_id` (store it 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 raised before anything is written. New helper `companies.find_companies`.
|
|
55
|
+
- Integration users: `add_integration_user` (password sign-in, tagged `department: "integration"`, all products, both groups, alert email off, every line) and `list_integration_users`. Integration users are never counted as seats or managers and get every new line. A manager now needs all three products.
|
|
56
|
+
- `remove_user` releases only an end user's line, and only when no other end user holds it. Removing a manager, an integration user or anyone holding several lines never takes a line off anyone else. `sync_numbers` counts as lines only end users holding exactly one number.
|
|
57
|
+
- `SeatCustomer.exclude_user_ids` / `exclude_emails`: users every workflow ignores.
|
|
58
|
+
- `offboard_customer`: pause the After Call webhook, clear the First Alert webhook, stop the connector, deactivate integration users, deactivate the company.
|
|
59
|
+
- Connectors are matched on their phone-system domain. A re-run updates a connector in `error`, stopped or changed with the settings passed (including a new key) and restarts it; it never creates a second one.
|
|
60
|
+
- `parse_after_call_event` returns `UnknownEvent` for event types it doesn't handle, and takes `max_bytes` (256 KB, `MAX_EVENT_BYTES`; `PayloadTooLargeError` above it).
|
|
61
|
+
- Token stores may implement `lock()` for sharing tokens across processes; new `FileTokenStore`. A 429 on renewal retries the same refresh token instead of signing in.
|
|
62
|
+
- `Retry-After` is honoured up to 60 seconds; a longer one raises `RateLimitError` at once. `Client(login_rate_limit_wait=60)` makes the sign-in wait configurable.
|
|
63
|
+
- `Client(keep_unknown_fields=True)` keeps response fields the reference doesn't list yet on customer-lifecycle reads (never sign-in links; conversation-data reads always keep only documented fields).
|
|
64
|
+
- `base_url` must be https (http only for localhost). A `datetime` without a time zone is refused. Alert `numbers` send North American numbers as their last 10 digits.
|
|
65
|
+
- Exception text carries only the status, code and request id (plus text the SDK wrote); the server's text stays on `.message`.
|
|
66
|
+
- Examples: receivers read their path token from the environment and refuse one shorter than 32 characters; the After Call receiver caps bodies at 256 KB, stores each call id in a persistent queue before answering and reads the call before using it. `examples/after-call-sample.json` for local tests.
|
|
67
|
+
- `tools/generate.py` takes the spec path (required) and `--check`.
|
|
68
|
+
|
|
69
|
+
## 0.1.0 (2026-11-16)
|
|
70
|
+
|
|
71
|
+
First release.
|
|
72
|
+
|
|
73
|
+
- Client with email and password sign-in for a dedicated integration user, automatic token renewal (single-use refresh tokens, renewal serialised across threads) and a pluggable token store.
|
|
74
|
+
- One method per API operation, grouped by reference section, with `iter_*` paging.
|
|
75
|
+
- Filters checked before sending: unknown filters, date-only values, enum values, up to 25 numbers and 50 location ids.
|
|
76
|
+
- Responses carry only the fields in the published reference.
|
|
77
|
+
- Read-merge-write helpers for every full-replacement write.
|
|
78
|
+
- User create with an idempotency key and recovery when a refused create left the user behind.
|
|
79
|
+
- Connector create, reactivate and deactivate wait for the final status, checking every 10 seconds for up to 10 minutes (`timeout=`, `ConnectorsAPI.check_interval`).
|
|
80
|
+
- Base Intelligence Seat workflows: provision a customer, add managers and end users, change an extension, remove a user, list users by type, sync numbers.
|
|
81
|
+
- Workflows email each user's invitation last, after their lines are mapped. Alert rules are created switched off and come on with the first manager (`activate_seat_alerts`).
|
|
82
|
+
- Conversation intelligence: calls, transcripts, recording links, alerts, tasks, insights.
|
|
83
|
+
- After Call and First Alert webhook configuration, After Call event parsing and de-duplication.
|
|
84
|
+
- New calls and alerts reach you on the After Call and First Alert webhooks (2026-11-17). `examples/alert_webhook_receiver.py` is a First Alert receiver: it reads only the alert id, answers at once and fetches the alert and its call with `get_alert(alert_id, with_call=True)`. The README covers a one-off catch-up after an outage.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in the Intelligence Cloud SDK. Tresic maintains this SDK.
|
|
4
|
+
|
|
5
|
+
## Pull requests
|
|
6
|
+
|
|
7
|
+
We don't accept code contributions from outside Tresic. Pull requests from outside contributors are closed without being merged, so that all code in the SDK is owned by Tresic and covered by its licence (see `LICENSE`). If you have a fix in mind, describe it in an issue instead.
|
|
8
|
+
|
|
9
|
+
## Bugs and feature requests
|
|
10
|
+
|
|
11
|
+
Open a GitHub issue, or write to support@tresic.cloud or your provider. Issues are public, so never include tokens, passwords, API keys, webhook URLs, recording links, phone numbers, names or any conversation content. Include the SDK version, your runtime version, the method you called and the `request_id` from the error.
|
|
12
|
+
|
|
13
|
+
## Security issues
|
|
14
|
+
|
|
15
|
+
Don't open an issue. Report vulnerabilities to security@tresic.cloud, as described in `SECURITY.md` and at https://docs.intelligence.cloud/security.
|
|
16
|
+
|
|
17
|
+
## Feedback
|
|
18
|
+
|
|
19
|
+
Suggestions and feedback you send may be used by Tresic without obligation to you, as the Intelligence Cloud API and SDK Terms (https://docs.intelligence.cloud/terms/api) set out.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: intelligence-cloud
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Python client for the Intelligence Cloud partner API: customer lifecycle and conversation intelligence.
|
|
5
5
|
Project-URL: Homepage, https://docs.intelligence.cloud
|
|
6
6
|
Project-URL: Documentation, https://docs.intelligence.cloud/api
|
|
@@ -41,10 +41,10 @@ Description-Content-Type: text/markdown
|
|
|
41
41
|
|
|
42
42
|
Python client for the Intelligence Cloud partner API. It covers both jobs:
|
|
43
43
|
|
|
44
|
-
- **
|
|
45
|
-
- **
|
|
44
|
+
- **Customers** with an 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, Insights Hub).
|
|
45
|
+
- **Conversations** with a user login: the conversation layer (`client.conversations`) gives a signed-in person their own calls, tasks and alerts; `client.intelligence` reads calls, transcripts, recordings, alerts, tasks and insights; and the After Call and First Alert webhooks.
|
|
46
46
|
|
|
47
|
-
Version 0.
|
|
47
|
+
Version 0.2.0. Python 3.10 or later. One dependency: `httpx` (0.27 or later).
|
|
48
48
|
|
|
49
49
|
The API reference is at https://docs.intelligence.cloud/reference.html, built from https://docs.intelligence.cloud/openapi.yaml.
|
|
50
50
|
|
|
@@ -67,16 +67,16 @@ To run the examples without installing: `uv run --with httpx --with-editable . p
|
|
|
67
67
|
|
|
68
68
|
## Credentials
|
|
69
69
|
|
|
70
|
-
Today every integration signs in with the email and password of a **dedicated integration user**. Turn MFA off for that user's company (`mfa_off=True` in `
|
|
70
|
+
Today every integration signs in with the email and password of a **dedicated integration user**. Turn MFA off for that user's company (`mfa_off=True` in `create_customer`, or `PATCH /companies/{id}` with `mfa_enforced: false`). **API keys arrive in December 2026.**
|
|
71
71
|
|
|
72
72
|
Use one client per credential:
|
|
73
73
|
|
|
74
74
|
| Credential | Role | Use it for |
|
|
75
75
|
|---|---|---|
|
|
76
|
-
| Admin | `reseller_admin` | `client.companies`, `client.users`, ...
|
|
77
|
-
| Frontline | `frontline_user` | `client.intelligence` (calls, alerts, tasks, insights) |
|
|
76
|
+
| Admin | `reseller_admin` | `client.accounts`, `client.companies`, `client.users`, ... |
|
|
77
|
+
| Frontline | `frontline_user` | `client.conversations` and `client.intelligence` (calls, alerts, tasks, insights) |
|
|
78
78
|
|
|
79
|
-
Admin logins get empty lists from the conversation-data endpoints by design. `client.intelligence` checks the role once and raises `FrontlineRequiredError` instead of returning empty data.
|
|
79
|
+
Admin logins get empty lists from the conversation-data endpoints by design. `client.intelligence` checks the role once and raises `FrontlineRequiredError` instead of returning empty data. `client.conversations` raises `WrongLoginError` for an administrator login, and `client.accounts` raises it for a user login.
|
|
80
80
|
|
|
81
81
|
Keep credentials out of source code. Read them from your secret store or environment. Send secrets to Tresic only through **security@tresic.cloud**, and report security issues there too.
|
|
82
82
|
|
|
@@ -88,7 +88,7 @@ admin = Client(email=os.environ["IC_ADMIN_EMAIL"], password=os.environ["IC_ADMIN
|
|
|
88
88
|
data = Client(email=os.environ["IC_DATA_EMAIL"], password=os.environ["IC_DATA_PASSWORD"])
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
`Client(base_url="https://app.intelligence.cloud/api/v1", email, password, token_store=None, timeout=30)`; also `user_agent=` (prefixed to the SDK's own), `max_retries=3`, `login_rate_limit_wait=60` (seconds; `0` raises `RateLimitError` at once, better inside a web request) and `keep_unknown_fields=False` (see "Rules the SDK applies for you"). `base_url` must be `https://` (`http://` only for `localhost`). If you pass your own `transport=`, keep certificate verification on.
|
|
91
|
+
`Client(base_url="https://app.intelligence.cloud/api/v1", email, password, token_store=None, timeout=30)`; also `user_agent=` (prefixed to the SDK's own), `max_retries=3`, `login_rate_limit_wait=60` (seconds; `0` raises `RateLimitError` at once, better inside a web request) and `keep_unknown_fields=False` (see "Rules the SDK applies for you"), `mask_numbers=True` and `app_url="https://app.intelligence.cloud"` (see "Conversation layer"). `base_url` must be `https://` (`http://` only for `localhost`). If you pass your own `transport=`, keep certificate verification on.
|
|
92
92
|
|
|
93
93
|
### Sign-in, tokens and sign-out
|
|
94
94
|
|
|
@@ -101,61 +101,111 @@ data = Client(email=os.environ["IC_DATA_EMAIL"], password=os.environ["IC_DATA_PA
|
|
|
101
101
|
- `client.logout()` signs out and **ends every session of that user, including the web app**. The SDK never calls it by itself.
|
|
102
102
|
- Sign-in returning `mfa_required` raises `MfaRequiredError`: "Integration users need MFA off for their company. API keys arrive in December 2026."
|
|
103
103
|
|
|
104
|
-
##
|
|
104
|
+
## Account layer: `client.accounts` (admin)
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
A customer is one company with one or more **teams** (each a location in the API) and a **Management** location named `<Company> - Management`.
|
|
107
|
+
|
|
108
|
+
- 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).
|
|
109
|
+
- 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.
|
|
110
|
+
- 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.
|
|
107
111
|
|
|
108
112
|
```python
|
|
109
|
-
from intelligence_cloud import
|
|
113
|
+
from intelligence_cloud import (AlertSetting, AlertSettings, Client, ConnectorSpec, CustomerSpec,
|
|
114
|
+
PersonSpec, TeamSpec)
|
|
110
115
|
|
|
111
116
|
admin = Client(email=..., password=...)
|
|
117
|
+
phone_system = ConnectorSpec.netsapiens("https://pbx.example.com/ns-api/v2", "riverbend.example.com",
|
|
118
|
+
api_key=phone_system_key)
|
|
112
119
|
|
|
113
|
-
customer = admin.
|
|
120
|
+
customer = admin.accounts.create_customer(CustomerSpec(
|
|
114
121
|
company_id=saved_company_id, # None the first time; store customer.company_id and pass it on re-runs
|
|
115
|
-
company_name="Riverbend
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
company_name="Riverbend Dental",
|
|
123
|
+
admin=PersonSpec("pat.lee@example.com", "Pat", "Lee", phone_number="+15555550100"),
|
|
124
|
+
team=TeamSpec(name="Riverbend - Main", street="1 River Rd", city="Springfield", state="IL",
|
|
125
|
+
country="US", zipcode="62701", vertical="<vertical id or key>"),
|
|
126
|
+
connector=phone_system, # used for the team and for Management
|
|
127
|
+
alerts=AlertSettings(customer_threat=AlertSetting(phrases=threat_phrases),
|
|
128
|
+
upset_customer=AlertSetting(phrases=upset_phrases)),
|
|
120
129
|
mfa_off=True, # the company has an integration user
|
|
121
|
-
connector=ConnectorSpec(api_url="https://pbx.example.com/ns-api/v2",
|
|
122
|
-
domain="riverbend.example.com", api_key=phone_system_key),
|
|
123
|
-
sso_domain="riverbend.example.com", # optional: returns the DNS TXT record to publish
|
|
124
130
|
))
|
|
131
|
+
team = customer.teams[0]
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
admin.
|
|
128
|
-
|
|
129
|
-
admin.
|
|
133
|
+
admin.accounts.add_base_user(customer, PersonSpec("sam.ortiz@example.com", "Sam", "Ortiz"), team=team, line="2101")
|
|
134
|
+
admin.accounts.add_base_manager(customer, PersonSpec("dana.cho@example.com", "Dana", "Cho"),
|
|
135
|
+
teams=[team], line="2001")
|
|
136
|
+
admin.accounts.activate_alerts(customer) # once each team has a manager in its alert groups
|
|
130
137
|
```
|
|
131
138
|
|
|
132
|
-
- **
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
+
- **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 `"customer_threat"` and `"upset_customer"`, and `set_alerts` creates those alerts when the lists arrive.
|
|
140
|
+
- **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 `company_id` 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 raised before anything is written.
|
|
141
|
+
- **Stops are reported.** A helper that fails part-way raises `AccountError` with `.step`, `.result` (so far) and `.cause`. Run it again with the same input to continue; `change_license` and `move_user` also recognise a person they left part-way. A connector that does not become active stops `create_customer`, `add_team` and `set_connector` at the end, once everything else is built: `.step` is `"connectors"` and `.cause` is `ConnectorTimeoutError` or `ConnectorError` (with `state_reason`).
|
|
142
|
+
- **Existing people keep their license.** `add_base_user`, `add_base_manager` and `add_integration_user` refuse (`InvalidRequestError`, before any write) a person already set up with another license; use `change_license`.
|
|
143
|
+
- **Alerts start switched off.** `activate_alerts` switches them on for every team. A team does not need a manager: its alerts then show in the app only, and the result lists it.
|
|
144
|
+
- **Alert email is off** for every person the helpers create, managers included. People switch it on in their own settings.
|
|
145
|
+
- **Insights Hub "monitor all numbers" stays off.** The helpers never switch it on and switch it off where they find it on.
|
|
146
|
+
- **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; `send_invitations` sends it later).
|
|
147
|
+
- **Connectors.** `ConnectorSpec(type, config, name=None, timeout=600)` takes the phone platform as the API names it and that platform's own settings; `ConnectorSpec.netsapiens(api_url, domain, api_key)` 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, logged or shown when the object is printed (any setting whose name contains key, secret, token, password, pwd, credential or auth is hidden, at any depth). A new connector is checked every 10 seconds until it settles; its status is recorded on the team (`connector_status`, `connector_state_reason`). A re-run with a corrected key repairs a connector in `error`; it never creates a second one.
|
|
148
|
+
|
|
149
|
+
| Helper | Does | Returns |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `create_customer(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` |
|
|
152
|
+
| `get_customer(company_id)` | Reads the layout back; a layout it does not recognise is listed in `pending` | `Customer` |
|
|
153
|
+
| `add_team(customer, team, connector, *, alerts=None)` | A further team with its connector, groups, alerts (copying the first team's phrases and levels unless `alerts` sets them) and Insights Hub | `Team` |
|
|
154
|
+
| `set_alerts(customer, alerts, *, team=None)` | Phrases and sentiment levels on one team or all; `None` keeps what is there; alerts keep their on or off state | rule ids changed |
|
|
155
|
+
| `set_connector(customer, connector, *, team=None)` | Attaches a phone system to the named team, or the first team and Management; refuses where an active one exists | `list[Team]` |
|
|
156
|
+
| `add_base_user(customer, person, *, team, line, invite=True)` | After Call, their line on the team's connector, First Alert and Insights Hub lists and the team's managers | `Member` |
|
|
157
|
+
| `add_base_manager(customer, person, *, teams, line=None, company_reports=False, invite=True)` | All three products on each team and Management, own line at Management, the teams' lines and groups; `company_reports=True` adds the company-wide reports group | `Member` |
|
|
158
|
+
| `add_integration_user(customer, person)` | A data-reading user across every team: password sign-in, tagged `department: "integration"`, every line | `Member` |
|
|
159
|
+
| `change_license(customer, user_id, to, *, teams=None, line=None)` | `"base_manager"` or `"base_user"`, moving their own line between the team and Management | `Member` |
|
|
160
|
+
| `move_user(customer, user_id, *, from_team, to_team)` | Moves a Base User's membership and line, or swaps one of a manager's teams; call history stays with the old team | `Member` |
|
|
161
|
+
| `change_line(customer, user_id, 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` |
|
|
162
|
+
| `remove_user(customer, user_id, *, keep_lines=False)` | Clears groups and lines, then deactivates; `notes` names teams left with no manager in an alert group (alerts are not changed) | summary |
|
|
163
|
+
| `activate_alerts(customer, *, team=None)` | Switches alerts on for every team. Returns a dict: `switched_on` (rule ids) and `no_manager` (teams whose alert groups have no manager, so their alerts show in the app only) | `{"switched_on", "no_manager"}` |
|
|
164
|
+
| `send_invitations(customer, *, user_ids=None)` | Sends invitations not yet sent or expired; re-sends to `user_ids` | user ids |
|
|
165
|
+
| `list_members(customer, *, license=None, team=None)` | Everyone, with license (`base_user`, `base_manager`, `integration`, `other`), teams and lines | `list[Member]` |
|
|
166
|
+
| `license_report(customer)` | People by license and the number of teams (Management not counted) | counts and members |
|
|
167
|
+
| `sync_lines(customer, *, dry_run=False)` | 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 |
|
|
168
|
+
| `offboard_customer(customer, *, deactivate_company=True)` | Pauses webhooks, stops every connector, deactivates integration users and the company | summary |
|
|
169
|
+
|
|
170
|
+
Every helper that takes `customer` also takes a company id. `team` is a `Team`, its location id or its name. Lines need an **active** connector: a refused mapping raises `AccountError` whose `.cause` is `ExtensionMappingError`, and no invitation is sent. An extension belongs to one location only: a clash raises `ConflictError` with the message "Extension is already monitored at another location."
|
|
171
|
+
|
|
172
|
+
## Conversation layer: `client.conversations` (user login)
|
|
173
|
+
|
|
174
|
+
Sign in as the person. The platform decides what each call returns: a Base User gets their own calls, a Base Manager their teams'.
|
|
139
175
|
|
|
140
|
-
|
|
176
|
+
```python
|
|
177
|
+
me = Client(email=..., password=...)
|
|
178
|
+
|
|
179
|
+
for brief in me.conversations.calls(): # today, newest first
|
|
180
|
+
print(brief) # CallBrief(id=..., when=...): no content
|
|
181
|
+
history = me.conversations.caller_history("5555550142", limit=5)
|
|
182
|
+
detail = me.conversations.brief(call_id) # summary, key points, tasks, sentiment, topics, alerts
|
|
183
|
+
tasks = me.conversations.open_tasks()
|
|
184
|
+
board = me.conversations.team_view(team_id) # for a manager: counts, alerts, open tasks, briefs
|
|
185
|
+
```
|
|
141
186
|
|
|
142
|
-
|
|
|
143
|
-
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
153
|
-
| `
|
|
154
|
-
| `
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
187
|
+
| Helper | Returns | Limits |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `me()`, `teams()` | Who is signed in and the teams they can see. `me().lines` is `None`: the API gives a user login no way to read its own lines | |
|
|
190
|
+
| `calls(*, day=None, since=None, until=None, team=None, number=None, search=None, limit=50)` | `list[CallBrief]`, newest first; default today | window at most 31 days, `limit` at most 200 |
|
|
191
|
+
| `brief(call_id)` | 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 |
|
|
192
|
+
| `transcript(call_id)` | The transcript of one call | one call per request |
|
|
193
|
+
| `recording_link(call_id)` | A `RecordingLink` that expires; the SDK never downloads the audio | |
|
|
194
|
+
| `caller_history(number, *, limit=10)` | Recent briefs for one caller (last 31 days) | `limit` at most 50 |
|
|
195
|
+
| `open_tasks(*, due=None, team=None)` | Open tasks with the id of the call each came from | up to 200 |
|
|
196
|
+
| `alerts(*, since=None, until=None, team=None, limit=50)` | `list[AlertBrief]` on this person's teams. `status=` raises `InvalidRequestError` and `holder` is `None`: the API has no alert status or holder yet | as `calls` |
|
|
197
|
+
| `alert(alert_id)` | One alert with its call brief | |
|
|
198
|
+
| `team_view(team, *, day=None, since=None, until=None)` | Counts, alerts, open tasks and briefs for one team | as `calls` |
|
|
199
|
+
| `topics(*, since=None, until=None, team=None)` | Topic volumes and rising topics (default last 7 days) | needs Insights Hub access |
|
|
200
|
+
| `reference(call_or_alert)` | The id and its page in the app, to pass to another system in place of content | |
|
|
201
|
+
| `parse_first_alert_event(payload)` | A `FirstAlertEvent` | |
|
|
202
|
+
|
|
203
|
+
- **Caller numbers are masked** to their last four digits (`***0142`) unless the client was created with `mask_numbers=False`, also where a number appears in a name. Extensions are shown as they are.
|
|
204
|
+
- **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.
|
|
205
|
+
- `<app>` is `https://app.intelligence.cloud` unless you pass your own address: `Client(app_url="https://...")`.
|
|
206
|
+
- **Limits are checked before any request**: a longer window, a larger limit, `number` with `search`, or a date without a time zone raises `InvalidRequestError`. "Today" and `day=` are midnight to midnight in this machine's time zone, daylight saving included.
|
|
207
|
+
- **Nothing is logged.** Printing a brief shows its id and time only. Keep summaries, names and numbers out of your own logs too.
|
|
208
|
+
- An administrator login raises `WrongLoginError`. There is no helper that walks every call; for a bounded daily job use `client.intelligence.iter_calls`.
|
|
159
209
|
|
|
160
210
|
## Quick start: conversation intelligence (frontline)
|
|
161
211
|
|
|
@@ -218,10 +268,11 @@ Every API operation is a method named after its `operationId` in snake case, gro
|
|
|
218
268
|
| `client.insights` | `get_insights_dashboard`, `list_topic_calls` / `iter_topic_calls` |
|
|
219
269
|
| `client.webhooks` | `get_after_call_webhook`, `save_after_call_webhook`, `test_after_call_webhook` |
|
|
220
270
|
| `client.intelligence` | `whoami`, `require_frontline`, `search_calls` / `iter_calls`, `get_call`, `get_transcript`, `get_recording_url`, `search_alerts` / `iter_alerts`, `get_alert(alert_id, with_call=False)`, `get_alerts_dashboard`, `list_tasks` / `iter_tasks`, `get_insights_dashboard`, `list_topic_calls` / `iter_topic_calls`, `get_after_call_webhook`, `set_after_call_webhook`, `test_after_call_webhook`, `get_first_alert_webhook`, `set_first_alert_webhook`, `test_first_alert_webhook` |
|
|
221
|
-
| `client.
|
|
271
|
+
| `client.accounts` | see "Account layer" |
|
|
272
|
+
| `client.conversations` | see "Conversation layer" |
|
|
222
273
|
| `client` | `login`, `logout`, `close` |
|
|
223
274
|
|
|
224
|
-
Module level: `parse_after_call_event`, `UnknownEvent`, `MAX_EVENT_BYTES`, `Deduplicator`, `FileTokenStore`, `unwrap`, `Page`, the error classes and the spec dataclasses.
|
|
275
|
+
Module level: `parse_after_call_event`, `parse_first_alert_event`, `UnknownEvent`, `MAX_EVENT_BYTES`, `mask_number`, `Deduplicator`, `FileTokenStore`, `unwrap`, `Page`, the error classes and the spec dataclasses.
|
|
225
276
|
|
|
226
277
|
### Rules the SDK applies for you
|
|
227
278
|
|
|
@@ -251,17 +302,20 @@ Log `status`, `code` and `request_id`, not exception text or response bodies. `s
|
|
|
251
302
|
| Error | When |
|
|
252
303
|
|---|---|
|
|
253
304
|
| `ApiError` | Any API error: `status`, `code`, `message`, `request_id` |
|
|
305
|
+
| `NetworkError` | The request did not complete (no connection, a timeout, an unreadable response): `status` 0, `code` `network_error` or `timeout`, `kind`. The HTTP library's own error is not attached, because it holds the request |
|
|
254
306
|
| `AuthError` (401), `PasswordExpiredError` | Sign-in failed, or the token could not be renewed |
|
|
255
307
|
| `NotFoundError` (404) | Not found, or outside what this login can see |
|
|
256
308
|
| `ConflictError` (409) | Duplicate name or email, already active or inactive, extension already monitored (`.extensions`) |
|
|
257
309
|
| `ValidationError` (400, 422) | Malformed request or refused value |
|
|
258
310
|
| `RateLimitError` (429) | Still rate limited after retries (`.retry_after`) |
|
|
259
|
-
| `InvalidRequestError` |
|
|
311
|
+
| `InvalidRequestError` | Bad input, refused by the SDK before sending |
|
|
260
312
|
| `MfaRequiredError` | The integration user's company has MFA on |
|
|
261
|
-
| `FrontlineRequiredError` |
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `
|
|
313
|
+
| `FrontlineRequiredError` | `client.intelligence` conversation data asked for with an admin login |
|
|
314
|
+
| `WrongLoginError` | An account helper with a user login, or a conversation helper with an administrator login; the message says which login to use |
|
|
315
|
+
| `AccountError` | An account helper stopped part-way (`.step`, `.result`, `.cause`); run it again to continue |
|
|
316
|
+
| `ConnectorError`, `ConnectorTimeoutError` | A connector ended in `error`, or a new connector did not settle in time |
|
|
317
|
+
| `ExtensionMappingError` | A helper could not map numbers (`.user_id`, `.cause`); the `.cause` of an `AccountError` |
|
|
318
|
+
| `WebhookPayloadError` | A webhook body is not JSON, or is a malformed After Call or First Alert event (answer 400) |
|
|
265
319
|
| `PayloadTooLargeError` | A webhook body is over `max_bytes` (256 KB; answer 413) |
|
|
266
320
|
|
|
267
321
|
All derive from `IntelligenceCloudError`.
|
|
@@ -353,15 +407,18 @@ def after_call(token):
|
|
|
353
407
|
|
|
354
408
|
### Receive First Alert
|
|
355
409
|
|
|
356
|
-
The First Alert webhook posts the alert that fired: the alert id, the rule, the location, the call and the time.
|
|
410
|
+
The First Alert webhook posts the alert that fired: the alert id, the rule, the location, the call and the time. `parse_first_alert_event` returns a `FirstAlertEvent` (`alert_id`, and `rule`, `location_id`, `call_id`, `timestamp` when the delivery carries them). Take the alert id, answer 2xx at once, then fetch the alert and its call with a frontline integration user in every alert group:
|
|
357
411
|
|
|
358
412
|
```python
|
|
359
413
|
@app.post("/ic/alerts/{token}")
|
|
360
414
|
async def first_alert(token: str, request: Request, background: BackgroundTasks):
|
|
361
415
|
if not hmac.compare_digest(token.encode(), ALERT_TOKEN.encode()): # IC_ALERT_WEBHOOK_TOKEN, 32+ characters
|
|
362
416
|
raise HTTPException(status_code=404)
|
|
363
|
-
|
|
364
|
-
|
|
417
|
+
try:
|
|
418
|
+
alert_id = parse_first_alert_event(await request.body()).alert_id
|
|
419
|
+
except PayloadTooLargeError:
|
|
420
|
+
raise HTTPException(status_code=413)
|
|
421
|
+
except WebhookPayloadError:
|
|
365
422
|
raise HTTPException(status_code=400)
|
|
366
423
|
if not alert_dedup.is_duplicate(alert_id): # a second Deduplicator, keyed on the alert id
|
|
367
424
|
background.add_task(handle_alert, alert_id)
|
|
@@ -389,7 +446,8 @@ Alerts are dated by their call, so start the window 30 minutes before the receiv
|
|
|
389
446
|
|---|---|---|
|
|
390
447
|
| `examples/whoami.py` | Sign in and print the role | any |
|
|
391
448
|
| `examples/export_calls.py` | Export yesterday's calls to CSV (ids, dates, sentiment, duration) | frontline |
|
|
392
|
-
| `examples/
|
|
449
|
+
| `examples/create_customer.py` | Create a customer, add a Base User and a Base Manager, switch the alerts on (dry run unless `--apply`; phrase lists from the files in `IC_THREAT_PHRASES_FILE` and `IC_UPSET_PHRASES_FILE`, optional) | admin |
|
|
450
|
+
| `examples/my_day.py` | A person's day: today's call briefs, open tasks and alerts, with masked numbers and no content in logs | frontline (the person's own login) |
|
|
393
451
|
| `examples/webhook_receiver.py` | A dependency-free After Call webhook receiver: 256 KB cap, a persistent queue keyed on `call.id`, a worker that reads each call (`--self-test` to try it offline) | frontline (worker) |
|
|
394
452
|
| `examples/after-call-sample.json` | A sample After Call event for local tests | none |
|
|
395
453
|
| `examples/alert_webhook_receiver.py` | A dependency-free First Alert webhook receiver that fetches each alert and its call (`--self-test` to try it offline) | frontline |
|