@aiqa/sdk 3.0.0 → 3.1.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 +91 -5
- package/dist/browser/browser.d.ts +40 -3
- package/dist/browser/browser.js +11 -1
- package/dist/browser/browser.js.map +1 -1
- package/dist/node/node.d.ts +40 -3
- package/dist/node/node.js +11 -1
- package/dist/node/node.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,8 @@ A TypeScript/JavaScript SDK for interacting with the AIQA WebSocket service. Thi
|
|
|
29
29
|
- [UpdateConversationInput](#updateconversationinput)
|
|
30
30
|
- [UpdateConversationResult](#updateconversationresult)
|
|
31
31
|
- [ConversationWarning](#conversationwarning)
|
|
32
|
+
- [UpsertAdvisorInput](#upsertadvisorinput)
|
|
33
|
+
- [UpsertAdvisorResult](#upsertadvisorresult)
|
|
32
34
|
- [Examples](#examples)
|
|
33
35
|
- [Error Handling](#error-handling)
|
|
34
36
|
- [Version Requirements](#version-requirements)
|
|
@@ -281,6 +283,42 @@ for (const warning of result.warnings ?? []) {
|
|
|
281
283
|
User-provided application status: `draft`, `pending`, `completed`, `expired`,
|
|
282
284
|
`closed`.
|
|
283
285
|
|
|
286
|
+
#### `upsertAdvisor()`
|
|
287
|
+
|
|
288
|
+
Creates an advisor in your organization, or updates the name of an existing
|
|
289
|
+
advisor with the same email. Then link the call to the advisor with
|
|
290
|
+
`updateConversation({ advisorEmail })`, passing the same email, or with
|
|
291
|
+
`updateConversation({ advisorId })`, passing the returned `advisor_id`.
|
|
292
|
+
|
|
293
|
+
**Parameters:**
|
|
294
|
+
|
|
295
|
+
- `input: UpsertAdvisorInput` - `advisorEmail`, `firstName` and `lastName`, all required
|
|
296
|
+
|
|
297
|
+
**Returns:**
|
|
298
|
+
|
|
299
|
+
- `Promise<UpsertAdvisorResult>`
|
|
300
|
+
|
|
301
|
+
| your organization has | result |
|
|
302
|
+
| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
303
|
+
| no user with that email | the advisor is created; `created: true` |
|
|
304
|
+
| an advisor with that email | its first and last name are updated; `created: false` |
|
|
305
|
+
| a user with that email who is not an advisor, such as an administrator | the user is not changed and keeps its own first and last name, which can differ from what you sent; `created: false`. You can still link the call to it with `advisorEmail` or `advisorId` |
|
|
306
|
+
|
|
307
|
+
- `advisor_id` is the email in lowercase.
|
|
308
|
+
- The Promise rejects when the advisor cannot be saved: invalid input (for
|
|
309
|
+
example, a malformed email), or, rarely, a different user in your
|
|
310
|
+
organization who already signs in with that email.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
const result = await sdk.upsertAdvisor({
|
|
314
|
+
advisorEmail: "advisor@example.com",
|
|
315
|
+
firstName: "Jane",
|
|
316
|
+
lastName: "Doe",
|
|
317
|
+
});
|
|
318
|
+
await sdk.updateConversation({ advisorEmail: "advisor@example.com" });
|
|
319
|
+
// or: await sdk.updateConversation({ advisorId: result.advisor.advisor_id });
|
|
320
|
+
```
|
|
321
|
+
|
|
284
322
|
### Fact Management
|
|
285
323
|
|
|
286
324
|
#### `addFact(fact)`
|
|
@@ -325,6 +363,13 @@ a timeout, a rejected payload.
|
|
|
325
363
|
answer_format: { type: "STRING" }
|
|
326
364
|
/** Optional (default: `false`). Use `true` when the fact was collected before the conversation started. It is stored, not verified. */
|
|
327
365
|
prefilled?: boolean
|
|
366
|
+
/**
|
|
367
|
+
* Optional. Use `true` for a value you already know is correct, such as data
|
|
368
|
+
* from your own records. Unlike `prefilled`, it is about trusting the value, not
|
|
369
|
+
* when it was collected. It is stored and visible to whoever reviews the call,
|
|
370
|
+
* never verified, and left out of the verification summary counts.
|
|
371
|
+
*/
|
|
372
|
+
reference?: boolean
|
|
328
373
|
/**
|
|
329
374
|
* Optional. Your own identifiers for this fact — a form field ID, a
|
|
330
375
|
* section name, anything that lets your UI map the result back to the
|
|
@@ -541,6 +586,12 @@ Rules:
|
|
|
541
586
|
- **Handle a `verification_status` you don't recognize as `processing`.**
|
|
542
587
|
- **A fact sent with `prefilled: true` is never verified**, so it gets no
|
|
543
588
|
`verification_status` and no `FACT_VERIFIED` event.
|
|
589
|
+
- **A fact sent with `reference: true` is never verified either.** Use it for
|
|
590
|
+
a value you already know is correct, such as the plan name from your own
|
|
591
|
+
records. It is stored, visible to whoever reviews the call, and left out of
|
|
592
|
+
the verification summary counts. `addFact()` still resolves, with
|
|
593
|
+
`is_valid_answer: false` and no `verification_status`, and no `FACT_VERIFIED`
|
|
594
|
+
event is emitted for it.
|
|
544
595
|
- **`pending_confirmation_*` is never final.** The answer can still change,
|
|
545
596
|
so don't show it as a decision.
|
|
546
597
|
- **A fact can be revised after `addFact()` has resolved.** If you keep its
|
|
@@ -791,6 +842,13 @@ type ApplicationFactInput = {
|
|
|
791
842
|
is_skipped?: boolean;
|
|
792
843
|
/** Optional (default: `false`). Use `true` when the fact was collected before the conversation started. It is stored, not verified. */
|
|
793
844
|
prefilled?: boolean;
|
|
845
|
+
/**
|
|
846
|
+
* Optional. Use `true` for a value you already know is correct, such as data
|
|
847
|
+
* from your own records. Unlike `prefilled`, it is about trusting the value, not
|
|
848
|
+
* when it was collected. It is stored and visible to whoever reviews the call,
|
|
849
|
+
* never verified, and left out of the verification summary counts.
|
|
850
|
+
*/
|
|
851
|
+
reference?: boolean;
|
|
794
852
|
/**
|
|
795
853
|
* Optional. Your own identifiers for this fact — a form field ID, a section
|
|
796
854
|
* name, anything that lets your UI map the result back to the right place.
|
|
@@ -883,15 +941,43 @@ type ConversationWarningCode =
|
|
|
883
941
|
| (string & {});
|
|
884
942
|
```
|
|
885
943
|
|
|
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
|
|
944
|
+
| `code` | meaning | conversation's advisor | what to do |
|
|
945
|
+
| ---------------------------- | ----------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------- |
|
|
946
|
+
| `advisor_not_found` | no AIQA user in your organization has the `advisorEmail` | unchanged | check the email, or create the advisor with [`upsertAdvisor()`](#upsertadvisor) |
|
|
947
|
+
| `advisor_lookup_unavailable` | the `advisorEmail` could not be checked at the moment (temporary) | unchanged | retry `updateConversation({ advisorEmail })` later |
|
|
948
|
+
| any other | added in a later version | — | log `message` and continue |
|
|
891
949
|
|
|
892
950
|
- Use `code` to choose what to do; do not parse `message`. `message` is human-readable, includes the email you sent, and may change.
|
|
893
951
|
- `success` is `true` and every other field you sent is saved.
|
|
894
952
|
|
|
953
|
+
### UpsertAdvisorInput
|
|
954
|
+
|
|
955
|
+
Accepted by `upsertAdvisor()`.
|
|
956
|
+
|
|
957
|
+
```typescript
|
|
958
|
+
type UpsertAdvisorInput = {
|
|
959
|
+
advisorEmail: string;
|
|
960
|
+
firstName: string;
|
|
961
|
+
lastName: string;
|
|
962
|
+
};
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
### UpsertAdvisorResult
|
|
966
|
+
|
|
967
|
+
Returned by `upsertAdvisor()`.
|
|
968
|
+
|
|
969
|
+
```typescript
|
|
970
|
+
type UpsertAdvisorResult = {
|
|
971
|
+
success: boolean; // always true when the Promise resolves
|
|
972
|
+
advisor: {
|
|
973
|
+
advisor_id: string; // pass it to updateConversation({ advisorId })
|
|
974
|
+
first_name: string | null; // null only for an existing non-advisor user with no name stored
|
|
975
|
+
last_name: string | null; // same as first_name
|
|
976
|
+
created: boolean; // true when created; false when a user in your organization already had this email
|
|
977
|
+
};
|
|
978
|
+
};
|
|
979
|
+
```
|
|
980
|
+
|
|
895
981
|
## Examples
|
|
896
982
|
|
|
897
983
|
### Complete Example: Recording Session
|
|
@@ -82,7 +82,8 @@ declare enum Methods {
|
|
|
82
82
|
FLAG_FACT = "FLAG_FACT",
|
|
83
83
|
SET_CONVERSATION_PRODUCT = "SET_CONVERSATION_PRODUCT",
|
|
84
84
|
SET_CONVERSATION_LANGUAGE = "SET_CONVERSATION_LANGUAGE",
|
|
85
|
-
UPDATE_CONVERSATION = "UPDATE_CONVERSATION"
|
|
85
|
+
UPDATE_CONVERSATION = "UPDATE_CONVERSATION",
|
|
86
|
+
UPSERT_ADVISOR = "UPSERT_ADVISOR"
|
|
86
87
|
}
|
|
87
88
|
type SetConversationProductResult = {
|
|
88
89
|
success: boolean;
|
|
@@ -137,6 +138,28 @@ type UpdateConversationResult = {
|
|
|
137
138
|
};
|
|
138
139
|
warnings?: ConversationWarning[];
|
|
139
140
|
};
|
|
141
|
+
/** The advisor to create or update with `upsertAdvisor()`. */
|
|
142
|
+
type UpsertAdvisorInput = {
|
|
143
|
+
/** Email of the advisor. Identifies the advisor in your organization. */
|
|
144
|
+
advisorEmail: string;
|
|
145
|
+
firstName: string;
|
|
146
|
+
lastName: string;
|
|
147
|
+
};
|
|
148
|
+
/** Returned by `upsertAdvisor()`. */
|
|
149
|
+
type UpsertAdvisorResult = {
|
|
150
|
+
/** Always `true` when the Promise resolves. */
|
|
151
|
+
success: boolean;
|
|
152
|
+
advisor: {
|
|
153
|
+
/** Pass it to `updateConversation({ advisorId })`. The email in lowercase. */
|
|
154
|
+
advisor_id: string;
|
|
155
|
+
/** The first name stored for this user. `null` only when the email belongs to an existing user who is not an advisor and has no name stored. */
|
|
156
|
+
first_name: string | null;
|
|
157
|
+
/** The last name stored for this user. `null` in the same case as `first_name`. */
|
|
158
|
+
last_name: string | null;
|
|
159
|
+
/** `true` when the advisor was created. `false` when a user in your organization already had this email: an advisor is updated, any other user is left unchanged. */
|
|
160
|
+
created: boolean;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
140
163
|
declare enum ConversationLanguage {
|
|
141
164
|
EN = "en",
|
|
142
165
|
ES = "es",
|
|
@@ -185,6 +208,13 @@ type ApplicationFactInput = {
|
|
|
185
208
|
is_skipped?: boolean;
|
|
186
209
|
/** Optional (default: `false`). Use `true` when the fact was collected before the conversation started. It is stored, not verified. */
|
|
187
210
|
prefilled?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Optional. Use `true` for a value you already know is correct, such as data
|
|
213
|
+
* from your own records. Unlike `prefilled`, it is about trusting the value, not
|
|
214
|
+
* when it was collected. It is stored and visible to whoever reviews the call,
|
|
215
|
+
* never verified, and left out of the verification summary counts.
|
|
216
|
+
*/
|
|
217
|
+
reference?: boolean;
|
|
188
218
|
/**
|
|
189
219
|
* Your own identifiers for this fact — a form field ID, a section name,
|
|
190
220
|
* anything that lets your UI map the result back to the right place.
|
|
@@ -243,7 +273,7 @@ interface AddFactResult {
|
|
|
243
273
|
answer_type?: string;
|
|
244
274
|
agent_answer?: string;
|
|
245
275
|
ai_answer?: string;
|
|
246
|
-
/** `false` for a fact that was never verified, such as a prefilled one. */
|
|
276
|
+
/** `false` for a fact that was never verified, such as a prefilled or reference one. */
|
|
247
277
|
is_valid_answer: boolean;
|
|
248
278
|
question_asked?: boolean;
|
|
249
279
|
/**
|
|
@@ -351,6 +381,12 @@ declare abstract class IAiqaSdk {
|
|
|
351
381
|
abstract setConversationProduct(product: string): Promise<SetConversationProductResult>;
|
|
352
382
|
abstract setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
|
|
353
383
|
abstract updateConversation(input: UpdateConversationInput): Promise<UpdateConversationResult>;
|
|
384
|
+
/**
|
|
385
|
+
* Creates an advisor in your organization, or updates the name of an existing
|
|
386
|
+
* advisor with the same email. A user with that email who is not an advisor is
|
|
387
|
+
* left unchanged. Rejects on invalid input.
|
|
388
|
+
*/
|
|
389
|
+
abstract upsertAdvisor(input: UpsertAdvisorInput): Promise<UpsertAdvisorResult>;
|
|
354
390
|
}
|
|
355
391
|
|
|
356
392
|
declare class AiQaSdk implements IAiqaSdk {
|
|
@@ -375,6 +411,7 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
375
411
|
setConversationProduct(product: string): Promise<SetConversationProductResult>;
|
|
376
412
|
setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
|
|
377
413
|
updateConversation(input: UpdateConversationInput): Promise<UpdateConversationResult>;
|
|
414
|
+
upsertAdvisor(input: UpsertAdvisorInput): Promise<UpsertAdvisorResult>;
|
|
378
415
|
authenticate(): Promise<void>;
|
|
379
416
|
startRecording(): Promise<boolean>;
|
|
380
417
|
stopRecording(): Promise<boolean>;
|
|
@@ -384,4 +421,4 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
384
421
|
private isManagerEvent;
|
|
385
422
|
}
|
|
386
423
|
|
|
387
|
-
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 FactWarning, type FactWarningCode, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type Utterance, type VerificationStatus };
|
|
424
|
+
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 FactWarning, type FactWarningCode, type FlagFactResult, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type TranscriptionUpdate, type UpdateConversationInput, type UpdateConversationResult, type UpsertAdvisorInput, type UpsertAdvisorResult, type Utterance, type VerificationStatus };
|
package/dist/browser/browser.js
CHANGED
|
@@ -3350,6 +3350,7 @@ var Methods = /* @__PURE__ */ ((Methods2) => {
|
|
|
3350
3350
|
Methods2["SET_CONVERSATION_PRODUCT"] = "SET_CONVERSATION_PRODUCT";
|
|
3351
3351
|
Methods2["SET_CONVERSATION_LANGUAGE"] = "SET_CONVERSATION_LANGUAGE";
|
|
3352
3352
|
Methods2["UPDATE_CONVERSATION"] = "UPDATE_CONVERSATION";
|
|
3353
|
+
Methods2["UPSERT_ADVISOR"] = "UPSERT_ADVISOR";
|
|
3353
3354
|
return Methods2;
|
|
3354
3355
|
})(Methods || {});
|
|
3355
3356
|
var ExternalStatus = /* @__PURE__ */ ((ExternalStatus2) => {
|
|
@@ -3406,7 +3407,7 @@ var compareVersions = (left, right) => {
|
|
|
3406
3407
|
// package.json
|
|
3407
3408
|
var package_default = {
|
|
3408
3409
|
name: "@aiqa/sdk",
|
|
3409
|
-
version: "3.
|
|
3410
|
+
version: "3.1.0-develop.1",
|
|
3410
3411
|
main: "dist/node/node.js",
|
|
3411
3412
|
module: "dist/node/node.js",
|
|
3412
3413
|
types: "dist/node/node.d.ts",
|
|
@@ -3783,6 +3784,15 @@ var AiQaSdk = class {
|
|
|
3783
3784
|
const { agent_id, ...conversation } = data.conversation;
|
|
3784
3785
|
return { ...data, conversation: { ...conversation, advisor_id: agent_id } };
|
|
3785
3786
|
}
|
|
3787
|
+
async upsertAdvisor(input) {
|
|
3788
|
+
const { advisorEmail, firstName, lastName } = input;
|
|
3789
|
+
const result = await this.sendMessage("UPSERT_ADVISOR" /* UPSERT_ADVISOR */, {
|
|
3790
|
+
email: advisorEmail,
|
|
3791
|
+
firstName,
|
|
3792
|
+
lastName
|
|
3793
|
+
});
|
|
3794
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
3795
|
+
}
|
|
3786
3796
|
async authenticate() {
|
|
3787
3797
|
try {
|
|
3788
3798
|
const result = await this.sendMessage("AUTHENTICATE" /* AUTHENTICATE */, {
|