/** * Weave Integration for WORKWAY * * Patient communication platform for dental and medical practices. * Designed for automated patient outreach - SMS reminders, review requests, * and missed call follow-ups. * * Zuhandenheit: "Reviews that request themselves" not "POST /messages endpoint" * * @example * ```typescript * import { Weave } from '@workwayco/integrations/weave'; * * const weave = new Weave({ * apiKey: env.WEAVE_API_KEY, * locationId: 'loc_123', * }); * * // Send appointment reminder * await weave.sendAppointmentReminder({ * patientPhone: '+15551234567', * patientName: 'John', * appointmentTime: '2024-01-15T10:00:00Z', * practiceName: 'Smile Dental', * }); * * // Request review after visit * await weave.requestReview({ * patientPhone: '+15551234567', * patientName: 'John', * reviewUrl: 'https://g.page/r/...', * }); * ``` */ import { ActionResult } from '@workwayco/sdk'; import { BaseAPIClient } from '../core/index.js'; /** * Weave integration configuration */ export interface WeaveConfig { /** API key */ apiKey: string; /** Location ID */ locationId: string; /** Optional: Override API endpoint (for testing) */ apiUrl?: string; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; } /** * Weave Message */ export interface WVMessage { id: string; location_id: string; thread_id: string; direction: 'inbound' | 'outbound'; body: string; status: WVMessageStatus; phone_number: string; patient_id?: string; created_at: string; updated_at: string; delivered_at?: string; read_at?: string; } /** * Weave Message Status */ export type WVMessageStatus = 'queued' | 'sending' | 'sent' | 'delivered' | 'failed' | 'received'; /** * Weave Thread (conversation) */ export interface WVThread { id: string; location_id: string; phone_number: string; patient_id?: string; patient_name?: string; last_message_at: string; unread_count: number; status: 'active' | 'archived'; } /** * Weave Review Request */ export interface WVReviewRequest { id: string; location_id: string; patient_phone: string; patient_name?: string; review_url: string; status: 'pending' | 'sent' | 'clicked' | 'completed' | 'failed'; sent_at?: string; clicked_at?: string; completed_at?: string; created_at: string; } /** * Weave Call Log */ export interface WVCallLog { id: string; location_id: string; direction: 'inbound' | 'outbound'; phone_number: string; caller_id?: string; status: 'answered' | 'missed' | 'voicemail' | 'busy' | 'failed'; duration?: number; recording_url?: string; patient_id?: string; started_at: string; ended_at?: string; } /** * Weave Patient (contact) */ export interface WVPatient { id: string; location_id: string; first_name: string; last_name: string; phone_number: string; email?: string; date_of_birth?: string; external_id?: string; tags?: string[]; created_at: string; updated_at: string; } /** * Weave Location */ export interface WVLocation { id: string; name: string; phone_number: string; address?: { line1?: string; city?: string; state?: string; zip?: string; }; timezone: string; review_url?: string; } export interface SendMessageOptions { /** Recipient phone number (E.164 format) */ phoneNumber: string; /** Message body */ body: string; /** Patient ID (optional, for linking) */ patientId?: string; } export interface SendAppointmentReminderOptions { /** Patient phone number */ patientPhone: string; /** Patient first name */ patientName: string; /** Appointment time (ISO string) */ appointmentTime: string; /** Practice name */ practiceName: string; /** Provider name (optional) */ providerName?: string; /** Custom message (optional, uses template if not provided) */ customMessage?: string; /** Include confirmation reply option */ includeConfirmation?: boolean; } export interface RequestReviewOptions { /** Patient phone number */ patientPhone: string; /** Patient first name */ patientName: string; /** Review URL (Google, Yelp, etc.) */ reviewUrl?: string; /** Practice name */ practiceName?: string; /** Custom message (optional) */ customMessage?: string; /** Delay before sending (minutes) */ delayMinutes?: number; } export interface ListMessagesOptions { /** Filter by phone number */ phoneNumber?: string; /** Filter by thread ID */ threadId?: string; /** Filter by direction */ direction?: 'inbound' | 'outbound'; /** Start date (ISO string) */ startDate?: string; /** End date (ISO string) */ endDate?: string; /** Page number */ page?: number; /** Results per page */ perPage?: number; } export interface ListCallsOptions { /** Filter by phone number */ phoneNumber?: string; /** Filter by status */ status?: 'answered' | 'missed' | 'voicemail'; /** Start date (ISO string) */ startDate?: string; /** End date (ISO string) */ endDate?: string; /** Page number */ page?: number; /** Results per page */ perPage?: number; } export interface GetMissedCallsOptions { /** Time window in hours (default: 24) */ hoursBack?: number; /** Only return calls not yet followed up */ unfollowedOnly?: boolean; } /** * Weave Patient Communication Integration * * Weniger, aber besser: Unified patient messaging for practice automation. */ export declare class Weave extends BaseAPIClient { private readonly locationId; constructor(config: WeaveConfig); /** * Send a text message */ sendMessage(options: SendMessageOptions): Promise>; /** * Send appointment reminder (Zuhandenheit API) * * Outcome-focused: "Remind patient about their appointment" */ sendAppointmentReminder(options: SendAppointmentReminderOptions): Promise>; /** * Send no-show follow-up (Zuhandenheit API) * * Outcome-focused: "Follow up with patient who missed appointment" */ sendNoShowFollowUp(options: { patientPhone: string; patientName: string; practiceName: string; customMessage?: string; }): Promise>; /** * List messages with optional filters */ listMessages(options?: ListMessagesOptions): Promise>; /** * Get message threads (conversations) */ listThreads(options?: { page?: number; perPage?: number; }): Promise>; /** * Get unread message count (Zuhandenheit API) * * Outcome-focused: "Do I have messages to respond to?" */ getUnreadCount(): Promise>; /** * Request a review (Zuhandenheit API) * * Outcome-focused: "Ask satisfied patient for a review" */ requestReview(options: RequestReviewOptions): Promise>; /** * List review requests */ listReviewRequests(options?: { status?: 'pending' | 'sent' | 'clicked' | 'completed'; page?: number; perPage?: number; }): Promise>; /** * Get review request stats (Zuhandenheit API) * * Outcome-focused: "How are our review requests performing?" */ getReviewStats(days?: number): Promise>; /** * List call logs */ listCalls(options?: ListCallsOptions): Promise>; /** * Get missed calls (Zuhandenheit API) * * Outcome-focused: "Who do I need to call back?" */ getMissedCalls(options?: GetMissedCallsOptions): Promise>; /** * Send missed call follow-up (Zuhandenheit API) * * Outcome-focused: "Follow up with caller we missed" */ sendMissedCallFollowUp(options: { phoneNumber: string; practiceName: string; customMessage?: string; }): Promise>; /** * Get patient by phone number */ getPatientByPhone(phoneNumber: string): Promise>; /** * Search patients */ searchPatients(query: string): Promise>; /** * Get location details */ getLocation(): Promise>; /** * Verify Weave webhook signature */ verifyWebhook(payload: string, signature: string, secret: string): Promise>; /** * Normalize phone number to E.164 format */ private normalizePhone; private getCapabilities; } export interface WVWebhookEvent { event: string; location_id: string; data: { message?: WVMessage; call?: WVCallLog; review_request?: WVReviewRequest; }; created_at: string; } //# sourceMappingURL=index.d.ts.map