@tellescope/types-models 1.256.0 → 1.256.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/index.ts CHANGED
@@ -1172,10 +1172,27 @@ export interface Enduser extends Enduser_readonly, Enduser_required, Enduser_upd
1172
1172
  preferredPharmacy?: Pharmacy,
1173
1173
  aiSummary?: string, // AI-generated patient profile summary (e.g. from the Generate Patient Summary journey action)
1174
1174
  aiSummaryUpdatedAt?: Date,
1175
+ // AI agent conversations (Start AI Conversation journey action). One entry per
1176
+ // (channel, source, destination) pairing, updated in place — an active entry means inbound
1177
+ // messages on that pairing are answered by the AI instead of the out-of-office autoreply.
1178
+ aiConversations?: EnduserAIConversation[],
1175
1179
  // unsubscribedFromEmail?: boolean,
1176
1180
  // unsubscribedFromSMS?: boolean,
1177
1181
  }
1178
1182
 
1183
+ export type EnduserAIConversation = {
1184
+ channel: 'SMS', // v1: SMS only
1185
+ aiConversationId: string, // the ai_conversations transcript/billing record
1186
+ source: string, // our number (inbound body.To)
1187
+ destination: string, // the enduser number in the conversation (inbound body.From)
1188
+ active: boolean,
1189
+ startedAt: Date,
1190
+ endedAt?: Date,
1191
+ endedReason?: string, // 'outcome' | 'staff-takeover' | 'unsubscribed' | 'expired' | 'max-turns' | 'credit-cap' | 'superseded' | 'error'
1192
+ journeyId?: string,
1193
+ automationStepId?: string, // the startAIConversation step — outcome events reference it
1194
+ }
1195
+
1179
1196
  export interface EnduserCustomType_readonly extends ClientRecord {}
1180
1197
  export interface EnduserCustomType_required {
1181
1198
  title: string,
@@ -3252,6 +3269,7 @@ export type AutomationEventType =
3252
3269
  | 'waitForTrigger'
3253
3270
  | "onCallOutcome"
3254
3271
  | "onAIDecision"
3272
+ | "onAIConversationOutcome"
3255
3273
  | "onError"
3256
3274
 
3257
3275
  interface AutomationEventBuilder <T extends AutomationEventType, V extends object> {
@@ -3367,8 +3385,10 @@ export type FormsUnsubmittedEvent = AutomationEventBuilder<'formsUnsubmitted', F
3367
3385
  export type OnJourneyStartAutomationEvent = AutomationEventBuilder<'onJourneyStart', {}>
3368
3386
  export type TicketCompletedAutomationEvent = AutomationEventBuilder<'ticketCompleted', TicketCompletedEventInfo>
3369
3387
  export type WaitForTriggerAutomationEvent = AutomationEventBuilder<'waitForTrigger', { automationStepId: string, triggerId: string }>
3370
- export type OnCallOutcomeAutomationEvent = AutomationEventBuilder<'onCallOutcome', { automationStepId: string, outcome: string }>
3388
+ export type OnCallOutcomeAutomationEvent = AutomationEventBuilder<'onCallOutcome', { automationStepId: string, outcome: string }>
3371
3389
  export type OnAIDecisionAutomationEvent = AutomationEventBuilder<'onAIDecision', { automationStepId: string, outcomes: string[] }>
3390
+ // branches from a 'startAIConversation' step when the AI conversation ends with this outcome (the SMS sibling of 'onCallOutcome')
3391
+ export type OnAIConversationOutcomeAutomationEvent = AutomationEventBuilder<'onAIConversationOutcome', { automationStepId: string, outcome: string }>
3372
3392
 
3373
3393
  export type OnErrorEventInfo = {
3374
3394
  automationStepId: string,
@@ -3386,6 +3406,7 @@ export type AutomationEventForType = {
3386
3406
  'waitForTrigger': WaitForTriggerAutomationEvent
3387
3407
  'onCallOutcome': OnCallOutcomeAutomationEvent,
3388
3408
  'onAIDecision': OnAIDecisionAutomationEvent
3409
+ 'onAIConversationOutcome': OnAIConversationOutcomeAutomationEvent
3389
3410
  'onError': OnErrorAutomationEvent
3390
3411
  }
3391
3412
  export type AutomationEvent = AutomationEventForType[keyof AutomationEventForType]
@@ -3551,6 +3572,15 @@ export type BelugaAutomationMappingEntry = {
3551
3572
  patientPreferences: BelugaUpdateVisitPatientPreferenceItem[],
3552
3573
  pharmacyId: string,
3553
3574
  }
3575
+ export type BelugaTriggerRefillPatientPreferenceItem = {
3576
+ medId: string,
3577
+ }
3578
+ export type BelugaTriggerRefillAutomationAction = AutomationActionBuilder<'belugaTriggerRefill', {
3579
+ formId: string,
3580
+ patientPreferences?: BelugaTriggerRefillPatientPreferenceItem[],
3581
+ useOrganizationMapping?: boolean,
3582
+ customFieldName?: string,
3583
+ }>
3554
3584
  export type SendChatAutomationAction = AutomationActionBuilder<'sendChat', {
3555
3585
  templateId: string,
3556
3586
  identifier: string,
@@ -3698,10 +3728,23 @@ export type CreateScriptSureDraftAutomationAction = AutomationActionBuilder<'cre
3698
3728
  matchMedicationTitle?: string, // when set, restrict to routes with this exact title
3699
3729
  matchEnduserState?: boolean, // when true, restrict to routes whose state === enduser.state
3700
3730
  }>
3731
+ // Starts an AI agent conversation with the enduser over a messaging channel (SMS v1) — the
3732
+ // messaging sibling of the phone tree 'AI Agent' step. The step's automated_action completes
3733
+ // immediately; the journey branches later via 'onAIConversationOutcome' events when the agent
3734
+ // ends the conversation with an outcome.
3735
+ export type StartAIConversationActionInfo = AIAgentBaseConfig & {
3736
+ channel: 'SMS', // v1: SMS only; conversations are scoped per (channel, source, destination)
3737
+ senderId: string, // user the AI's messages are attributed to (message userId + merge-field context)
3738
+ fromNumber?: string, // source number — must be one of the organization's numbers; defaults to organization.twilioNumber
3739
+ initialMessage: string, // opening SMS, sent immediately; supports merge fields like {{enduser.fname}}
3740
+ inactivityTimeoutHours?: number, // conversation auto-ends after this idle window (default 72)
3741
+ }
3742
+ export type StartAIConversationAutomationAction = AutomationActionBuilder<'startAIConversation', StartAIConversationActionInfo>
3701
3743
 
3702
3744
  export type AutomationActionForType = {
3703
3745
  'aiDecision': AIDecisionAutomationAction,
3704
3746
  'generateEnduserSummary': GenerateEnduserSummaryAutomationAction,
3747
+ 'startAIConversation': StartAIConversationAutomationAction,
3705
3748
  'assignInboxItem': AssignInboxItemAutomationAction,
3706
3749
  'stripeChargeCardOnFile': StripeChargeCardOnFileAutomationAction,
3707
3750
  'stripeCancelSubscription': StripeCancelSubscriptionAutomationAction,
@@ -3737,6 +3780,7 @@ export type AutomationActionForType = {
3737
3780
  'smartMeterPlaceOrder': SmartMeterPlaceOrderAutomationAction,
3738
3781
  'belugaAutoRx': BelugaAutoRxAutomationAction,
3739
3782
  'belugaUpdateVisit': BelugaUpdateVisitAutomationAction,
3783
+ 'belugaTriggerRefill': BelugaTriggerRefillAutomationAction,
3740
3784
  'healthieSync': HealthieSyncAutomationAction,
3741
3785
  healthieAddToCourse: HealthieAddToCourseAutomationAction,
3742
3786
  healthieSendChat: HealthieSendChatAutomationAction,
@@ -5154,6 +5198,18 @@ export type PhoneTreeAgentTools = {
5154
5198
  export type PhoneTreeAgentToolType = keyof PhoneTreeAgentTools
5155
5199
  export type PhoneTreeAgentTool = PhoneTreeAgentTools[PhoneTreeAgentToolType]
5156
5200
 
5201
+ // The channel-agnostic AI agent configuration — shared by the phone tree 'AI Agent' step (voice)
5202
+ // and the 'startAIConversation' journey action (SMS). Channel-specific settings extend this.
5203
+ export type AIAgentBaseConfig = {
5204
+ prompt: string, // org-authored additions to the channel's base system prompt
5205
+ outcomes: { value: string, description: string }[], // the agent must end with one of these
5206
+ tools?: PhoneTreeAgentTool[], // capabilities the agent may use mid-conversation (e.g. 'Submit Form', 'Book Appointment')
5207
+ model?: string, // friendly AI model name, see SELECTABLE_AI_MODELS (constants); defaults to Claude Sonnet 5
5208
+ maxTokensPerTurn?: number,
5209
+ maxTurns?: number,
5210
+ maxCreditsPerCall?: number, // per-call/per-conversation spend circuit breaker, default from constants
5211
+ }
5212
+
5157
5213
  export type PhoneTreeActionBuilder <T, V> = { type: T, info: V }
5158
5214
  export type PhoneTreeActions = {
5159
5215
  // 'Play': PhoneTreeActionBuilder<"Play", { playback: PhonePlayback }>
@@ -5209,19 +5265,14 @@ export type PhoneTreeActions = {
5209
5265
  // Conversational AI agent (Twilio ConversationRelay + Bedrock). A generic "end call with outcome"
5210
5266
  // step: the agent converses, then ends with one of the configured outcomes; the tree branches on
5211
5267
  // the outcome via 'On Agent Outcome' events, like 'On Gather' branches on input.
5212
- 'AI Agent': PhoneTreeActionBuilder<"AI Agent", {
5213
- prompt: string, // org-authored additions to the base voice system prompt
5268
+ // The field set is AIAgentBaseConfig + voice-only settings — structurally identical to the
5269
+ // pre-split inline shape, so validators, editors, and stored trees are unaffected.
5270
+ 'AI Agent': PhoneTreeActionBuilder<"AI Agent", AIAgentBaseConfig & {
5214
5271
  greeting?: string, // ConversationRelay welcomeGreeting
5215
5272
  voice?: string,
5216
5273
  language?: string,
5217
5274
  interruptible?: boolean, // barge-in, default true
5218
- maxTokensPerTurn?: number,
5219
- maxTurns?: number,
5220
5275
  maxDurationSeconds?: number,
5221
- maxCreditsPerCall?: number, // per-call spend circuit breaker, default from constants
5222
- model?: string, // friendly AI model name, see SELECTABLE_AI_MODELS (constants); defaults to Claude Sonnet 5
5223
- outcomes: { value: string, description: string }[], // the agent must end with one of these
5224
- tools?: PhoneTreeAgentTool[], // capabilities the agent may use mid-call (e.g. 'Submit Form')
5225
5276
  }>
5226
5277
  }
5227
5278
  export type PhoneTreeActionType = keyof PhoneTreeActions