@scout9/app 1.0.0-alpha.0.6.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scout9/app",
3
- "version": "1.0.0-alpha.0.6.4",
3
+ "version": "1.0.0-alpha.0.6.5",
4
4
  "description": "Build and deploy your Scout9 app for SMS auto replies",
5
5
  "publishConfig": {
6
6
  "access": "public"
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
- message?: string | {content: string; transform?: boolean} | undefined;
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
  });
@@ -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
  };