Files
lingxi-web/src/types/messaging.ts
T
wmq af49d22ca7 feat: release contextual omnichannel customer platform
Add Telegram, WhatsApp and email account management, realtime messaging, contextual multilingual AI, customer intelligence, knowledge workflows, enterprise controls, a unified design system and complete repository documentation.
2026-07-30 02:29:53 +08:00

200 lines
4.9 KiB
TypeScript

import type { IntentLevel, Sentiment } from './common'
/** 渠道类型(含渠道中心全部可连接类型) */
export type ChannelType =
| 'whatsapp'
| 'telegram'
| 'messenger'
| 'email'
| 'gmail'
| 'outlook'
| 'webform'
| 'website'
| 'landing'
| 'social'
| 'exhibition'
| 'api'
| 'webhook'
export type MessageType = 'text' | 'image' | 'file' | 'audio' | 'product'
export type MessageStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'failed'
export type MessageSender = 'customer' | 'agent' | 'system'
export interface Message {
id: string
conversationId: string
sender: MessageSender
senderName?: string
type: MessageType
originalText: string
translatedText?: string
/** 发出消息的中文客服备注,不会发送到外部渠道 */
translationCn?: string
translationStatus?: 'pending' | 'completed' | 'failed'
translatedAt?: string
translationMethod?: 'ai-contextual' | 'ai-direct' | 'source'
translationContextMessages?: number
translationConversationSummaryApplied?: boolean
translationModel?: string
intentStatus?: 'pending' | 'completed' | 'failed'
intentAnalysis?: {
primary: string
label: string
confidence: number
urgency: 'low' | 'medium' | 'high' | 'urgent'
sentiment: 'positive' | 'neutral' | 'negative' | 'angry'
entities: string[]
rationale: string
analyzedAt: string
model: string
}
originalLang: string
targetLang?: string
status: MessageStatus
createdAt: string
isImportant?: boolean
internalNote?: string
attachmentName?: string
productCard?: { name: string; sku: string; price: string }
replyToId?: string
replyPreview?: string
editedAt?: string
isDeleted?: boolean
deletedAt?: string
reactions?: Array<{
actor: string
emoji: string
fromMe?: boolean
updatedAt?: string
}>
telegramFileId?: number
whatsappMessageId?: string
whatsappContentType?: string
attachmentMimeType?: string
attachmentSize?: number
stickerEmoji?: string
emailUid?: number
emailMessageId?: string
emailSubject?: string
emailAttachments?: Array<{
id: string
name: string
mimeType: string
size: number
available: boolean
}>
}
export interface Conversation {
id: string
customerId: string
channel: ChannelType
unreadCount: number
status: 'pending' | 'replied' | 'closed'
assigneeId: string | null
intentLevel: IntentLevel
sentiment: Sentiment
hasRisk: boolean
lastMessage?: Message
summary: string
updatedAt: string
emailSubject?: string
channelId?: string
telegramChatId?: string
telegramChatType?: string
whatsappJid?: string
whatsappChatType?: string
isPinned?: boolean
archived?: boolean
mutedUntil?: string | null
markedUnread?: boolean
isBlocked?: boolean
leftAt?: string
presence?: 'available' | 'unavailable' | 'composing' | 'recording' | 'paused'
presenceUpdatedAt?: string
lastSeenAt?: string
translationTargetLang?: string
messageIntentEnabled?: boolean
aiContextStatus?: 'waiting' | 'queued' | 'compressing' | 'ready' | 'failed'
aiContextSourceMessageCount?: number
aiContextPendingMessages?: number
aiContextCompressedAt?: string
aiContextCompactedMessageIds?: string[]
aiContextMemory?: {
summary: string
facts: string[]
commitments: string[]
products: string[]
unresolved: string[]
preferences: string[]
updatedThroughMessageId: string
sourceMessageCount: number
updatedAt: string
model: string
version: number
}
}
export interface AiBackfillStatus {
status: 'not-started' | 'queued' | 'running' | 'completed' | 'failed'
totalCount: number
completedCount: number
pendingCount: number
progress: number
startedAt?: string
completedAt?: string | null
lastError?: string
}
export type ChannelStatus = 'connected' | 'disconnected' | 'error' | 'paused' | 'unconnected'
export interface ChannelConnection {
id: string
type: ChannelType
name: string
status: ChannelStatus
account?: string
lastSyncAt?: string
todayMessages: number
errorMessage?: string
autoReply: boolean
authState?: string
defaultOwnerId?: string
displayName?: string
imapHost?: string
imapPort?: number
imapSecure?: boolean
imapFolder?: string
smtpHost?: string
smtpPort?: number
smtpSecure?: boolean
syncDays?: number
lastVerifiedAt?: string
isDefault?: boolean
provider?: string
pairingCode?: string
qrDataUrl?: string
}
export interface ChannelSyncLog {
id: string
channelId: string
action: string
detail: string
status: 'success' | 'failed'
createdAt: string
}
/** 发送消息请求 */
export interface SendMessagePayload {
text: string
/** 已确认的中文参考译文,仅在内部消息记录中保存 */
translationCn?: string
/** auto 表示根据客户最近消息或客户画像自动选择目标语言 */
targetLang?: string
replyToId?: string
replyPreview?: string
type?: MessageType
attachmentName?: string
}