UNPKG

plazbot

Version:

Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.

216 lines (215 loc) 5.65 kB
export interface Contact { id: string; name?: string; phoneNumber?: string; email?: string; tags?: string[]; stage?: string; segmentation?: string; assignedAgentId?: string; assignedAgentName?: string; owner?: string; isSolved?: boolean; variables?: Record<string, string>; createdAt?: string; updatedAt?: string; } export interface ContactFilter { tags?: string[]; stage?: string; isSolved?: boolean; assignedAgentId?: string; search?: string; } export interface CreateContactParams { name?: string; phoneNumber?: string; email?: string; tags?: string[]; stage?: string; } export interface UpdateContactParams { name?: string; phoneNumber?: string; email?: string; } export interface ContactsAPI { get(id: string): Promise<Contact>; list(params?: { filter?: ContactFilter; limit?: number; offset?: number; }): Promise<Contact[]>; search(params: { phone?: string; email?: string; }): Promise<Contact[]>; create(data: CreateContactParams): Promise<Contact>; update(id: string, data: UpdateContactParams): Promise<Contact>; delete(ids: string[]): Promise<void>; setVariable(contactId: string, code: string, value: string | null): Promise<void>; getVariable(contactId: string, code: string): Promise<string | null>; addTag(contactId: string, tag: string): Promise<void>; removeTag(contactId: string, tag: string): Promise<void>; setStage(contactId: string, stageId: string): Promise<void>; setSegmentation(contactId: string, segmentationId: string): Promise<void>; assignAgent(contactId: string, agentId: string): Promise<void>; resolve(contactId: string): Promise<void>; } export interface SendMessageParams { to: string; message: string; } export interface TemplateVariable { variable: string; value: string; } export interface TemplateFile { fileUrl: string; fileName: string; } export interface SendTemplateParams { to: string; template: string; variablesBody?: TemplateVariable[]; variablesHeader?: TemplateVariable[]; file?: TemplateFile; } export interface MessageResult { success?: boolean; messageId?: string; } export interface Message { id: string; content?: string; contentUrl?: string; from?: string; to?: string; timestamp?: string; type?: string; direction?: 'incoming' | 'outgoing'; } export interface WhatsAppAPI { send(params: SendMessageParams): Promise<MessageResult>; sendTemplate(params: SendTemplateParams): Promise<MessageResult>; getHistory(contactId: string, params?: { limit?: number; }): Promise<Message[]>; } export interface Agent { id: string; name: string; description?: string; prompt: string; color?: string; enable?: boolean; tags?: string[]; } export interface AgentResponse { answer: string; sources?: { title?: string; url?: string; content?: string; }[]; actionsExecuted?: { name?: string; intent?: string; result?: unknown; }[]; } export interface AgentsAPI { get(id: string): Promise<Agent>; list(): Promise<Agent[]>; chat(params: { agentId: string; question: string; sessionId: string; }): Promise<AgentResponse>; } export interface Conversation { contactId: string; isSolved: boolean; assignedAgentId?: string; assignedMemberId?: string; lastMessageAt?: string; unreadCount?: number; } export interface ConversationsAPI { get(contactId: string): Promise<Conversation>; getMessages(contactId: string, params?: { limit?: number; }): Promise<Message[]>; addNote(contactId: string, content: string): Promise<void>; resolve(contactId: string): Promise<void>; reopen(contactId: string): Promise<void>; } export interface WhatsAppTemplate { id: string; name: string; status: string; language?: string; category?: string; components?: unknown[]; } export interface TemplatesAPI { list(): Promise<WhatsAppTemplate[]>; getActive(): Promise<WhatsAppTemplate[]>; } export interface WorkspaceVariable { code: string; name: string; type?: string; } export interface Tag { id: string; name: string; color?: string; } export interface Stage { id: string; name: string; order?: number; } export interface Member { id: string; name: string; email: string; role?: string; } export interface WorkspaceAPI { getVariables(): Promise<WorkspaceVariable[]>; getTags(): Promise<Tag[]>; getStages(): Promise<Stage[]>; getMembers(): Promise<Member[]>; } export interface KVSetOptions { /** TTL en segundos */ ttl?: number; } export interface KVEntry { key: string; value: unknown; } export interface KVStore { get<T = string>(key: string): Promise<T | null>; set(key: string, value: unknown, options?: KVSetOptions): Promise<void>; delete(key: string): Promise<void>; list(prefix?: string): Promise<KVEntry[]>; } export interface Logger { info(message: string, data?: unknown): void; warn(message: string, data?: unknown): void; error(message: string, data?: unknown): void; } export interface PlazbotAPI { contacts: ContactsAPI; whatsapp: WhatsAppAPI; agents: AgentsAPI; conversations: ConversationsAPI; templates: TemplatesAPI; workspace: WorkspaceAPI; kv: KVStore; fetch(url: string, options?: RequestInit): Promise<Response>; log: Logger; }