UNPKG

@ogxing/server-sdk

Version:

server-sdk

2,063 lines (1,584 loc) 152 kB
/* eslint-disable */ /* tslint:disable */ /* * --------------------------------------------------------------- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## * ## ## * ## AUTHOR: acacode ## * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## * --------------------------------------------------------------- */ export interface ChannelAutoReply { active: boolean; type: AutoReplyType; bot?: AutoReplyBot; greetings: AutoReplyGreeting[]; } export interface WebpushRegisterBody { /** Target platform this registration originates from. */ platform: PushPlatform; /** Registration object provided by relevant platform. */ registration: string; } export interface GupshupWabaOutboundMessageQuickReply { type: 'quick_reply'; msgid: 'qr1'; content: { type: 'text'; header: 'this is the header'; text: 'this is the body'; caption: 'this is the footer'; }; options: any[]; } export interface VoiceWebhookPayload { route: string; message: string; type: 'chat' | 'audio'; direction: 'send' | 'recv'; } export interface WhatsappGupshupUpdateBody { channelId: ChannelId; /** Remote platform id for this channel. Gupshup waba unique application name. */ remoteId: string; /** Gupshup waba api key scoped to gupshup application. */ apiKey: string; /** Inbound/outbound route for this channel. For whatsapp, voice, etc phone number. For wechat, messenger etc platform specific identifier. */ route?: string; } export type MessageOutboundSendBody = | WhatsappOutboundSendPayload | MessengerOutboundSendPayload | WechatOutboundSendPayload | LineOutboundSendPayload | SmsOutboundSendPayload | UccOutboundSendPayload; export interface WhatsappPersonalFetchQrQs { channelId: ChannelId; } export interface WhatsappPersonalUnlinkBody { channelId: ChannelId; } export interface WhatsappPersonalRestartBody { channelId: ChannelId; } export interface WhatsappPersonalStopSyncBody { channelId: ChannelId; } export interface WhatsappPersonalSyncProgressQs { channelId: ChannelId; } export type WhatsappPersonalSyncProgressReply = ChannelSyncProgressGetReply; export interface ChannelSyncProgressGetReply { total: number; processed: number; } export interface MessageContactInfoUpdateBody { deskId: DeskId; contactId: ContactId; /** User provided contact name, if not set will infer from platform provided name, then from platform's contact route. */ name?: string; /** Customer reference number, for customer to setup an identifier to link with their external system. */ crn?: string; /** List of tags set by user. */ tags?: string[]; /** List of assigned member ids. */ members?: MemberId[]; /** Optional extra remark. */ remark?: string; /** Sticky contact that always appears on top. */ sticky?: boolean; /** Archived contact. */ archive?: boolean; } export interface MessageFetchDeskDistinctTagBody { deskId: DeskId; } export type MessageFetchDeskDistinctTagReply = string[]; export interface MessageFetchDeskDistinctChannelBody { deskId: DeskId; } /** * Filter by channel route. */ export type MessageFetchDeskDistinctChannelReply = ContactFilterChannel[]; export interface MessageOutboundSendRecallBody { messageId: MessageId; } export interface MessageOutboundSendCancelBody { messageIds: string[]; } export interface MessageOutboundResendTimeoutBody { messageIds: string[]; } export interface MessageFetchVirginContactQs { term: string; deskId: DeskId; } export type MessageFetchVirginContactReply = Contact[]; export interface MessageFetchQueuedOutboundSendQs { channelId: ChannelId; type: MessageFetchQueuedOutboundSendType; } export type MessageFetchQueuedOutboundSendReply = { message: Message; _id: string; reference?: string; route: string; channel: string; platform: Platform; status: 'O' | 'C'; remark?: string; crn?: string; tags: string[]; members: MemberId[]; archive: boolean; sticky: boolean; autoReply?: { active: boolean; provider?: AutoReplyBotProvider; contexts?: any[] | string; messageId?: MessageId; }; name: string; platformProvidedName?: string; deskId: DeskId; thumbnail?: string; group?: GroupMetadata; lastAt: Date; orderAt: Date; lastMessageId: MessageId; jumpToMessage?: Message; hash?: string; caseCount: number; inboundMessageCount: number; readBy: Record0; }[]; export interface MessageCaseCloseBody { deskId: DeskId; contactId: ContactId; body: string; media?: MessageMetaMedia[]; append: boolean; /** String representation of BSON ObjectId */ caseId?: MongoId; } export interface MessageMemoBody { deskId: DeskId; contactId: ContactId; body: string; media?: MessageMetaMedia[]; } export interface MessageFlashBody { deskId: DeskId; contactId: ContactId; body: string; media?: MessageMetaMedia[]; } export interface MessageContactLockBody { deskId: DeskId; contactId: ContactId; } export interface MessageContactReadBody { deskId: DeskId; contactId: ContactId; } export interface BroadcastFetchQs { deskId: DeskId; limit: number; } export type BroadcastFetchReply = { _id: string; route: string; platform: Platform; deskId: DeskId; memberId: MemberId; body?: string; media?: { url: string; type: MessageMediaType }; recipients: string[]; source: 'filter' | 'custom'; filter?: ContactFilter; priority: MessagePriority; remark?: string; paused: boolean; delivered: number; read: number; recalled: number; cancelled: number; timeout: number; failed: number; total: number; completed: boolean; lastMessageId?: MessageId; lastMessageRoute?: string; lastAt: Date; }[]; export interface BroadcastFetchDetailQs { broadcastId: BroadcastId; } export type BroadcastFetchDetailReply = Broadcast; export interface BroadcastCreateBody { deskId: DeskId; /** Channel to broadcast from. */ route: string; /** Platform of channel to broadcast from. */ platform: Platform; /** Text message */ body?: string; /** Media to send. */ media?: { url: string; type: MessageMediaType }; /** Recipient route list. */ recipients: string[]; /** Recipient generated via filter or custom user provided list. */ source: 'filter' | 'custom'; /** Filter used to generate recipient list. */ filter?: ContactFilter; /** Send priority. */ priority: MessagePriority; /** Additional remark for reference only. */ remark?: string; /** Toggle to pause / resume broadcast. */ paused: boolean; } export interface BroadcastUpdateBody { broadcastId: BroadcastId; /** Toggle to pause / resume broadcast. */ paused?: boolean; /** Additional remark for reference only. */ remark?: string; } export type BroadcastRecipientGenerateByFilterBody = ContactFilter; export type BroadcastRecipientGenerateByFilterReply = string[]; export interface PromocodeGenerateBody { /** * Specify either percent or exact amount. * @min 0 * @max 100 */ discountPercent?: number; /** Exact amount to deduct in Dinero format. */ amount?: { amount: number; currency: DineroFactoryCurrency }; /** * How many total redeem count until this promo is deactivated. * @min 0 */ maxRedeemLimit?: number; /** Allow same user to redeem using this code multiple time. */ allowReuse?: boolean; /** * How many time can this code be reused. * @min 0 */ allowReuseLimit?: number; /** * The date this promo code expires. * @format date-time */ expireAt?: Date; /** Only allow targeted user to claim this promo code. */ targetUsers?: UserId[]; /** The actual promo code itself. Uppercase case only, if provided lowercase will auto covert to uppercase. */ code: string; } export interface PromocodeFetchQs { /** * How many result to return * @min 0 */ limit?: number; creatorId?: UserId; /** Include already deactivated promo code */ includeDeactivated?: boolean; } export type PromocodeFetchReply = PromoCode[]; export interface VoiceRouteUpdateBody { channelId: ChannelId; route: string; } export interface VoiceTriggerWhatsappBody { channelId: ChannelId; route: string; } export interface VoiceCustomTagBody { deskId: DeskId; platform: 'voice'; /** Inbound/outbound route for this channel. For whatsapp, voice, etc phone number. For wechat, messenger etc platform specific identifier. */ channel?: string; /** Contact route. */ route: string; tag: string; } export interface ChannelAddBody { deskId: DeskId; /** The actual promo code itself. Uppercase case only, if provided lowercase will auto covert to uppercase. */ promoCode: string; /** Product plan this channel is on. */ productPlan: ProductPlan; } export type ChannelAddReply = Channel; export interface ChannelDeleteBody { channelId: ChannelId; } export interface ChannelUpdateInfoBody { channelId: ChannelId; /** Channel display name */ name?: string; /** Display profile picture */ thumbnail?: string; autoReply?: ChannelAutoReply; } export type AutoReplyBotOutboundTestBody = | AutoReplyBotOutboundTestDialogFlow | AutoReplyBotOutboundTestWatson | AutoReplyBotOutboundTestBotpress; export interface AutoReplyBotOutboundTestReply { error?: any; parsed?: AutoReplyBotMessage[]; raw?: any; } export interface DeskCreateBody { /** Desk display name. */ name: string; /** Timezone this desk operates at */ timezone: string; } export interface DeskCreateReply { deskId: DeskId; memberId: MemberId; } export interface DeskQuitBody { deskId: DeskId; } export interface DeskDeleteBody { deskId: DeskId; } export interface DeskUpdateInfoBody { deskId: DeskId; /** Desk display name. */ name?: string; /** Desk profile picture. */ thumbnail?: string; /** Additional desk description. */ slogan?: string; } export interface DeskUpdateSettingBody { deskId: DeskId; /** Timezone this desk operates at */ timezone?: string; /** Enable anonymize phone number feature. Channel route to anonymize. */ anonChannels?: ContactFilterChannel[]; /** Enable desk chat feature. */ deskChat?: boolean; /** Enable flash message feature. */ flash?: boolean; /** Enable auto reply feature. */ autoReply?: boolean; /** Case auto open / close settings. */ contactCase?: DeskCaseSetting; /** New inbound message forward settings. */ inboundForward?: DeskInboundForwardSetting; } export type DeskUpdateContactFilterBody = ContactFilter; export type DeskUpdateReportSettingBody = ReportSetting; export interface DeskVerifyTokenBody { /** Desk invitation token */ token: string; } export type DeskVerifyTokenReply = InvitationToken; export interface MemberAcceptInvitationBody { /** Desk invitation token */ token: string; } export interface MemberAcceptInvitationReply { /** UCC desk members. */ member: Member; /** UCC user info. */ user: User; } export interface MemberRejectInvitationBody { /** Desk invitation token */ token: string; } export interface MemberRejectInvitationReply { /** UCC desk members. */ member: Member; /** UCC user info. */ user: User; } export interface DeskExcerptBody { deskId: DeskId; body: string; whatsappId: string; messengerId: string; wechatId: string; lineId: string; } export interface DeskExcerptReply { deskId: DeskId; name: string; thumbnail?: string; platforms: Platform[]; onboardMessage?: string; } export interface DeskCreateApiKeyBody { deskId: DeskId; /** Name for this apikey. */ name?: string; /** Full access to desk related api. */ adminAccess?: boolean; /** Full access to channel related api. */ channelAccess?: boolean; /** Allow this apikey to access all channels of this desk. */ allowAllChannel?: boolean; /** List of channels this apikey has access to. No effect if allowAllChannel is enabled. */ channels?: ChannelId[]; } export interface DeskCreateApiKeyReply { id: ApiKeyId; /** Name for this apikey. */ name?: string; /** Generated apikey. */ key: string; /** Full access to desk related api. */ adminAccess: boolean; /** Full access to channel related api. */ channelAccess: boolean; /** Allow this apikey to access all channels of this desk. */ allowAllChannel: boolean; /** List of channels this apikey has access to. No effect if allowAllChannel is enabled. */ channels: ChannelId[]; /** Desk this belongs to. */ deskId: DeskId; /** Member that created this. */ memberId: MemberId; } export interface DeskUpdateApiKeyBody { apiKeyId: ApiKeyId; deskId: DeskId; /** Name for this apikey. */ name?: string; /** Full access to desk related api. */ adminAccess?: boolean; /** Full access to channel related api. */ channelAccess?: boolean; /** Allow this apikey to access all channels of this desk. */ allowAllChannel?: boolean; /** List of channels this apikey has access to. No effect if allowAllChannel is enabled. */ channels?: ChannelId[]; } export interface DeskDeleteApiKeyBody { deskId: DeskId; apiKeyId: ApiKeyId; } export interface DeskCreateWebhookBody { deskId: DeskId; /** Name for this webhook. */ name?: string; /** Webhook callback url when new event arrives. */ url: string; /** List of events for each channel. */ channelEvents?: WebhookChannelEvents; /** List of subscripted webhook events. */ deskEvents?: WebhookDeskEvent[]; } export interface DeskCreateWebhookReply { id: WebhookId; /** Name for this webhook. */ name?: string; /** Webhook callback url when new event arrives. */ url: string; /** List of subscripted webhook events. */ deskEvents?: WebhookDeskEvent[]; /** List of events for each channel. */ channelEvents?: WebhookChannelEvents; /** Desk this belongs to. */ deskId: DeskId; /** Member that created this. */ memberId: MemberId; } export interface DeskUpdateWebhookBody { webhookId: WebhookId; deskId: DeskId; /** Name for this webhook. */ name?: string; /** Webhook callback url when new event arrives. */ url: string; /** List of events for each channel. */ channelEvents?: WebhookChannelEvents; /** List of subscripted webhook events. */ deskEvents?: WebhookDeskEvent[]; } export interface DeskDeleteWebhookBody { deskId: DeskId; webhookId: WebhookId; } export interface MemberAddBody { /** Desk scoped email. */ email?: string; /** Profile picture inside desk. Derive from user account profile picture if not provided. */ thumbnail?: string; /** Display name inside desk. Derive from user account name if not provided. */ name: string; /** Role of this member inside desk. */ role: MemberRole; /** Desk this member belongs to. */ deskId: DeskId; } export interface MemberAddReply { id: MemberId; /** Invitation token */ token: string; /** Invitation url */ url: string; } export interface MemberDeleteBody { memberId: MemberId; } export interface MemberUpdateInfoBody { memberId: MemberId; /** Display name inside desk. Derive from user account name if not provided. */ name?: string; /** Profile picture inside desk. Derive from user account profile picture if not provided. */ thumbnail?: string; /** Desk scoped email. */ email?: string; /** Role of this member inside desk. */ role?: MemberRole; } export interface UserInfoUpdateBody { /** User display name. */ name?: string; /** User avatar, if not set will infer from login method provided thumbnail. */ thumbnail?: string; /** List of biometric uuid, 1 for each channel */ biometrics?: string[]; } export interface UserDeskSortUpdateBody { /** List of deskId, desk will be displayed according to this order. */ orders: DeskId[]; } export interface UserMemberSortUpdateBody { /** Desk this member belongs to. */ deskId: DeskId; orders: MongoId[]; } export interface AuthEmailVerifyQs { /** Encrypted stringified payload. */ token: string; } export interface AuthEmailPollQs { /** Encrypted unique login id. */ token: string; /** Use local firebase emulator for login. No effect when running in production. */ skipFirebaseEmulator?: boolean; } export interface AuthFirebaseApikeyBody { /** Generate api token bounded to this firebase uid, to be used in future api calls. */ generateApiToken: boolean; } export interface AuthLoginBody { /** Firebase idToken. */ token: string; /** Use local firebase emulator for login. No effect when running in production. */ skipFirebaseEmulator?: boolean; } export interface AuthLogoutBody { sessionId?: string; } export interface AuthEmailTriggerBody { /** Email to send login link to. */ email: string; } export interface AuthEmailSwitchTriggerBody { /** Email to send login switch link to. */ email: string; } export interface AuthEmailSwitchVerifyQs { /** Encrypted stringified payload. */ token: string; } export type AuthSsoSwitchBody = AuthLoginBody; export type CompositeSearchBody = CompositeSearch; export type CompositeSearchReply = CompositeSearchResult; export type CompositeFetchBody = CompositeFetchConfig; export type CompositeFetchReply = CompositeFetchData; export interface DebugSetupMessagingAccountBody { /** Create new messaging account with custom apikey. */ apiKey: string; } export interface DebugMessagingChannelSessionUpdateBody { channelId: ChannelId; /** WhatsApp web login session credential. Store as an url to compressed chrome profile. */ session?: string; } export interface DebugChangeUserRoleBody { userId: UserId; /** User role in UCC. */ role: UserRole; } export interface DebugLinkChannelBody { channelId: ChannelId; } export type DebugTriggerFakeInboundMessageBody = MessageOutboundSendBody; export interface DebugSetupRealFirebaseAccountReply { /** Generated real firebase account email. Will always returns the same hardcoded email. */ email: string; /** Generated real firebase account password. */ password: string; } export interface OgpScrapQs { url: string; } export interface OgpScrapReply { author?: string; date?: string; description?: string; image?: string; publisher?: string; title?: string; url?: string; } export type ReportGenerateBody = ReportSetting; export interface UploadQs { deskId?: DeskId; convertToThumbnail?: boolean; shortenUrl?: boolean; } export type AutoReplyType = 'greeting' | 'bot'; export type AutoReplyBot = AutoReplyBotDialogFlow | AutoReplyBotWatson | AutoReplyBotBotpress; export type AutoReplyBotDialogFlow = AutoReplyBotDialogFlowEs | AutoReplyBotDialogFlowCx; export interface AutoReplyBotDialogFlowEs { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; throttle: boolean; provider: 'dialogflow'; /** Dialogflow google service account json file as string. */ jsonString: string; variant: 'es'; } /** * String representation of BSON ObjectId */ export type MongoId = string; export interface AutoReplyBotDialogFlowCx { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; throttle: boolean; provider: 'dialogflow'; /** Dialogflow google service account json file as string. */ jsonString: string; variant: 'cx'; /** Only required for dialogflow cx. dialogflow es only allow 1 agent per google project. */ agentId: string; } export interface AutoReplyBotWatson { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; throttle: boolean; provider: 'watson'; apiKey: string; serviceUrl: string; assistantId: string; } export interface AutoReplyBotBotpress { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; throttle: boolean; provider: 'botpress'; /** Botpress origin url. eg http://localhost:3000 */ origin: string; /** Which bot to use. */ botId: string; } export type AutoReplyGreeting = AutoReplyGreetingRecurring | AutoReplyGreetingEvent; /** * Recurring event greeting. */ export interface AutoReplyGreetingRecurring { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; /** Auto reply content, can reply multiple messages. */ contents: AutoReplyGreetingContent[]; type: 'recurring'; /** Time spans this greeting is active. */ spans: AutoReplyGreetingEventSpan[]; } export interface AutoReplyGreetingContent { /** Text to send. */ body?: string; /** Media to send. */ media?: { url: string; type: MessageMediaType }; } export type MessageMediaType = 'image' | 'sticker' | 'audio' | 'ptt' | 'video' | 'document'; export interface AutoReplyGreetingEventSpan { /** On which weekday. */ day: WeekDay; /** Greeting start replying at specific time. */ start: AutoReplyGreetingEventSpanTime; /** Greeting stop replying at specific time. */ end: AutoReplyGreetingEventSpanTime; } export type WeekDay = | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'; export interface AutoReplyGreetingEventSpanTime { /** * @min 0 * @max 23 */ hour: number; /** * @min 0 * @max 59 */ minute: number; } /** * Single one time event greeting. */ export interface AutoReplyGreetingEvent { /** String representation of BSON ObjectId */ _id: MongoId; /** Auto reply nickname. */ name: string; /** Auto reply content, can reply multiple messages. */ contents: AutoReplyGreetingContent[]; type: 'event'; /** * Greeting start replying at specific time. * @format date-time */ startAt: Date; /** * Greeting stop replying at specific time. * @format date-time */ endAt: Date; } /** * Push supported platforms */ export type PushPlatform = 'browser' | 'iosNative' | 'androidNative'; export type ChannelId = MongoId; export interface WhatsappOutboundSendPayload { platform: 'whatsapp'; /** Send location message. */ location?: { latitude: number; longitude: number; description?: string }; /** Auto generate link preview from url found inside text. */ linkPreview?: boolean; quote?: string; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export type DeskId = MongoId; export type MessageOutboundMediaType = 'image' | 'sticker' | 'audio' | 'video' | 'document' | 'ptt'; export type MessagePriority = 'low' | 'normal' | 'high' | 'urgent'; export interface MessengerOutboundSendPayload { platform: 'messenger'; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export interface WechatOutboundSendPayload { platform: 'wechat'; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export interface LineOutboundSendPayload { platform: 'line'; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export interface SmsOutboundSendPayload { platform: 'sms'; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export interface UccOutboundSendPayload { platform: 'ucc'; deskId: DeskId; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; /** Text message to send. */ body?: string; /** Send media message. */ media?: { type: MessageOutboundMediaType; url: string; caption?: string }; priority: MessagePriority; virgin?: boolean; } export type ContactId = MongoId; export type MemberId = MongoId; export interface ContactFilterChannel { platform: Platform; route: string; } export type Platform = 'whatsapp' | 'messenger' | 'wechat' | 'line' | 'ucc' | 'sms' | 'voice'; export type MessageId = MongoId; /** * Chat contact of any platform. */ export interface Contact { _id: string; /** Contact ID reference from remote system if available. */ reference?: string; /** Contact route. */ route: string; /** Channel route. Store as route instead of channelId since channel comes and go, but absolute route can be used by new channel without changes and thus can continue upon existing contact. */ channel: string; platform: Platform; /** Case Open 'O' | Closed 'C'. */ status: 'O' | 'C'; /** Optional extra remark. */ remark?: string; /** Customer reference number, for customer to setup an identifier to link with their external system. */ crn?: string; /** List of tags set by user. */ tags: string[]; /** List of assigned member ids. */ members: MemberId[]; /** Archived contact. */ archive: boolean; /** Sticky contact that always appears on top. */ sticky: boolean; /** Auto reply state for this contact. */ autoReply?: { active: boolean; provider?: AutoReplyBotProvider; contexts?: any[] | string; messageId?: MessageId; }; /** User provided contact name, if not set will infer from platform provided name, then from platform's contact route. */ name: string; /** Immutable name provided by platform. */ platformProvidedName?: string; /** Desk this contact belongs to. */ deskId: DeskId; /** Platform provided profile picture. */ thumbnail?: string; /** Group chat, only support WhatsApp for now. TODO: Ucc internal group chat can use it too to limit who can see and access the internal group chat. */ group?: GroupMetadata; /** * Last action timestamp, any contact info edit / new message for this contact will update this. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort contact. Same as last message orderAt timestamp. Must use orderAt instead of infer from last message _id as ObjectId granularity is in second meanwhile orderAt is in millisecond. * @format date-time */ orderAt: Date; /** Latest message id. */ lastMessageId: MessageId; /** * NOTE for all following properties: Frontend only variable, dynamically generated before forwarding. These are NOT SAVED into DB! * * Only exist for filtered / search result. Show the message except to display as well on contact navigation auto jump to this message. */ jumpToMessage?: Message; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** How many case this contact current have. Incremented upon new case creation. */ caseCount: number; /** Total number of inbound received message for this contact. Incremented upon new message insertion. */ inboundMessageCount: number; /** Message read by members. */ readBy: Record0; } export type AutoReplyBotProvider = 'dialogflow' | 'watson' | 'botpress'; export interface GroupMetadata { /** Group description. */ description?: string; /** Creator of this group chat. */ owner: string; /** Must specify at least of the option. Either 'admin' admin only or 'all' everyone. */ permission: GroupPermission; participants: { id: string; isAdmin: boolean; isSuperAdmin: boolean }[]; } /** * Must specify at least of the option. Either 'admin' admin only or 'all' everyone. */ export interface GroupPermission { /** Permission to send new message. */ send: GroupPermissionSend; /** Permission to edit group info. */ edit: GroupPermissionEdit; } /** * Permission to send new message. */ export type GroupPermissionSend = 'admin' | 'all'; /** * Permission to edit group info. */ export type GroupPermissionEdit = 'admin' | 'all'; export type Message = MessageChat | MessageMeta; export type MessageChat = | MessageWhatsapp | MessageMessenger | MessageWechat | MessageLine | MessageUcc | MessageSms | MessageVoice; /** * Whatsapp Message. */ export type MessageWhatsapp = MessageWhatsappSend | MessageWhatsappRecv; export interface MessageWhatsappSend { platform: 'whatsapp'; /** Message type. */ type: MessageType; /** WhatsApp message id. */ id?: string; /** * Delete initiated timestamp. Can only delete sent message. Delete from your side only, recipient copy remains intact. * @format date-time */ deletedAt?: Date; deletedBy?: MemberId; /** Whatsapp contact that created this message. Only meaningful when in group chat, marks the author of this message. */ author?: string; quote?: { meta?: { isGroup: boolean; isMedia: boolean; isForwarded: boolean; isBroadcast: boolean; isStarred: boolean; isArchived: boolean; isMuted: boolean; isBlocked: boolean; isPinned: boolean; }; id: string; wid: string; type: MessageType; direction: 'send' | 'recv'; author?: string; body: string; media?: MessageMedia; linkPreview?: MessageLinkPreview; location?: MessageLocation; product?: MessageProduct; order?: MessageOrder; payment?: MessagePayment; name: string; thumbnail?: string; group?: GroupMetadata; }; /** Url (link) auto generated preview message. */ linkPreview?: MessageLinkPreview; /** Location message, visit via https://maps.google.com/?q=<lat>,<lng> */ location?: MessageLocation; /** Product catalog message */ product?: MessageProduct; /** Order message */ order?: MessageOrder; /** Payment message */ payment?: MessagePayment; meta?: { isGroup: boolean; isMedia: boolean; isForwarded: boolean; isBroadcast: boolean; isStarred: boolean; isArchived: boolean; isMuted: boolean; isBlocked: boolean; isPinned: boolean; }; direction: 'send'; /** Triggered by who. */ memberId?: MessageMemberId; /** Triggered by which broadcast. */ broadcastId?: BroadcastId; /** Send priority, only available is sent by user, not from master phone. */ priority?: MessagePriority; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; /** * Single grey tick timestamp. * @format date-time */ sentAt?: Date; /** * Double grey tick timestamp. * @format date-time */ deliveredAt?: Date; /** * Double blue tick timestamp. * @format date-time */ readAt?: Date; /** * Media file, user clicked timestamp. * @format date-time */ playedAt?: Date; /** For group chat, detailed delivery (double grey tick) status for each group member. */ delivered?: MessageAckContent[]; /** For group chat, detailed read (double blue tick) status for each group member. */ read?: MessageAckContent[]; /** For group chat, detailed played (double blue tick) status for each group member. */ played?: MessageAckContent[]; /** * Recall initiated timestamp. Can only recall sent message. * @format date-time */ recalledAt?: Date; recalledBy?: MemberId; /** * Cancel initiated timestamp. Can only cancel if not already sent. * @format date-time */ cancelledAt?: Date; cancelledBy?: MemberId; /** * Message timeout timestamp. * @format date-time */ timeoutAt?: Date; /** * Delivery failed timestamp, due to invalid contact, banned, etc. * @format date-time */ failedAt?: Date; failedReason?: string; /** Message ack. <=0 - Irrelevant / pending 1 - single grey tick 2 - double grey tick 3 - double blue tick */ ack?: number; /** Log for each user triggered resend attempt. */ resendLogs?: { by: MemberId; at: Date; timeoutAt: Date }[]; } export type MessageType = | 'chat' | 'image' | 'sticker' | 'audio' | 'video' | 'document' | 'ptt' | 'location' | 'vcard' | 'multi_vcard' | 'revoked' | 'order' | 'product' | 'payment' | 'groups_v4_invite' | 'notification' | 'unknown'; export interface MessageMedia { /** Url to the content. */ url: string; mime?: string; /** Caption text, available for image / video only. */ caption?: string; fileName?: string; /** File hash generated by whatsapp. */ fileHash?: string; /** Media file size in byte. */ size?: number; /** Image / video frame width. */ width?: number; /** Image / video frame height. */ height?: number; /** Length of audio / video file. */ duration?: number; /** Number of pages for this document, eg pdf page count. */ pageCount?: number; } export interface MessageLinkPreview { /** Thumbnail image generated from url. eg youtube icon */ thumbnail?: string; /** A short title from url. eg 'Youtube' */ title?: string; /** Longer description from url. eg 'Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.' */ description?: string; /** Url used to generate this preview extracted from message body. */ url?: string; } /** * Location message, visit via https://maps.google.com/?q=<lat>,<lng> */ export interface MessageLocation { latitude: number; longitude: number; /** Location name, if available. */ description?: string; /** Location thumbnail. */ thumbnail?: string; } export interface MessageProduct { price?: string; url?: string; urlText?: string; urlNumber?: string; productId: string; currency?: string; description?: string; imageHeight?: number; imageWidth?: number; totalImages?: number; } export interface MessageOrder { products: MessageProduct[]; subtotal: string; total: string; currency: string; /** @format date-time */ createdAt: Date; } export type MessagePayment = object; export type MessageMemberId = | 'bot' | 'api' | 'greeting' | 'system' | 'resend' | 'broadcast' | 'external' | MemberId; export type BroadcastId = MongoId; export type Record1 = Record<string, string[]>; export interface MessageAckContent { /** @format date-time */ at: Date; /** WhatsApp Contact ID */ wid: string; } export interface MessageWhatsappRecv { platform: 'whatsapp'; /** Message type. */ type: MessageType; /** WhatsApp message id. */ id?: string; /** * Delete initiated timestamp. Can only delete sent message. Delete from your side only, recipient copy remains intact. * @format date-time */ deletedAt?: Date; deletedBy?: MemberId; /** Whatsapp contact that created this message. Only meaningful when in group chat, marks the author of this message. */ author?: string; quote?: { meta?: { isGroup: boolean; isMedia: boolean; isForwarded: boolean; isBroadcast: boolean; isStarred: boolean; isArchived: boolean; isMuted: boolean; isBlocked: boolean; isPinned: boolean; }; id: string; wid: string; type: MessageType; direction: 'send' | 'recv'; author?: string; body: string; media?: MessageMedia; linkPreview?: MessageLinkPreview; location?: MessageLocation; product?: MessageProduct; order?: MessageOrder; payment?: MessagePayment; name: string; thumbnail?: string; group?: GroupMetadata; }; /** Url (link) auto generated preview message. */ linkPreview?: MessageLinkPreview; /** Location message, visit via https://maps.google.com/?q=<lat>,<lng> */ location?: MessageLocation; /** Product catalog message */ product?: MessageProduct; /** Order message */ order?: MessageOrder; /** Payment message */ payment?: MessagePayment; meta?: { isGroup: boolean; isMedia: boolean; isForwarded: boolean; isBroadcast: boolean; isStarred: boolean; isArchived: boolean; isMuted: boolean; isBlocked: boolean; isPinned: boolean; }; direction: 'recv'; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } /** * Messenger message. */ export type MessageMessenger = MessageMessengerSend | MessageMessengerRecv; export interface MessageMessengerSend { platform: 'messenger'; type: MessageChatType; direction: 'send'; /** Triggered by who. */ memberId?: MessageMemberId; /** Triggered by which broadcast. */ broadcastId?: BroadcastId; /** Send priority, only available is sent by user, not from master phone. */ priority?: MessagePriority; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } export type MessageChatType = 'chat' | 'image' | 'sticker' | 'audio' | 'ptt' | 'video' | 'document'; export interface MessageMessengerRecv { platform: 'messenger'; type: MessageChatType; direction: 'recv'; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } /** * Wechat message. */ export type MessageWechat = MessageWechatSend | MessageWechatRecv; export interface MessageWechatSend { platform: 'wechat'; type: MessageChatType; direction: 'send'; /** Triggered by who. */ memberId?: MessageMemberId; /** Triggered by which broadcast. */ broadcastId?: BroadcastId; /** Send priority, only available is sent by user, not from master phone. */ priority?: MessagePriority; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } export interface MessageWechatRecv { platform: 'wechat'; type: MessageChatType; direction: 'recv'; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } /** * Line message. */ export type MessageLine = MessageLineSend | MessageLineRecv; export interface MessageLineSend { platform: 'line'; type: MessageChatType; direction: 'send'; /** Triggered by who. */ memberId?: MessageMemberId; /** Triggered by which broadcast. */ broadcastId?: BroadcastId; /** Send priority, only available is sent by user, not from master phone. */ priority?: MessagePriority; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } export interface MessageLineRecv { platform: 'line'; type: MessageChatType; direction: 'recv'; /** * Message timestamp displayed on remote platform. * @format date-time */ at?: Date; /** Content of this message, can be text, base64 uri media, etc depending on type. */ body: string; media?: MessageMedia; /** Channel this message belongs to. Channel may be deactivated in the future but never deleted, thus giving ability to look back and see which particular channel triggered this message in case multiple channel used the same channel route. */ channelId: ChannelId; _id: string; /** Reference ID given by remote system. */ reference?: string; /** Contact this message belongs to. */ contactId: ContactId; /** Desk this message belongs to. */ deskId: DeskId; /** * Last action timestamp. * @format date-time */ lastAt: Date; /** * Ordering timestamp, frontend uses this to sort message. Always use new Date() to generate instead of infer from _id as ObjectId granularity is second, new Date() is in millisecond. * @format date-time */ orderAt: Date; /** Unique hash value generated by combining contactId and desk scoped contact filter. Used by frontend to isolate contact data depending on filter setting. */ hash?: string; /** Highlight search matched field. */ highlight?: Record1; } /** * UCC internal group chat. Only support direction 'send', and dashboard will auto invert it ba