@scout9/app 1.0.0-alpha.0.5.9 → 1.0.0-alpha.0.6.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/src/public.d.ts CHANGED
@@ -543,6 +543,14 @@ export type IntentWorkflowEvent = {
543
543
  initial: string | null;
544
544
  };
545
545
 
546
+ export type MessageEntity = {
547
+ start: number;
548
+ end: number;
549
+ type: string;
550
+ option?: string | null;
551
+ text?: string | null;
552
+ }
553
+
546
554
  export type Message = {
547
555
  /** Unique ID for the message */
548
556
  id: string;
@@ -561,6 +569,8 @@ export type Message = {
561
569
  intentScore?: (number | null) | undefined;
562
570
  /** How long to delay the message manually in seconds */
563
571
  delayInSeconds?: (number | null) | undefined;
572
+ /** Entities related to the message */
573
+ entities?: MessageEntity[] | null;
564
574
  };
565
575
 
566
576
  export type PersonaConfiguration = AgentConfiguration;
@@ -704,7 +714,6 @@ export type WorkflowResponseMessageApiResponse = string | {
704
714
  };
705
715
  };
706
716
 
707
-
708
717
  export type WorkflowsConfiguration = {
709
718
  /** Workflow id association, used to handle route params */
710
719
  entities: string[];
@@ -1,6 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { zId } from './utils.js';
3
3
 
4
+ export const MessageEntitySchema = z.object({
5
+ start: z.number(),
6
+ end: z.number(),
7
+ type: z.string(),
8
+ option: z.string().optional().nullable(),
9
+ text: z.string().optional().nullable()
10
+ });
11
+
4
12
  export const MessageSchema = z.object({
5
13
  id: zId('Message ID', {description: 'Unique ID for the message'}),
6
14
  role: z.enum(['agent', 'customer', 'system']),
@@ -11,5 +19,6 @@ export const MessageSchema = z.object({
11
19
  context: z.any({description: 'The context generated from the message'}).optional(),
12
20
  intent: z.string({description: 'Detected intent'}).optional().nullable(),
13
21
  intentScore: z.number({description: 'Confidence score of the assigned intent'}).nullable().optional(),
14
- delayInSeconds: z.number({description: 'How long to delay the message manually in seconds'}).nullable().optional()
22
+ delayInSeconds: z.number({description: 'How long to delay the message manually in seconds'}).nullable().optional(),
23
+ entities: z.array(MessageEntitySchema).optional().nullable()
15
24
  });
@@ -50,6 +50,9 @@ export const AgentSchema = z.object({
50
50
  tag: z.string().optional(),
51
51
  ingress: z.enum(["auto", "manual", "app", "workflow"]),
52
52
  llm: z.string().optional(),
53
+ webhookUri: z.string().optional(),
54
+ watermarkEnabled: z.boolean().optional(),
55
+ watermark: z.string().optional()
53
56
  }).optional()
54
57
  });
55
58
 
@@ -19,7 +19,8 @@
19
19
  * @property {Array<import('@scout9/app').Message>} messages
20
20
  * @property {import('@scout9/app').Message} message - the message sent by the customer (should exist in messages)
21
21
  * @property {import('@scout9/app').Customer} customer
22
- * @property {any} context
22
+ * @property {import('@scout9/app').ConversationProgress} progress - progress checklist for manual/auto ingress workflows
23
+ * @property {any} context - event context
23
24
  */
24
25
 
25
26
  /**
@@ -46,6 +47,14 @@
46
47
  * @property {any} context
47
48
  */
48
49
 
50
+ /**
51
+ * @typedef {Object} GenerateOutput
52
+ * @property {import('@scout9/admin').GenerateResponse | undefined} generate
53
+ * @property {Array<import('@scout9/app').Message>} messages
54
+ * @property {import('@scout9/app').Conversation} conversation
55
+ * @property {any} context
56
+ */
57
+
49
58
  /**
50
59
  * @callback ParseFun
51
60
  * @param {string} message - message to send
@@ -76,6 +85,7 @@
76
85
  * @param {import('@scout9/app').Message['role']} prefix
77
86
  * @returns {string}
78
87
  */
88
+
79
89
  /**
80
90
  * @callback StatusCallback
81
91
  * @param {string} message
@@ -273,6 +283,7 @@ export const Spirits = {
273
283
  message.intentScore = parsePayload.intentScore;
274
284
  }
275
285
  message.context = parsePayload.context;
286
+ message.entities = parsePayload.entities;
276
287
  const index = messages.findIndex(m => m.content === message.content || m.id === message.id);
277
288
  if (index === -1) {
278
289
  const _message = {
@@ -280,6 +291,7 @@ export const Spirits = {
280
291
  role: 'customer',
281
292
  content: message,
282
293
  context: parsePayload.context,
294
+ entities: parsePayload.entities,
283
295
  time: new Date().toISOString()
284
296
  };
285
297
  if (parsePayload.intent) {
@@ -293,6 +305,7 @@ export const Spirits = {
293
305
  progress('Added message', 'info', 'ADD_MESSAGE', _message);
294
306
  } else {
295
307
  messages[index].context = parsePayload.context;
308
+ messages[index].entities = parsePayload.entities;
296
309
  if (parsePayload.intent) {
297
310
  messages[index].intent = parsePayload.intent;
298
311
  }