@scout9/app 1.0.0-alpha.0.6.3 → 1.0.0-alpha.0.6.5
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/dist/{dev-ea47d904.cjs → dev-6e60a643.cjs} +3 -3
- package/dist/{index-c61b5075.cjs → index-bf3ce1b6.cjs} +7 -7
- package/dist/index.cjs +4 -4
- package/dist/{macros-621210f1.cjs → macros-1a4fd407.cjs} +10 -1
- package/dist/{multipart-parser-0a176f23.cjs → multipart-parser-13478cb7.cjs} +4 -4
- package/dist/schemas.cjs +1 -1
- package/dist/{spirits-e626085b.cjs → spirits-985e6711.cjs} +112 -106
- package/dist/spirits.cjs +1 -1
- package/dist/testing-tools.cjs +3 -3
- package/package.json +1 -1
- package/src/public.d.ts +77 -1
- package/src/runtime/schemas/message.js +3 -1
- package/src/runtime/schemas/users.js +1 -0
- package/src/testing-tools/spirits.js +9 -1
- package/types/index.d.ts +267 -6
- package/types/index.d.ts.map +3 -1
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dev = require("./dev-
|
|
6
|
-
require("./spirits-
|
|
5
|
+
var dev = require("./dev-6e60a643.cjs");
|
|
6
|
+
require("./spirits-985e6711.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
9
9
|
require('path');
|
|
@@ -24,7 +24,7 @@ require('node:url');
|
|
|
24
24
|
require('node:events');
|
|
25
25
|
require('node:stream');
|
|
26
26
|
require('node:string_decoder');
|
|
27
|
-
require("./macros-
|
|
27
|
+
require("./macros-1a4fd407.cjs");
|
|
28
28
|
require('node:readline');
|
|
29
29
|
require('node:process');
|
|
30
30
|
require('node:os');
|
package/package.json
CHANGED
package/src/public.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Application platform for managing auto reply workflows from personal communication methods
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @param {WorkflowEvent} event - every workflow receives an event object
|
|
9
11
|
* @param {Object} options
|
|
@@ -530,6 +532,21 @@ export type FollowupWithInstructions = FollowupBase & { instructions: Instructio
|
|
|
530
532
|
|
|
531
533
|
export type Followup = FollowupWithMessage | FollowupWithInstructions;
|
|
532
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Metadata to provide a atomic transaction on a entity context record
|
|
537
|
+
* @ingress auto/manual only
|
|
538
|
+
*/
|
|
539
|
+
export type EntityContextUpsert = {
|
|
540
|
+
entityType: string;
|
|
541
|
+
entityRecordId: string;
|
|
542
|
+
method: 'mutate' | 'delete'
|
|
543
|
+
} & ({
|
|
544
|
+
method: 'delete'
|
|
545
|
+
} | {
|
|
546
|
+
method: 'mutate';
|
|
547
|
+
fields: Record<string, string | number | boolean | null | '#remove' | '#delete'>;
|
|
548
|
+
});
|
|
549
|
+
|
|
533
550
|
export type Forward = boolean | string | {
|
|
534
551
|
to?: string | undefined;
|
|
535
552
|
mode?: ("after-reply" | "immediately") | undefined;
|
|
@@ -554,6 +571,9 @@ export type EntityToken = {
|
|
|
554
571
|
export type Message = {
|
|
555
572
|
/** Unique ID for the message */
|
|
556
573
|
id: string;
|
|
574
|
+
/**
|
|
575
|
+
* @TODO role:agent is inaccurate it should be "persona"
|
|
576
|
+
*/
|
|
557
577
|
role: "agent" | "customer" | "system";
|
|
558
578
|
content: string;
|
|
559
579
|
/** Datetime ISO 8601 timestamp */
|
|
@@ -571,6 +591,10 @@ export type Message = {
|
|
|
571
591
|
delayInSeconds?: (number | null) | undefined;
|
|
572
592
|
/** Entities related to the message */
|
|
573
593
|
entities?: EntityToken[] | null;
|
|
594
|
+
/** If set to true, the PMT will not transform, message will be sent as is */
|
|
595
|
+
ignoreTransform?: boolean;
|
|
596
|
+
/** Media urls to attach to the transported message */
|
|
597
|
+
mediaUrls?: string[];
|
|
574
598
|
};
|
|
575
599
|
|
|
576
600
|
export type PersonaConfiguration = AgentConfiguration;
|
|
@@ -666,27 +690,79 @@ export type AnticipateKeywords = WorkflowResponseSlotBase & {
|
|
|
666
690
|
|
|
667
691
|
export type Anticipate = AnticipateDid | AnticipateKeywords[];
|
|
668
692
|
|
|
693
|
+
export type DirectMessagePayload = {
|
|
694
|
+
/**
|
|
695
|
+
* The content
|
|
696
|
+
*/
|
|
697
|
+
content: string;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* If true, the PMT will transform the message into the owners own words. By default will send the message as is
|
|
701
|
+
*/
|
|
702
|
+
transform?: boolean;
|
|
703
|
+
|
|
704
|
+
mediaUrls?: string[];
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Workflow Response Slot, can use for both PMT workflow event and event macro runtimes
|
|
709
|
+
*/
|
|
669
710
|
export type WorkflowResponseSlotBase = {
|
|
670
711
|
/** Forward input information of a conversation */
|
|
671
712
|
forward?: Forward | undefined;
|
|
672
713
|
/** Note to provide to the agent, recommend using forward object api instead */
|
|
673
714
|
forwardNote?: string | undefined;
|
|
715
|
+
|
|
716
|
+
/** Instructions to send to the PMT on how to steer the conversation */
|
|
674
717
|
instructions?: Instruction[] | undefined;
|
|
718
|
+
|
|
719
|
+
/** Remove instructions from memory (requires set instructions to have ids) */
|
|
675
720
|
removeInstructions?: string[] | undefined;
|
|
676
|
-
|
|
721
|
+
|
|
722
|
+
/** If provided, sends a direct message to the user */
|
|
723
|
+
message?: string | DirectMessagePayload | undefined;
|
|
724
|
+
|
|
725
|
+
/** Delays in seconds of instructions (if provided) to PMT and direct message (if provided) to user */
|
|
677
726
|
secondsDelay?: number | undefined;
|
|
727
|
+
|
|
728
|
+
/** unix time of when to send instructions or message */
|
|
678
729
|
scheduled?: number | undefined;
|
|
730
|
+
|
|
731
|
+
/** Context to upsert to the conversation */
|
|
679
732
|
contextUpsert?: {
|
|
680
733
|
[x: string]: any;
|
|
681
734
|
} | undefined;
|
|
735
|
+
|
|
736
|
+
/** If true, resets the conversations intent value to undefined or to its initial value */
|
|
682
737
|
resetIntent?: boolean | undefined;
|
|
738
|
+
|
|
739
|
+
/** Information to follow up to the client */
|
|
683
740
|
followup?: Followup | undefined;
|
|
684
741
|
};
|
|
685
742
|
|
|
743
|
+
/**
|
|
744
|
+
* Workflow Response Slot, only PMT workflow events
|
|
745
|
+
*/
|
|
686
746
|
export type WorkflowResponseSlot = WorkflowResponseSlotBase & {
|
|
747
|
+
/**
|
|
748
|
+
* The Anticipate API acts as a preflight to the users next response, for example:
|
|
749
|
+
* - did the user agree to accept the concert tickets? Then proceed with asking for their email
|
|
750
|
+
* - Did the user say any of these words: "cancel", "drop", or "remove"? Then cancel tickets
|
|
751
|
+
*/
|
|
687
752
|
anticipate?: Anticipate | undefined;
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* If provided, it will propagate entity context to your Scout9 entity context store
|
|
757
|
+
* @ingress auto/manual only
|
|
758
|
+
*/
|
|
759
|
+
entityContextUpsert?: Array<EntityContextUpsert> | undefined;
|
|
688
760
|
};
|
|
689
761
|
|
|
762
|
+
/**
|
|
763
|
+
* The JSON anticipated response for a given workflow to drive the PMT runtime
|
|
764
|
+
* Can either be an EventMacro or WorkflowResponseSlot
|
|
765
|
+
*/
|
|
690
766
|
export type WorkflowResponse = EventMacros | WorkflowResponseSlot | (WorkflowResponseSlot | EventMacros)[];
|
|
691
767
|
|
|
692
768
|
export type WorkflowFunction = (event: WorkflowEvent) => WorkflowResponse | Promise<WorkflowResponse>;
|
|
@@ -20,5 +20,7 @@ export const MessageSchema = z.object({
|
|
|
20
20
|
intent: z.string({description: 'Detected intent'}).optional().nullable(),
|
|
21
21
|
intentScore: z.number({description: 'Confidence score of the assigned intent'}).nullable().optional(),
|
|
22
22
|
delayInSeconds: z.number({description: 'How long to delay the message manually in seconds'}).nullable().optional(),
|
|
23
|
-
entities: z.array(MessageEntitySchema).optional().nullable()
|
|
23
|
+
entities: z.array(MessageEntitySchema).optional().nullable(),
|
|
24
|
+
ignoreTransform: z.boolean({description: 'If set to true, the PMT will not transform, message will be sent as is'}).optional(),
|
|
25
|
+
mediaUrls: z.array(z.string(), {description: 'Media urls to attach to the transported message'}).optional().nullable()
|
|
24
26
|
});
|
|
@@ -34,6 +34,7 @@ export const AgentSchema = z.object({
|
|
|
34
34
|
firstName: z.string({description: 'Agent first name'}).optional(),
|
|
35
35
|
lastName: z.string({description: 'Agent last name'}).optional(),
|
|
36
36
|
inactive: z.boolean({description: 'Agent is inactive'}).optional(),
|
|
37
|
+
isFreeProgrammablePhoneNumber: z.boolean({description: 'Whether the pmt programmable phone number they have is a free number or not'}).optional(),
|
|
37
38
|
programmablePhoneNumber: z.string({description: 'Programmable phone number'}).optional(),
|
|
38
39
|
programmablePhoneNumberSid: z.string({description: 'Programmable phone number SID'}).optional(),
|
|
39
40
|
programmableEmail: z.string({description: 'Email address from Scout9 gmail subdomain'}).optional(),
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
* @property {Change<any>} context
|
|
113
113
|
* @property {Change<import('@scout9/app').Message>} message
|
|
114
114
|
* @property {Array<import('@scout9/app').Followup>} followup
|
|
115
|
+
* @property {Array<import('@scout9/app').EntityContextUpsert>} entityContextUpsert
|
|
115
116
|
*/
|
|
116
117
|
export const Spirits = {
|
|
117
118
|
|
|
@@ -138,6 +139,7 @@ export const Spirits = {
|
|
|
138
139
|
} = input;
|
|
139
140
|
let {conversation, messages, context, message} = input;
|
|
140
141
|
const followup = [];
|
|
142
|
+
const entityContextUpsert = [];
|
|
141
143
|
|
|
142
144
|
// 0. Setup Helpers
|
|
143
145
|
const updateConversation = (previousConversation, conversationUpdates) => {
|
|
@@ -398,6 +400,7 @@ export const Spirits = {
|
|
|
398
400
|
contextUpsert,
|
|
399
401
|
anticipate,
|
|
400
402
|
followup: slotFollowup,
|
|
403
|
+
entityContextUpsert: slotEntityContextUpsert
|
|
401
404
|
} of slots) {
|
|
402
405
|
|
|
403
406
|
// Anticipate customer response
|
|
@@ -439,6 +442,10 @@ export const Spirits = {
|
|
|
439
442
|
followup.push(slotFollowup);
|
|
440
443
|
}
|
|
441
444
|
|
|
445
|
+
if (slotEntityContextUpsert && slotEntityContextUpsert.length) {
|
|
446
|
+
entityContextUpsert.push(...slotEntityContextUpsert);
|
|
447
|
+
}
|
|
448
|
+
|
|
442
449
|
// Forward to agent or other agent
|
|
443
450
|
if (forward) {
|
|
444
451
|
conversation = lockConversation(conversation, 'App instructed forward');
|
|
@@ -680,7 +687,8 @@ export const Spirits = {
|
|
|
680
687
|
before: contextBefore,
|
|
681
688
|
after: context
|
|
682
689
|
},
|
|
683
|
-
followup
|
|
690
|
+
followup,
|
|
691
|
+
entityContextUpsert
|
|
684
692
|
};
|
|
685
693
|
}
|
|
686
694
|
};
|