@aiqa/sdk 2.5.0-develop.1 → 3.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,8 +129,6 @@ going so far.
129
129
  client_name: string;
130
130
  client_phone_number: string;
131
131
  agent_id: string;
132
- agent_first_name: string;
133
- agent_last_name: string;
134
132
  external_status?: string;
135
133
  verification?: ApplicationVerificationSummary;
136
134
  }
@@ -138,11 +136,11 @@ going so far.
138
136
 
139
137
  Wait for the `authenticated` event before calling it: until authentication
140
138
  has completed, and whenever the connection is down, it **rejects**.
141
- `client_name`, `client_phone_number` and `agent_id` normally carry any change
142
- you made with `updateConversation()` earlier in the call — see
139
+ `agent_id` is the advisor's AIQA user id, the value `updateConversation()`
140
+ returns as `conversation.advisor_id`. `client_name`,
141
+ `client_phone_number` and `agent_id` normally carry any change you made with
142
+ `updateConversation()` earlier in the call — see
143
143
  [Reading `verification`](#reading-verification) for the exception.
144
- `agent_first_name` and `agent_last_name` come back empty; use
145
- `updateConversation({ agentName })` if you need to record an agent's name.
146
144
  `external_status` is the value you last sent with
147
145
  `updateConversation({ externalStatus })`, lowercased — one of
148
146
  [`ExternalStatus`](#externalstatus) — and is **missing** until you send one.
@@ -228,50 +226,48 @@ change.
228
226
 
229
227
  - `input: UpdateConversationInput` - partial set of conversation fields to update
230
228
 
231
- | field | type | max | notes |
232
- | --------------------------- | ---------- | -------- | ----------------------------------------------------------------------- |
233
- | `policyNumber` | `string` | 128 | |
234
- | `insuredPhone` | `string` | 32 | the insured, who may differ from the caller |
235
- | `clientName` | `string` | 128 | |
236
- | `clientPhone` | `string` | 32 | |
237
- | `clientEmail` | `string` | 254 | must be a valid email address |
238
- | `clientId` | `string` | 64 | your own CRM identifier |
239
- | `agentId` | `string` | 64 | the agent's AIQA user id; used instead of `agentEmail` if both are sent |
240
- | `agentEmail` | `string` | 254 | valid email; alternative to `agentId` |
241
- | `agentName` | `string` | 128 | |
242
- | `advisorId` / `advisorName` | `string` | 64/128 | |
243
- | `agentGroups` | `string[]` | 32 × 128 | entries cannot contain a comma |
244
- | `externalStatus` | `string` | — | see [`ExternalStatus`](#externalstatus) |
229
+ | field | type | max | notes |
230
+ | ---------------- | ---------- | -------- | --------------------------------------------------------------------------------------------------------------- |
231
+ | `policyNumber` | `string` | 128 | |
232
+ | `insuredPhone` | `string` | 32 | the insured, who may differ from the caller |
233
+ | `clientName` | `string` | 128 | |
234
+ | `clientPhone` | `string` | 32 | |
235
+ | `clientEmail` | `string` | 254 | must be a valid email address |
236
+ | `clientId` | `string` | 64 | your own CRM identifier |
237
+ | `advisorId` | `string` | 64 | the advisor's AIQA user id; used instead of `advisorEmail` if both are sent; a longer id goes in `advisorEmail` |
238
+ | `advisorEmail` | `string` | 254 | email of the advisor's AIQA user; AIQA links the call to that user |
239
+ | `agentGroups` | `string[]` | 32 × 128 | entries cannot contain a comma |
240
+ | `externalStatus` | `string` | — | see [`ExternalStatus`](#externalstatus) |
245
241
 
246
242
  Every string (including each `agentGroups` entry) must be non-empty;
247
243
  surrounding whitespace is trimmed first, so a value of only spaces is
248
244
  rejected. `null` is rejected — omit the field instead. At least one field is
249
245
  required, and any field not in the table is rejected.
250
246
 
251
- **Agent identification**
247
+ **Advisor identification**
252
248
 
253
- | sent | conversation's agent | `conversation.agent_id` | `warnings` |
254
- | ------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------- | -------------------------- |
255
- | `agentId` | set to `agentId` | `agentId` | — |
256
- | `agentId` + `agentEmail` | set to `agentId` | `agentId` (`agentEmail` is ignored) | — |
257
- | `agentEmail`, a user matches | set to that user | the user's AIQA user id: their email in lowercase (compare it to what you sent ignoring case) | — |
258
- | `agentEmail`, no user matches | unchanged | absent | `agent_not_found` |
259
- | `agentEmail`, temporarily not checked | unchanged | absent | `agent_lookup_unavailable` |
260
- - `conversation` never contains `agentEmail`.
249
+ | sent | conversation's advisor | `conversation.advisor_id` | `warnings` |
250
+ | --------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------- | ---------------------------- |
251
+ | `advisorId` | set to `advisorId` | `advisorId` | — |
252
+ | `advisorId` + `advisorEmail` | set to `advisorId` | `advisorId` (`advisorEmail` is ignored) | — |
253
+ | `advisorEmail`, a user matches | set to that user | the user's AIQA user id: their email in lowercase (compare it to what you sent ignoring case) | — |
254
+ | `advisorEmail`, no user matches | unchanged | absent | `advisor_not_found` |
255
+ | `advisorEmail`, temporarily not checked | unchanged | absent | `advisor_lookup_unavailable` |
256
+ - The result never includes the email you sent; a matched user comes back as their id in `advisor_id`.
261
257
  - With a warning, `success` is `true` and every other field you sent is saved.
262
- - After `agent_lookup_unavailable`, call `updateConversation({ agentEmail })` again later. You do not need to resend the other fields.
258
+ - After `advisor_lookup_unavailable`, call `updateConversation({ advisorEmail })` again later. You do not need to resend the other fields.
263
259
 
264
260
  **Returns:**
265
261
 
266
262
  - `Promise<UpdateConversationResult>`
267
- - `conversation`: only the fields you sent; a matched `agentEmail` comes back as `agent_id`.
263
+ - `conversation`: only the fields you sent; a matched `advisorEmail` comes back as `advisor_id`.
268
264
  - `warnings`: present only when part of the update was not applied.
269
265
 
270
266
  ```typescript
271
267
  const result = await sdk.updateConversation({
272
268
  policyNumber: "POL-123",
273
269
  clientEmail: "jane@example.com",
274
- agentEmail: "vio.agent@example.com",
270
+ advisorEmail: "advisor@example.com",
275
271
  externalStatus: ExternalStatus.COMPLETED,
276
272
  });
277
273
  console.log(result.success, result.conversation.policy_number);
@@ -524,7 +520,7 @@ on the `FACT_VERIFIED` broadcast event before the Promise resolves:
524
520
 
525
521
  ```
526
522
  processing
527
- └─> awaiting_question (agent hasn't asked yet)
523
+ └─> awaiting_question (advisor hasn't asked yet)
528
524
  └─> awaiting_answer (asked, customer hasn't answered yet)
529
525
  └─> partial (partial evidence — e.g. "305" of "30521")
530
526
  └─> pending_confirmation_matched
@@ -563,9 +559,7 @@ type Application = {
563
559
  application_id: string;
564
560
  client_name: string;
565
561
  client_phone_number: string;
566
- agent_id: string;
567
- agent_first_name: string; // comes back empty
568
- agent_last_name: string; // comes back empty
562
+ agent_id: string; // the advisor's AIQA user id (conversation.advisor_id)
569
563
  // The externalStatus you last sent, lowercased. Missing until you send one
570
564
  // — not the same as "draft". Never in the authentication snapshot, so on the
571
565
  // fallback path below it is absent, not stale.
@@ -606,7 +600,7 @@ type ApplicationVerificationSummary = {
606
600
  count_pending: number;
607
601
 
608
602
  // Facts flagged as suspicious when the call is reviewed — for instance the
609
- // agent leading the customer to the expected answer. Independent of the
603
+ // advisor leading the customer to the expected answer. Independent of the
610
604
  // answer: a matched fact can be flagged. Reads 0 while the call is running.
611
605
  count_suspicious: number;
612
606
  };
@@ -663,7 +657,7 @@ interface AddFactResult {
663
657
  question_asked?: boolean;
664
658
 
665
659
  /**
666
- * How closely the agent's utterance matched the expected question, on a
660
+ * How closely the advisor's utterance matched the expected question, on a
667
661
  * 0–1 or a 0–100 scale. Higher is closer.
668
662
  */
669
663
  question_match_score?: number;
@@ -842,11 +836,8 @@ type UpdateConversationInput = {
842
836
  clientPhone?: string;
843
837
  clientEmail?: string;
844
838
  clientId?: string;
845
- agentId?: string; // or agentEmail
846
- agentEmail?: string; // or agentId
847
- agentName?: string;
848
- advisorId?: string;
849
- advisorName?: string;
839
+ advisorId?: string; // or advisorEmail
840
+ advisorEmail?: string; // or advisorId
850
841
  agentGroups?: string[];
851
842
  externalStatus?: ExternalStatus | (string & {});
852
843
  };
@@ -856,7 +847,7 @@ type UpdateConversationInput = {
856
847
 
857
848
  Returned by `updateConversation()`.
858
849
 
859
- - `conversation`: only the fields you sent; a matched `agentEmail` comes back as `agent_id`.
850
+ - `conversation`: only the fields you sent; a matched `advisorEmail` comes back as `advisor_id`.
860
851
  - `warnings`: present only when part of the update was not applied.
861
852
 
862
853
  ```typescript
@@ -869,10 +860,7 @@ type UpdateConversationResult = {
869
860
  client_phone?: string;
870
861
  client_email?: string;
871
862
  client_id?: string;
872
- agent_id?: string;
873
- agent_name?: string;
874
863
  advisor_id?: string;
875
- advisor_name?: string;
876
864
  agent_groups?: string[];
877
865
  external_status?: string;
878
866
  };
@@ -890,16 +878,16 @@ interface ConversationWarning {
890
878
  }
891
879
 
892
880
  type ConversationWarningCode =
893
- | "agent_not_found"
894
- | "agent_lookup_unavailable"
881
+ | "advisor_not_found"
882
+ | "advisor_lookup_unavailable"
895
883
  | (string & {});
896
884
  ```
897
885
 
898
- | `code` | meaning | conversation's agent | what to do |
899
- | -------------------------- | --------------------------------------------------------------- | -------------------- | ------------------------------------------------ |
900
- | `agent_not_found` | no AIQA user in your organization has the `agentEmail` | unchanged | check the email |
901
- | `agent_lookup_unavailable` | the `agentEmail` could not be checked at the moment (temporary) | unchanged | retry `updateConversation({ agentEmail })` later |
902
- | any other | added in a later version | — | log `message` and continue |
886
+ | `code` | meaning | conversation's advisor | what to do |
887
+ | ---------------------------- | ----------------------------------------------------------------- | ---------------------- | -------------------------------------------------- |
888
+ | `advisor_not_found` | no AIQA user in your organization has the `advisorEmail` | unchanged | check the email |
889
+ | `advisor_lookup_unavailable` | the `advisorEmail` could not be checked at the moment (temporary) | unchanged | retry `updateConversation({ advisorEmail })` later |
890
+ | any other | added in a later version | — | log `message` and continue |
903
891
 
904
892
  - Use `code` to choose what to do; do not parse `message`. `message` is human-readable, includes the email you sent, and may change.
905
893
  - `success` is `true` and every other field you sent is saved.
@@ -42,7 +42,7 @@ type ApplicationVerificationSummary = {
42
42
  count_pending: number;
43
43
  /**
44
44
  * Facts flagged as suspicious when the call is reviewed — for instance the
45
- * agent leading the customer to the expected answer. Independent of the
45
+ * advisor leading the customer to the expected answer. Independent of the
46
46
  * answer: a matched fact can be flagged. Reads 0 while the call is running.
47
47
  */
48
48
  count_suspicious: number;
@@ -51,11 +51,8 @@ type Application = {
51
51
  application_id: string;
52
52
  client_name: string;
53
53
  client_phone_number: string;
54
+ /** The advisor's AIQA user id; `updateConversation()` returns it as `conversation.advisor_id`. */
54
55
  agent_id: string;
55
- /** Comes back empty. Set an agent name with `updateConversation()`. */
56
- agent_first_name: string;
57
- /** Comes back empty. Set an agent name with `updateConversation()`. */
58
- agent_last_name: string;
59
56
  /**
60
57
  * The status you last reported with `updateConversation({ externalStatus })`,
61
58
  * folded to lowercase by the server. Missing when you never reported one —
@@ -110,18 +107,15 @@ type UpdateConversationInput = {
110
107
  clientPhone?: string;
111
108
  clientEmail?: string;
112
109
  clientId?: string;
113
- /** The agent's AIQA user id. Takes precedence over `agentEmail`. */
114
- agentId?: string;
115
- /** Email of the agent's AIQA user. Results: README, Agent identification. */
116
- agentEmail?: string;
117
- agentName?: string;
110
+ /** The advisor's AIQA user id. Takes precedence over `advisorEmail`. */
118
111
  advisorId?: string;
119
- advisorName?: string;
112
+ /** Email of the advisor's AIQA user. Results: README, Advisor identification. */
113
+ advisorEmail?: string;
120
114
  agentGroups?: string[];
121
115
  externalStatus?: ExternalStatus | (string & {});
122
116
  };
123
117
  /** Decide with `code`, not `message`. Codes: README, ConversationWarning. */
124
- type ConversationWarningCode = "agent_not_found" | "agent_lookup_unavailable" | (string & {});
118
+ type ConversationWarningCode = "advisor_not_found" | "advisor_lookup_unavailable" | (string & {});
125
119
  /** Part of an `updateConversation()` that was not applied; the rest was saved. */
126
120
  interface ConversationWarning {
127
121
  code: ConversationWarningCode;
@@ -137,10 +131,7 @@ type UpdateConversationResult = {
137
131
  client_phone?: string;
138
132
  client_email?: string;
139
133
  client_id?: string;
140
- agent_id?: string;
141
- agent_name?: string;
142
134
  advisor_id?: string;
143
- advisor_name?: string;
144
135
  agent_groups?: string[];
145
136
  external_status?: string;
146
137
  };
@@ -211,7 +202,7 @@ type QuestionStatus = "searching" | "asked" | "not_asked";
211
202
  * `processing`.
212
203
  *
213
204
  * - `processing` queued, or nothing to go on yet
214
- * - `awaiting_question` the agent hasn't asked the question yet
205
+ * - `awaiting_question` the advisor hasn't asked the question yet
215
206
  * - `awaiting_answer` asked, the customer hasn't answered yet
216
207
  * - `partial` partial evidence so far (e.g. "305" of "30521")
217
208
  * - `pending_confirmation_matched` a matching answer is held briefly in case
@@ -256,7 +247,7 @@ interface AddFactResult {
256
247
  is_valid_answer: boolean;
257
248
  question_asked?: boolean;
258
249
  /**
259
- * How closely the agent's utterance matched the expected question, on a 0–1
250
+ * How closely the advisor's utterance matched the expected question, on a 0–1
260
251
  * or a 0–100 scale. Higher is closer.
261
252
  */
262
253
  question_match_score?: number;
@@ -3406,7 +3406,7 @@ var compareVersions = (left, right) => {
3406
3406
  // package.json
3407
3407
  var package_default = {
3408
3408
  name: "@aiqa/sdk",
3409
- version: "2.4.0-develop.2",
3409
+ version: "2.5.0-develop.1",
3410
3410
  main: "dist/node/node.js",
3411
3411
  module: "dist/node/node.js",
3412
3412
  types: "dist/node/node.d.ts",
@@ -3770,8 +3770,18 @@ var AiQaSdk = class {
3770
3770
  return result && result.data !== void 0 ? result.data : result;
3771
3771
  }
3772
3772
  async updateConversation(input) {
3773
- const result = await this.sendMessage("UPDATE_CONVERSATION" /* UPDATE_CONVERSATION */, input);
3774
- return result && result.data !== void 0 ? result.data : result;
3773
+ const { advisorId, advisorEmail, ...fields } = input;
3774
+ const result = await this.sendMessage("UPDATE_CONVERSATION" /* UPDATE_CONVERSATION */, {
3775
+ ...fields,
3776
+ agentId: advisorId,
3777
+ agentEmail: advisorEmail
3778
+ });
3779
+ const data = result && result.data !== void 0 ? result.data : result;
3780
+ if (!data?.conversation || !("agent_id" in data.conversation)) {
3781
+ return data;
3782
+ }
3783
+ const { agent_id, ...conversation } = data.conversation;
3784
+ return { ...data, conversation: { ...conversation, advisor_id: agent_id } };
3775
3785
  }
3776
3786
  async authenticate() {
3777
3787
  try {