@aiqa/sdk 2.3.0-develop.1 → 2.3.0-develop.2

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
@@ -27,6 +27,7 @@ A TypeScript/JavaScript SDK for interacting with the AIQA WebSocket service. Thi
27
27
  - [ConversationLanguage](#conversationlanguage)
28
28
  - [UpdateConversationInput](#updateconversationinput)
29
29
  - [UpdateConversationResult](#updateconversationresult)
30
+ - [ConversationWarning](#conversationwarning)
30
31
  - [Examples](#examples)
31
32
  - [Error Handling](#error-handling)
32
33
  - [Version Requirements](#version-requirements)
@@ -226,36 +227,56 @@ change.
226
227
 
227
228
  - `input: UpdateConversationInput` - partial set of conversation fields to update
228
229
 
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
- | `agentId` / `agentName` | `string` | 64/128 | |
238
- | `advisorId` / `advisorName` | `string` | 64/128 | |
239
- | `agentGroups` | `string[]` | 32 × 128 | entries cannot contain a comma |
240
- | `externalStatus` | `string` | — | see [`ExternalStatus`](#externalstatus) |
230
+ | field | type | max | notes |
231
+ | --------------------------- | ---------- | -------- | ----------------------------------------------------------------------- |
232
+ | `policyNumber` | `string` | 128 | |
233
+ | `insuredPhone` | `string` | 32 | the insured, who may differ from the caller |
234
+ | `clientName` | `string` | 128 | |
235
+ | `clientPhone` | `string` | 32 | |
236
+ | `clientEmail` | `string` | 254 | must be a valid email address |
237
+ | `clientId` | `string` | 64 | your own CRM identifier |
238
+ | `agentId` | `string` | 64 | the agent's AIQA user id; used instead of `agentEmail` if both are sent |
239
+ | `agentEmail` | `string` | 254 | valid email; alternative to `agentId` |
240
+ | `agentName` | `string` | 128 | |
241
+ | `advisorId` / `advisorName` | `string` | 64/128 | |
242
+ | `agentGroups` | `string[]` | 32 × 128 | entries cannot contain a comma |
243
+ | `externalStatus` | `string` | — | see [`ExternalStatus`](#externalstatus) |
241
244
 
242
245
  Every string (including each `agentGroups` entry) must be non-empty;
243
246
  surrounding whitespace is trimmed first, so a value of only spaces is
244
247
  rejected. `null` is rejected — omit the field instead. At least one field is
245
248
  required, and any field not in the table is rejected.
246
249
 
250
+ **Agent identification**
251
+
252
+ | sent | conversation's agent | `conversation.agent_id` | `warnings` |
253
+ | ------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------- | -------------------------- |
254
+ | `agentId` | set to `agentId` | `agentId` | — |
255
+ | `agentId` + `agentEmail` | set to `agentId` | `agentId` (`agentEmail` is ignored) | — |
256
+ | `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) | — |
257
+ | `agentEmail`, no user matches | unchanged | absent | `agent_not_found` |
258
+ | `agentEmail`, temporarily not checked | unchanged | absent | `agent_lookup_unavailable` |
259
+ - `conversation` never contains `agentEmail`.
260
+ - With a warning, `success` is `true` and every other field you sent is saved.
261
+ - After `agent_lookup_unavailable`, call `updateConversation({ agentEmail })` again later. You do not need to resend the other fields.
262
+
247
263
  **Returns:**
248
264
 
249
- - `Promise<UpdateConversationResult>` - `conversation` echoes only the fields
250
- you sent.
265
+ - `Promise<UpdateConversationResult>`
266
+ - `conversation`: only the fields you sent; a matched `agentEmail` comes back as `agent_id`.
267
+ - `warnings`: present only when part of the update was not applied.
251
268
 
252
269
  ```typescript
253
270
  const result = await sdk.updateConversation({
254
271
  policyNumber: "POL-123",
255
272
  clientEmail: "jane@example.com",
273
+ agentEmail: "vio.agent@example.com",
256
274
  externalStatus: ExternalStatus.COMPLETED,
257
275
  });
258
276
  console.log(result.success, result.conversation.policy_number);
277
+ for (const warning of result.warnings ?? []) {
278
+ console.warn(warning.code, warning.message);
279
+ }
259
280
  ```
260
281
 
261
282
  ##### `ExternalStatus`
@@ -787,7 +808,8 @@ type UpdateConversationInput = {
787
808
  clientPhone?: string;
788
809
  clientEmail?: string;
789
810
  clientId?: string;
790
- agentId?: string;
811
+ agentId?: string; // or agentEmail
812
+ agentEmail?: string; // or agentId
791
813
  agentName?: string;
792
814
  advisorId?: string;
793
815
  advisorName?: string;
@@ -798,8 +820,10 @@ type UpdateConversationInput = {
798
820
 
799
821
  ### UpdateConversationResult
800
822
 
801
- Returned by `updateConversation()`. `conversation` echoes only the fields you
802
- sent.
823
+ Returned by `updateConversation()`.
824
+
825
+ - `conversation`: only the fields you sent; a matched `agentEmail` comes back as `agent_id`.
826
+ - `warnings`: present only when part of the update was not applied.
803
827
 
804
828
  ```typescript
805
829
  type UpdateConversationResult = {
@@ -818,9 +842,34 @@ type UpdateConversationResult = {
818
842
  agent_groups?: string[];
819
843
  external_status?: string;
820
844
  };
845
+ // Present only when part of the update was not applied.
846
+ warnings?: ConversationWarning[];
821
847
  };
822
848
  ```
823
849
 
850
+ ### ConversationWarning
851
+
852
+ ```typescript
853
+ interface ConversationWarning {
854
+ code: ConversationWarningCode;
855
+ message: string;
856
+ }
857
+
858
+ type ConversationWarningCode =
859
+ | "agent_not_found"
860
+ | "agent_lookup_unavailable"
861
+ | (string & {});
862
+ ```
863
+
864
+ | `code` | meaning | conversation's agent | what to do |
865
+ | -------------------------- | --------------------------------------------------------------- | -------------------- | ------------------------------------------------ |
866
+ | `agent_not_found` | no AIQA user in your organization has the `agentEmail` | unchanged | check the email |
867
+ | `agent_lookup_unavailable` | the `agentEmail` could not be checked at the moment (temporary) | unchanged | retry `updateConversation({ agentEmail })` later |
868
+ | any other | added in a later version | — | log `message` and continue |
869
+
870
+ - Use `code` to choose what to do; do not parse `message`. `message` is human-readable, includes the email you sent, and may change.
871
+ - `success` is `true` and every other field you sent is saved.
872
+
824
873
  ## Examples
825
874
 
826
875
  ### Complete Example: Recording Session
@@ -110,14 +110,24 @@ type UpdateConversationInput = {
110
110
  clientPhone?: string;
111
111
  clientEmail?: string;
112
112
  clientId?: string;
113
+ /** The agent's AIQA user id. Takes precedence over `agentEmail`. */
113
114
  agentId?: string;
115
+ /** Email of the agent's AIQA user. Results: README, Agent identification. */
116
+ agentEmail?: string;
114
117
  agentName?: string;
115
118
  advisorId?: string;
116
119
  advisorName?: string;
117
120
  agentGroups?: string[];
118
121
  externalStatus?: ExternalStatus | (string & {});
119
122
  };
120
- /** Only the fields you sent come back in `conversation`. */
123
+ /** Decide with `code`, not `message`. Codes: README, ConversationWarning. */
124
+ type ConversationWarningCode = "agent_not_found" | "agent_lookup_unavailable" | (string & {});
125
+ /** Part of an `updateConversation()` that was not applied; the rest was saved. */
126
+ interface ConversationWarning {
127
+ code: ConversationWarningCode;
128
+ message: string;
129
+ }
130
+ /** `conversation` holds the fields you sent; `warnings` only when part was not applied. */
121
131
  type UpdateConversationResult = {
122
132
  success: boolean;
123
133
  conversation: {
@@ -134,6 +144,7 @@ type UpdateConversationResult = {
134
144
  agent_groups?: string[];
135
145
  external_status?: string;
136
146
  };
147
+ warnings?: ConversationWarning[];
137
148
  };
138
149
  declare enum ConversationLanguage {
139
150
  EN = "en",
@@ -369,4 +380,4 @@ declare class AiQaSdk implements IAiqaSdk {
369
380
  private isManagerEvent;
370
381
  }
371
382
 
372
- export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, type ApplicationVerificationStatus, type ApplicationVerificationSummary, ConversationLanguage, type DialogAct, type DialogActConfidence, ExternalStatus, FactAnswerFormatType, type FactVerifiedPayload, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type Utterance, type VerificationStatus };
383
+ export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, type ApplicationVerificationStatus, type ApplicationVerificationSummary, ConversationLanguage, type ConversationWarning, type ConversationWarningCode, type DialogAct, type DialogActConfidence, ExternalStatus, FactAnswerFormatType, type FactVerifiedPayload, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type Utterance, type VerificationStatus };
@@ -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.2.0-develop.3",
3409
+ version: "2.3.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",