intelligence-cloud 0.1.1__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.
Files changed (47) hide show
  1. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/CHANGELOG.md +38 -0
  2. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/PKG-INFO +119 -61
  3. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/README.md +118 -60
  4. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/_common.py +1 -1
  5. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/alert_webhook_receiver.py +1 -1
  6. intelligence_cloud-0.2.0/examples/create_customer.py +68 -0
  7. intelligence_cloud-0.2.0/examples/my_day.py +33 -0
  8. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/pyproject.toml +1 -1
  9. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/__init__.py +38 -15
  10. intelligence_cloud-0.2.0/src/intelligence_cloud/_version.py +1 -0
  11. intelligence_cloud-0.2.0/src/intelligence_cloud/accounts.py +1958 -0
  12. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/client.py +43 -9
  13. intelligence_cloud-0.2.0/src/intelligence_cloud/conversations.py +529 -0
  14. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/data/spec.json +2 -0
  15. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/errors.py +51 -4
  16. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/receiver.py +85 -1
  17. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/resources.py +10 -4
  18. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/live/test_live.py +248 -112
  19. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/unit/fake_api.py +147 -18
  20. intelligence_cloud-0.2.0/tests/unit/test_accounts.py +629 -0
  21. intelligence_cloud-0.2.0/tests/unit/test_conversations.py +203 -0
  22. intelligence_cloud-0.2.0/tests/unit/test_review2.py +197 -0
  23. intelligence_cloud-0.2.0/tests/unit/test_review_fixes.py +549 -0
  24. intelligence_cloud-0.1.1/examples/provision_seat.py +0 -48
  25. intelligence_cloud-0.1.1/src/intelligence_cloud/_version.py +0 -1
  26. intelligence_cloud-0.1.1/src/intelligence_cloud/workflows.py +0 -791
  27. intelligence_cloud-0.1.1/tests/unit/test_review2.py +0 -408
  28. intelligence_cloud-0.1.1/tests/unit/test_workflows.py +0 -369
  29. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/.gitignore +0 -0
  30. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/CONTRIBUTING.md +0 -0
  31. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/LICENSE +0 -0
  32. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/SECURITY.md +0 -0
  33. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/after-call-sample.json +0 -0
  34. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/export_calls.py +0 -0
  35. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/webhook_receiver.py +0 -0
  36. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/examples/whoami.py +0 -0
  37. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_base.py +0 -0
  38. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_generated.py +0 -0
  39. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/_spec.py +0 -0
  40. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/auth.py +0 -0
  41. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/intelligence.py +0 -0
  42. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/src/intelligence_cloud/py.typed +0 -0
  43. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/__init__.py +0 -0
  44. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/unit/__init__.py +0 -0
  45. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/unit/test_client.py +0 -0
  46. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tests/unit/test_intelligence.py +0 -0
  47. {intelligence_cloud-0.1.1 → intelligence_cloud-0.2.0}/tools/generate.py +0 -0
@@ -1,5 +1,43 @@
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.
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
+
3
41
  ## 0.1.1 (2026-11-29)
4
42
 
5
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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: intelligence-cloud
3
- Version: 0.1.1
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
- - **Customer lifecycle** with admin credentials (a reseller admin login): companies, locations, users, products, connectors, First Alert, Insights Hub, and the Base Intelligence Seat workflows.
45
- - **Conversation intelligence** with frontline credentials (a frontline user login): calls, transcripts, recordings, alerts, tasks, insights, and the After Call webhook.
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.1.1. Python 3.10 or later. One dependency: `httpx` (0.27 or later).
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 `provision_seat_customer`, or `PATCH /companies/{id}` with `mfa_enforced: false`). **API keys arrive in December 2026.**
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`, ... and `client.workflows` |
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
- ## Quick start: customer lifecycle (admin)
104
+ ## Account layer: `client.accounts` (admin)
105
105
 
106
- Provision a Base Intelligence Seat customer: one location, After Call for end users, First Alert and Insights Hub for managers, the "Upset Customer" and "Customer Threat" alerts routed to "Manager Alerts", and an "Insights Hub Access" group.
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 Client, SeatCustomerSpec, LocationSpec, ConnectorSpec, UserSpec
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.workflows.provision_seat_customer(SeatCustomerSpec(
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 Auto Group",
116
- admin_name="Pat Lee", admin_email="pat.lee@example.com", admin_phone="+15555550100",
117
- location=LocationSpec(name="Riverbend - Main", street="1 River Rd", city="Springfield",
118
- state="IL", country="US", zipcode="62701", vertical="<vertical id or key>"),
119
- threat_phrases=customer_threat_phrases, # from your Tresic contact
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
- # End users first: each line is mapped, then the invitation is emailed.
127
- admin.workflows.add_frontline_user(customer, UserSpec("sam.ortiz@example.com", "Sam", "Ortiz"), "2101")
128
- # The first manager switches the two alerts on, then gets the invitation.
129
- admin.workflows.add_manager(customer, UserSpec("dana.cho@example.com", "Dana", "Cho"))
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
- - **Customer Threat phrases are provided by your Tresic contact.** Pass them as `threat_phrases`. Creating the Customer Threat alert without them raises `InvalidRequestError`.
133
- - The primary contact (`admin_email`) is always invited as customer admin by email.
134
- - Every workflow can be run again. **Store `customer.company_id` and pass it as `company_id` on every re-run.** Without it, a company with the same name is used only when its primary contact email is `admin_email`; any other company with that name raises `ConflictError` (code `company_name_conflict`) before anything is written. The location, groups and rules are found by name, users by email, and the connector by its phone-system domain. A company or location found inactive raises unless `reactivate=True`.
135
- - Both alert rules are created **switched off**. `add_manager` switches them on once the manager is set up (`activate_alerts=True`, the default). To switch them on yourself, pass `activate_alerts=False` and call `activate_seat_alerts(customer)` when you are ready. Re-running `provision_seat_customer` never switches a rule off.
136
- - Users are created **without** an invitation. The workflow maps their lines and sets their products and groups, and only then emails the invitation. If a mapping is refused, `ExtensionMappingError` is raised and no invitation has been sent. Pass `UserSpec(..., send_invitation=False)` to invite later with `admin.users.resend_invitation(company_id, user_id)`.
137
- - The connector connects in the background. The workflow checks it every 10 seconds, for up to 10 minutes (`ConnectorSpec(timeout=...)`), until it is `active` or `error`, and records `connector_status` and `connector_state_reason` on the result. A key that cannot create call subscriptions ends in `error` / `invalid_permissions`: use a read/write key. Re-run the workflow with the corrected key: a connector found in `error`, stopped, or with changed settings is updated with the settings you pass and restarted, never duplicated.
138
- - Get the customer object back later with `admin.workflows.get_seat_customer(company_id)`.
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
- ### Seat workflows
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
- | Method | Does |
143
- |---|---|
144
- | `provision_seat_customer(spec)` | Company, MFA off (optional), products, location, groups, both rules (switched off), connector (optional), Insights Hub access, SSO domain claim (optional). Returns `SeatCustomer` with every id. |
145
- | `get_seat_customer(company_id)` | Rebuilds `SeatCustomer` from what is configured. |
146
- | `add_frontline_user(customer, user, extension)` | Creates an end user (no invitation yet) with After Call on their own line and alert email off, maps the line, adds it to every manager, First Alert and Insights Hub, then emails the invitation. |
147
- | `add_manager(customer, user, *, activate_alerts=True)` | Creates a manager (no invitation yet) with all three products, both groups and alert email on, maps all end-user lines at the location, switches both alerts on, then emails the invitation. The manager's own phone line is not captured on the Seat: it is never mapped, nor added to First Alert or Insights Hub. |
148
- | `activate_seat_alerts(customer)` | Switches on the Upset Customer and Customer Threat rules. Returns the ids it switched on. |
149
- | `change_user_extension(customer, user_id, old, new)` | Moves an end user's line: their mapping, every manager, First Alert, Insights Hub. |
150
- | `add_integration_user(customer, user)` | Creates the customer's integration (data-reading) user: password sign-in, tagged `department: "integration"`, all three products, both groups, alert email off, every line. Never counted as a seat or manager; later end users' lines are added to it. Invitation last. |
151
- | `remove_user(customer, user_id, keep_extensions=False)` | Removes the user from groups, clears their numbers, then deactivates. Only an end user's line is released, and only when no other end user holds it: it comes off managers, integration users, First Alert and Insights Hub (unless kept). Removing a manager, an integration user or anyone holding several lines never takes a line off anyone else. |
152
- | `list_frontline_users(customer)` / `list_managers(customer)` / `list_integration_users(customer)` | The location's users, classified: end users have After Call only; managers have all three products; integration users are tagged `department: "integration"`. |
153
- | `sync_numbers(customer, dry_run=False)` | Recomputes the location's lines (each end user's single extension) and pushes them to managers, integration users, First Alert and Insights Hub. Managers and integration users end up with exactly the lines; any other number on their mapping is removed. `dry_run=True` returns the changes only. |
154
- | `offboard_customer(customer, deactivate_company=True)` | A customer leaves: pauses the After Call webhook, clears the First Alert webhook, stops the connector, deactivates the integration users, then deactivates the company. Safe to run again. |
155
-
156
- To keep a user out of every workflow (for example a person you manage by hand), list them in `customer.exclude_user_ids` or `customer.exclude_emails`.
157
-
158
- Number mappings need an **active** connector. When a mapping is refused, the workflow raises `ExtensionMappingError` with `user_id` set: the user exists but has not been invited, and you run the workflow again once the connector is active. The re-run finds the user, finishes the setup and emails the invitation. A re-run also re-sends the invitation to any user who has not accepted one yet. An extension can belong to one location only: a conflict raises `ConflictError` with the message "Extension is already monitored at another location." and the clashing numbers in `.extensions`.
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.workflows` | see "Seat workflows" |
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` | Refused by the SDK before sending |
311
+ | `InvalidRequestError` | Bad input, refused by the SDK before sending |
260
312
  | `MfaRequiredError` | The integration user's company has MFA on |
261
- | `FrontlineRequiredError` | Conversation data asked for with an admin login |
262
- | `ConnectorError`, `ConnectorTimeoutError` | A connector ended in `error`, or did not finish in time |
263
- | `ExtensionMappingError` | A workflow could not map numbers (`.user_id`, `.cause`) |
264
- | `WebhookPayloadError` | A webhook body is not JSON, or is a malformed After Call event (answer 400) |
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. Read only the alert id, answer 2xx at once, then fetch the alert and its call with a frontline integration user in Manager Alerts:
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
- alert_id = alert_id_from(await request.body()) # see examples/alert_webhook_receiver.py
364
- if alert_id is None:
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/provision_seat.py` | Provision a Seat customer and add an end user and a manager (dry run unless `--apply`; phrases from the file in `IC_THREAT_PHRASES_FILE`) | admin |
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 |