@ecodrix/erix-api 1.0.1 → 1.0.4
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/dist/cli.js +38 -0
- package/dist/index.d.cts +1979 -0
- package/dist/index.d.ts +1173 -313
- package/dist/ts/browser/index.global.js +14 -14
- package/dist/ts/browser/index.global.js.map +1 -1
- package/dist/ts/cjs/index.cjs +1 -1
- package/dist/ts/cjs/index.cjs.map +1 -1
- package/dist/ts/cjs/index.d.cts +1173 -313
- package/dist/ts/esm/index.d.ts +1173 -313
- package/dist/ts/esm/index.js +1 -1
- package/dist/ts/esm/index.js.map +1 -1
- package/package.json +18 -13
- package/src/cli.ts +305 -0
- package/src/core.ts +28 -12
- package/src/index.ts +22 -8
- package/src/resource.ts +21 -1
- package/src/resources/crm/activities.ts +89 -0
- package/src/resources/crm/analytics.ts +89 -0
- package/src/resources/crm/automationDashboard.ts +24 -0
- package/src/resources/crm/automations.ts +151 -0
- package/src/resources/crm/index.ts +25 -1
- package/src/resources/crm/leads.ts +178 -45
- package/src/resources/crm/payments.ts +16 -0
- package/src/resources/crm/pipelines.ts +119 -0
- package/src/resources/crm/scoring.ts +33 -0
- package/src/resources/crm/sequences.ts +28 -0
- package/src/resources/email.ts +2 -5
- package/src/resources/events.ts +52 -2
- package/src/resources/health.ts +63 -0
- package/src/resources/marketing.ts +111 -0
- package/src/resources/media.ts +1 -4
- package/src/resources/meet.ts +12 -2
- package/src/resources/notifications.ts +30 -0
- package/src/resources/queue.ts +39 -0
- package/src/resources/storage.ts +72 -0
- package/src/resources/webhooks.ts +3 -8
- package/src/resources/whatsapp/broadcasts.ts +31 -0
- package/src/resources/whatsapp/conversations.ts +39 -9
- package/src/resources/whatsapp/index.ts +20 -2
- package/src/resources/whatsapp/messages.ts +24 -0
- package/src/resources/whatsapp/templates.ts +109 -0
package/dist/ts/cjs/index.d.cts
CHANGED
|
@@ -16,193 +16,247 @@ declare abstract class APIResource {
|
|
|
16
16
|
constructor(client: AxiosInstance);
|
|
17
17
|
protected post<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
18
18
|
protected get<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
19
|
+
protected patch<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
20
|
+
protected put<T>(url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
19
21
|
protected deleteRequest<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
20
22
|
private buildConfig;
|
|
21
23
|
private handleError;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* Recipient's phone number in E.164 format.
|
|
30
|
-
* @example "+919876543210"
|
|
31
|
-
*/
|
|
32
|
-
to: string;
|
|
33
|
-
/** Plain text body of the message. */
|
|
34
|
-
text?: string;
|
|
35
|
-
/** Public URL of the media asset to send. */
|
|
36
|
-
mediaUrl?: string;
|
|
37
|
-
/** MIME category of the media. */
|
|
38
|
-
mediaType?: "image" | "video" | "audio" | "document";
|
|
39
|
-
/** The `messageId` of the message to reply to (quoted replies). */
|
|
40
|
-
replyToId?: string;
|
|
41
|
-
/** Filename shown to the recipient (required for `document` type). */
|
|
42
|
-
filename?: string;
|
|
43
|
-
/** Arbitrary metadata stored with the message record. */
|
|
26
|
+
interface LogActivityParams {
|
|
27
|
+
leadId: string;
|
|
28
|
+
type: "note" | "call" | "email" | "meeting" | "whatsapp" | "system";
|
|
29
|
+
title: string;
|
|
30
|
+
body?: string;
|
|
44
31
|
metadata?: Record<string, any>;
|
|
45
32
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
interface LogCallParams {
|
|
34
|
+
durationMinutes: number;
|
|
35
|
+
summary: string;
|
|
36
|
+
outcome: "answered" | "no_answer" | "busy" | "voicemail" | "wrong_number";
|
|
37
|
+
}
|
|
38
|
+
declare class Notes extends APIResource {
|
|
50
39
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @example "+919876543210"
|
|
40
|
+
* List all notes for a specific lead.
|
|
53
41
|
*/
|
|
54
|
-
|
|
55
|
-
/** The exact template name as approved in Meta Business Manager. */
|
|
56
|
-
templateName: string;
|
|
42
|
+
list<T = any>(leadId: string): Promise<T>;
|
|
57
43
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @default "en_US"
|
|
44
|
+
* Add a note to a lead.
|
|
60
45
|
*/
|
|
61
|
-
|
|
46
|
+
create<T = any>(leadId: string, params: {
|
|
47
|
+
content: string;
|
|
48
|
+
}): Promise<T>;
|
|
62
49
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @example ["Alice", "10 April 2026", "10:00 AM"]
|
|
50
|
+
* Update an existing note.
|
|
65
51
|
*/
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
update<T = any>(noteId: string, content: string): Promise<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Pin or unpin a note to the top of the feed.
|
|
55
|
+
*/
|
|
56
|
+
pin<T = any>(noteId: string, isPinned?: boolean): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete a note.
|
|
59
|
+
*/
|
|
60
|
+
delete(noteId: string): Promise<unknown>;
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Access via `ecod.whatsapp.messages`.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* await ecod.whatsapp.messages.send({
|
|
80
|
-
* to: "+919876543210",
|
|
81
|
-
* text: "Your appointment is confirmed!",
|
|
82
|
-
* });
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
declare class Messages extends APIResource {
|
|
62
|
+
declare class Activities extends APIResource {
|
|
63
|
+
notes: Notes;
|
|
64
|
+
constructor(client: any);
|
|
86
65
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* For text-only messages, supply `text`. For media, supply `mediaUrl`
|
|
90
|
-
* and `mediaType`. Both can be combined.
|
|
91
|
-
*
|
|
92
|
-
* @param params - Message parameters.
|
|
93
|
-
* @returns The created message record.
|
|
94
|
-
*
|
|
95
|
-
* @example Text message
|
|
96
|
-
* ```typescript
|
|
97
|
-
* await ecod.whatsapp.messages.send({
|
|
98
|
-
* to: "+919876543210",
|
|
99
|
-
* text: "Hello!",
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* @example Media message
|
|
104
|
-
* ```typescript
|
|
105
|
-
* await ecod.whatsapp.messages.send({
|
|
106
|
-
* to: "+919876543210",
|
|
107
|
-
* mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
|
|
108
|
-
* mediaType: "document",
|
|
109
|
-
* filename: "invoice.pdf",
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
66
|
+
* Retrieve the complete chronological timeline for a lead.
|
|
112
67
|
*/
|
|
113
|
-
|
|
68
|
+
timeline<T = any>(leadId: string, params?: {
|
|
69
|
+
page?: number;
|
|
70
|
+
limit?: number;
|
|
71
|
+
}): Promise<T>;
|
|
114
72
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* Templates must be approved in Meta Business Manager before use.
|
|
118
|
-
* Variable placeholders in the template body are filled left-to-right
|
|
119
|
-
* from the `variables` array.
|
|
120
|
-
*
|
|
121
|
-
* @param params - Template message parameters.
|
|
122
|
-
* @returns The created message record.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* await ecod.whatsapp.messages.sendTemplate({
|
|
127
|
-
* to: "+919876543210",
|
|
128
|
-
* templateName: "appointment_reminder",
|
|
129
|
-
* language: "en_US",
|
|
130
|
-
* variables: ["Alice", "10 April", "10:00 AM"],
|
|
131
|
-
* });
|
|
132
|
-
* ```
|
|
73
|
+
* List specific activities (filtered by type).
|
|
133
74
|
*/
|
|
134
|
-
|
|
75
|
+
list<T = any>(leadId: string, params?: {
|
|
76
|
+
type?: string;
|
|
77
|
+
page?: number;
|
|
78
|
+
limit?: number;
|
|
79
|
+
}): Promise<T>;
|
|
135
80
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @param conversationId - The conversation to mark as read.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* await ecod.whatsapp.messages.markRead("conv_64abc...");
|
|
143
|
-
* ```
|
|
81
|
+
* Generic method to log a business activity/event.
|
|
144
82
|
*/
|
|
145
|
-
|
|
83
|
+
log<T = any>(params: LogActivityParams): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Specific method to log communication outcomes.
|
|
86
|
+
*/
|
|
87
|
+
logCall<T = any>(leadId: string, params: LogCallParams): Promise<T>;
|
|
146
88
|
}
|
|
147
89
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
90
|
+
type AnalyticsRange = "24h" | "7d" | "30d" | "60d" | "90d" | "365d";
|
|
91
|
+
interface AnalyticsParams {
|
|
92
|
+
range?: AnalyticsRange;
|
|
93
|
+
from?: string;
|
|
94
|
+
to?: string;
|
|
95
|
+
pipelineId?: string;
|
|
151
96
|
}
|
|
152
|
-
declare class
|
|
97
|
+
declare class Analytics extends APIResource {
|
|
153
98
|
/**
|
|
154
|
-
*
|
|
99
|
+
* KPIs: total leads, pipeline value, won revenue, avg score, conversion rate.
|
|
155
100
|
*/
|
|
156
|
-
|
|
101
|
+
overview<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
157
102
|
/**
|
|
158
|
-
*
|
|
103
|
+
* Stage-by-stage lead counts and conversion percentages.
|
|
159
104
|
*/
|
|
160
|
-
|
|
105
|
+
funnel<T = any>(pipelineId: string): Promise<T>;
|
|
161
106
|
/**
|
|
162
|
-
*
|
|
107
|
+
* Revenue forecast: deal value × stage probability.
|
|
163
108
|
*/
|
|
164
|
-
|
|
109
|
+
forecast<T = any>(pipelineId?: string): Promise<T>;
|
|
165
110
|
/**
|
|
166
|
-
*
|
|
111
|
+
* Lead source breakdown: count, conversion rate, total value per source.
|
|
167
112
|
*/
|
|
168
|
-
|
|
113
|
+
sources<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
169
114
|
/**
|
|
170
|
-
*
|
|
115
|
+
* Team leaderboard: won deals, revenue, activity count, conversion rate per member.
|
|
116
|
+
*/
|
|
117
|
+
team<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Daily activity counts by type. For activity calendar.
|
|
120
|
+
*/
|
|
121
|
+
heatmap<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Score distribution: how many leads in each score bucket.
|
|
124
|
+
*/
|
|
125
|
+
scores<T = any>(): Promise<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Avg time leads spend in each stage. Helps find bottlenecks.
|
|
128
|
+
*/
|
|
129
|
+
stageTime<T = any>(pipelineId: string): Promise<T>;
|
|
130
|
+
/**
|
|
131
|
+
* Tiered Growth Report matching business sophistication.
|
|
132
|
+
*/
|
|
133
|
+
tiered<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
134
|
+
/**
|
|
135
|
+
* Consolidated analytics including CRM overview and WhatsApp.
|
|
136
|
+
*/
|
|
137
|
+
summary<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
138
|
+
/**
|
|
139
|
+
* WhatsApp volume and delivery analytics.
|
|
171
140
|
*/
|
|
172
|
-
|
|
141
|
+
whatsapp<T = any>(params?: AnalyticsParams): Promise<T>;
|
|
173
142
|
}
|
|
174
143
|
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
144
|
+
declare class AutomationDashboard extends APIResource {
|
|
145
|
+
/**
|
|
146
|
+
* Retrieve summary statistics for automation health.
|
|
147
|
+
*/
|
|
148
|
+
stats<T = any>(): Promise<T>;
|
|
149
|
+
/**
|
|
150
|
+
* List recent EventLog entries (automation logs).
|
|
151
|
+
*/
|
|
152
|
+
logs<T = any>(params?: {
|
|
153
|
+
limit?: number;
|
|
154
|
+
status?: string;
|
|
155
|
+
}): Promise<T>;
|
|
156
|
+
/**
|
|
157
|
+
* Re-emit a failed event log to process its automations again.
|
|
158
|
+
*/
|
|
159
|
+
retryFailedEvent<T = any>(logId: string): Promise<T>;
|
|
186
160
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
161
|
+
|
|
162
|
+
interface AutomationRulePayload {
|
|
163
|
+
name: string;
|
|
164
|
+
trigger: string;
|
|
165
|
+
isActive?: boolean;
|
|
166
|
+
nodes: any[];
|
|
167
|
+
edges: any[];
|
|
168
|
+
}
|
|
169
|
+
declare class Automations extends APIResource {
|
|
191
170
|
/**
|
|
192
|
-
*
|
|
193
|
-
|
|
171
|
+
* List all automation rules for the tenant.
|
|
172
|
+
*/
|
|
173
|
+
list<T = any>(): Promise<T>;
|
|
174
|
+
/**
|
|
175
|
+
* Create a new automation rule.
|
|
176
|
+
*/
|
|
177
|
+
create<T = any>(payload: AutomationRulePayload): Promise<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Update an existing automation rule.
|
|
180
|
+
*/
|
|
181
|
+
update<T = any>(ruleId: string, payload: Partial<AutomationRulePayload>): Promise<T>;
|
|
182
|
+
/**
|
|
183
|
+
* Enable or disable an automation rule.
|
|
184
|
+
*/
|
|
185
|
+
toggle<T = any>(ruleId: string): Promise<T>;
|
|
186
|
+
/**
|
|
187
|
+
* Delete an automation rule.
|
|
188
|
+
*/
|
|
189
|
+
deleteRule<T = any>(ruleId: string): Promise<T>;
|
|
190
|
+
/**
|
|
191
|
+
* Bulk delete rules.
|
|
192
|
+
*/
|
|
193
|
+
bulkDelete<T = any>(ruleIds: string[]): Promise<T>;
|
|
194
|
+
/**
|
|
195
|
+
* Dry-run test an automation rule against a specific lead.
|
|
196
|
+
*/
|
|
197
|
+
test<T = any>(ruleId: string, leadId: string): Promise<T>;
|
|
198
|
+
/**
|
|
199
|
+
* Get available event triggers for automations.
|
|
200
|
+
*/
|
|
201
|
+
getAvailableEvents<T = any>(): Promise<T>;
|
|
202
|
+
/**
|
|
203
|
+
* List enrollments for a rule.
|
|
204
|
+
*/
|
|
205
|
+
enrollments<T = any>(ruleId: string, params?: {
|
|
206
|
+
status?: string;
|
|
207
|
+
page?: number;
|
|
208
|
+
limit?: number;
|
|
209
|
+
startDate?: string;
|
|
210
|
+
endDate?: string;
|
|
211
|
+
}): Promise<T>;
|
|
212
|
+
/**
|
|
213
|
+
* Get an enrollment detail.
|
|
214
|
+
*/
|
|
215
|
+
getEnrollment<T = any>(enrollmentId: string): Promise<T>;
|
|
216
|
+
/**
|
|
217
|
+
* Pause an enrollment.
|
|
218
|
+
*/
|
|
219
|
+
pauseEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
220
|
+
/**
|
|
221
|
+
* Resume an enrollment.
|
|
222
|
+
*/
|
|
223
|
+
resumeEnrollment<T = any>(ruleId: string, enrollmentId: string): Promise<T>;
|
|
224
|
+
/**
|
|
225
|
+
* List workflow runs.
|
|
226
|
+
*/
|
|
227
|
+
runs<T = any>(ruleId: string): Promise<T>;
|
|
228
|
+
/**
|
|
229
|
+
* Get run details.
|
|
230
|
+
*/
|
|
231
|
+
getRun<T = any>(runId: string): Promise<T>;
|
|
232
|
+
/**
|
|
233
|
+
* Resume a paused run.
|
|
234
|
+
*/
|
|
235
|
+
resumeRun<T = any>(runId: string): Promise<T>;
|
|
236
|
+
/**
|
|
237
|
+
* Abort a running workflow.
|
|
238
|
+
*/
|
|
239
|
+
abortRun<T = any>(runId: string): Promise<T>;
|
|
240
|
+
/**
|
|
241
|
+
* Emit an external webhook event to unlock a `wait_event` node inside a
|
|
242
|
+
* paused workflow run. Required when integrating third-party tools that
|
|
243
|
+
* need to resume a suspended automation.
|
|
194
244
|
*
|
|
195
|
-
* @param
|
|
196
|
-
* @
|
|
245
|
+
* @param ruleId - The automation rule that contains the wait_event node.
|
|
246
|
+
* @param eventName - The event name that should match the node's condition.
|
|
247
|
+
* @param payload - Arbitrary data forwarded to the node context.
|
|
197
248
|
*/
|
|
198
|
-
|
|
199
|
-
success: boolean;
|
|
200
|
-
messageId?: string;
|
|
201
|
-
templateName?: string;
|
|
202
|
-
resolvedVariables?: any[];
|
|
203
|
-
}>;
|
|
249
|
+
webhookEvent<T = any>(ruleId: string, eventName: string, payload?: any): Promise<T>;
|
|
204
250
|
}
|
|
205
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Valid statuses for a CRM Lead.
|
|
254
|
+
*/
|
|
255
|
+
type LeadStatus = "new" | "contacted" | "qualified" | "won" | "lost" | "archived";
|
|
256
|
+
/**
|
|
257
|
+
* Common lead acquisition sources. Additional string values are allowed.
|
|
258
|
+
*/
|
|
259
|
+
type LeadSource = "website" | "whatsapp" | "direct" | "referral" | string;
|
|
206
260
|
/**
|
|
207
261
|
* Parameters for creating a new CRM Lead.
|
|
208
262
|
*/
|
|
@@ -217,11 +271,50 @@ interface CreateLeadParams {
|
|
|
217
271
|
phone?: string;
|
|
218
272
|
/**
|
|
219
273
|
* Acquisition channel.
|
|
220
|
-
* @example "website" | "whatsapp" | "direct" | "referral"
|
|
221
274
|
*/
|
|
222
|
-
source?:
|
|
275
|
+
source?: LeadSource;
|
|
223
276
|
/** Arbitrary key-value metadata (UTM params, order IDs, etc.). */
|
|
224
277
|
metadata?: Record<string, any>;
|
|
278
|
+
/** Pipeline ID to assign the lead */
|
|
279
|
+
pipelineId?: string;
|
|
280
|
+
/** Stage ID to assign the lead */
|
|
281
|
+
stageId?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Options for listing leads.
|
|
285
|
+
*/
|
|
286
|
+
interface ListLeadsParams {
|
|
287
|
+
status?: LeadStatus;
|
|
288
|
+
pipelineId?: string;
|
|
289
|
+
stageId?: string;
|
|
290
|
+
source?: LeadSource;
|
|
291
|
+
assignedTo?: string;
|
|
292
|
+
tags?: string[] | string;
|
|
293
|
+
minScore?: number;
|
|
294
|
+
search?: string;
|
|
295
|
+
startDate?: string;
|
|
296
|
+
endDate?: string;
|
|
297
|
+
appointmentId?: string;
|
|
298
|
+
bookingId?: string;
|
|
299
|
+
orderId?: string;
|
|
300
|
+
meetingId?: string;
|
|
301
|
+
page?: number;
|
|
302
|
+
limit?: number;
|
|
303
|
+
sortBy?: string;
|
|
304
|
+
sortDir?: "asc" | "desc";
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Options for upserting a lead.
|
|
308
|
+
*/
|
|
309
|
+
interface UpsertLeadParams {
|
|
310
|
+
leadData: Partial<CreateLeadParams> & {
|
|
311
|
+
phone: string;
|
|
312
|
+
name?: string;
|
|
313
|
+
};
|
|
314
|
+
moduleInfo?: any;
|
|
315
|
+
trigger?: string;
|
|
316
|
+
pipelineId?: string;
|
|
317
|
+
stageId?: string;
|
|
225
318
|
}
|
|
226
319
|
/**
|
|
227
320
|
* CRM Lead resource — full lifecycle management.
|
|
@@ -243,16 +336,15 @@ declare class Leads extends APIResource {
|
|
|
243
336
|
*
|
|
244
337
|
* @param params - Lead creation parameters. `firstName` is required.
|
|
245
338
|
* @returns The newly created Lead document.
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* const { data } = await ecod.crm.leads.create({
|
|
250
|
-
* firstName: "Alice",
|
|
251
|
-
* phone: "+919876543210",
|
|
252
|
-
* });
|
|
253
|
-
* ```
|
|
254
339
|
*/
|
|
255
340
|
create<T = any>(params: CreateLeadParams): Promise<T>;
|
|
341
|
+
/**
|
|
342
|
+
* Upsert a lead by phone number. Creates if not exists, updates if exists.
|
|
343
|
+
*
|
|
344
|
+
* @param params - Upsert parameters containing leadData with a phone number.
|
|
345
|
+
* @returns The newly created or updated Lead document.
|
|
346
|
+
*/
|
|
347
|
+
upsert<T = any>(params: UpsertLeadParams): Promise<T>;
|
|
256
348
|
/**
|
|
257
349
|
* Bulk ingest leads efficiently in parallel using automatic chunking.
|
|
258
350
|
* Prevents rate limit exhaustion by executing `chunkSize` requests at a time.
|
|
@@ -262,74 +354,567 @@ declare class Leads extends APIResource {
|
|
|
262
354
|
* @returns Array of created lead results.
|
|
263
355
|
*/
|
|
264
356
|
createMany(leads: CreateLeadParams[], chunkSize?: number): Promise<any[]>;
|
|
357
|
+
/**
|
|
358
|
+
* Bulk upsert (import) leads.
|
|
359
|
+
*
|
|
360
|
+
* @param leads - Array of leads to import.
|
|
361
|
+
*/
|
|
362
|
+
import<T = any>(leads: Partial<CreateLeadParams>[]): Promise<T>;
|
|
265
363
|
/**
|
|
266
364
|
* List leads with optional filtering and pagination.
|
|
267
365
|
*
|
|
268
366
|
* @param params - Filter options (status, source, pipelineId, page, limit, etc.)
|
|
269
367
|
* @returns Paginated list of Lead documents.
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```typescript
|
|
273
|
-
* const { data } = await ecod.crm.leads.list({ status: "new", limit: 25 });
|
|
274
|
-
* ```
|
|
275
368
|
*/
|
|
276
|
-
list<T = any>(params?:
|
|
369
|
+
list<T = any>(params?: ListLeadsParams): Promise<T>;
|
|
277
370
|
/**
|
|
278
371
|
* Auto-paginating iterator for leads.
|
|
279
372
|
* Seamlessly fetches leads page by page as you iterate.
|
|
280
373
|
*
|
|
281
374
|
* @example
|
|
282
375
|
* ```typescript
|
|
283
|
-
* for await (const lead of ecod.crm.leads.listAutoPaging(
|
|
376
|
+
* for await (const lead of ecod.crm.leads.listAutoPaging<Lead>()) {
|
|
284
377
|
* console.log(lead.firstName);
|
|
285
378
|
* }
|
|
286
379
|
* ```
|
|
287
380
|
*/
|
|
288
|
-
listAutoPaging(params?:
|
|
381
|
+
listAutoPaging<T = any>(params?: ListLeadsParams): AsyncGenerator<T, void, unknown>;
|
|
289
382
|
/**
|
|
290
383
|
* Retrieve a single lead by its unique ID.
|
|
291
384
|
*
|
|
292
385
|
* @param leadId - The MongoDB ObjectId of the lead.
|
|
293
386
|
* @returns The Lead document, or a 404 error if not found.
|
|
387
|
+
*/
|
|
388
|
+
retrieve<T = any>(leadId: string): Promise<T>;
|
|
389
|
+
/**
|
|
390
|
+
* Retrieve a single lead by its phone number.
|
|
294
391
|
*
|
|
295
|
-
* @
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
392
|
+
* @param phone - Lead's phone number.
|
|
393
|
+
*/
|
|
394
|
+
retrieveByPhone<T = any>(phone: string): Promise<T>;
|
|
395
|
+
/**
|
|
396
|
+
* Retrieve a single lead by a reference key and value.
|
|
397
|
+
*
|
|
398
|
+
* @param refKey - Reference key metadata.
|
|
399
|
+
* @param refValue - Reference value.
|
|
299
400
|
*/
|
|
300
|
-
|
|
401
|
+
retrieveByRef<T = any>(refKey: string, refValue: string): Promise<T>;
|
|
301
402
|
/**
|
|
302
403
|
* Update the fields of an existing lead.
|
|
303
404
|
*
|
|
304
405
|
* @param leadId - The ID of the lead to update.
|
|
305
406
|
* @param params - Partial lead fields to update.
|
|
306
407
|
* @returns The updated Lead document.
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* ```typescript
|
|
310
|
-
* await ecod.crm.leads.update("64abc...", { email: "new@email.com" });
|
|
311
|
-
* ```
|
|
312
408
|
*/
|
|
313
|
-
update(leadId: string, params: Partial<CreateLeadParams>): Promise<
|
|
409
|
+
update<T = any>(leadId: string, params: Partial<CreateLeadParams>): Promise<T>;
|
|
314
410
|
/**
|
|
315
|
-
*
|
|
316
|
-
* for audit purposes but is excluded from all standard list views.
|
|
411
|
+
* Move a lead to a new stage in a pipeline.
|
|
317
412
|
*
|
|
318
|
-
* @param leadId -
|
|
413
|
+
* @param leadId - ID of the lead.
|
|
414
|
+
* @param stageId - Target stage ID.
|
|
415
|
+
*/
|
|
416
|
+
move<T = any>(leadId: string, stageId: string): Promise<T>;
|
|
417
|
+
/**
|
|
418
|
+
* Convert a lead (mark as won or lost with reason).
|
|
319
419
|
*
|
|
320
|
-
* @
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
|
|
420
|
+
* @param leadId - ID of the lead.
|
|
421
|
+
* @param outcome - "won" | "lost"
|
|
422
|
+
* @param reason - Reason for the outcome.
|
|
423
|
+
*/
|
|
424
|
+
convert<T = any>(leadId: string, outcome: "won" | "lost", reason?: string): Promise<T>;
|
|
425
|
+
/**
|
|
426
|
+
* Update the tags of a lead.
|
|
427
|
+
*
|
|
428
|
+
* @param leadId - ID of the lead.
|
|
429
|
+
* @param options - Tags to add or remove.
|
|
430
|
+
*/
|
|
431
|
+
tags<T = any>(leadId: string, options: {
|
|
432
|
+
add?: string[];
|
|
433
|
+
remove?: string[];
|
|
434
|
+
}): Promise<T>;
|
|
435
|
+
/**
|
|
436
|
+
* Recalculate lead score based on activities and interactions.
|
|
437
|
+
*
|
|
438
|
+
* @param leadId - ID of the lead.
|
|
439
|
+
*/
|
|
440
|
+
recalculateScore<T = any>(leadId: string): Promise<T>;
|
|
441
|
+
/**
|
|
442
|
+
* Update embedded metadata/references of a lead without touching core fields.
|
|
443
|
+
*
|
|
444
|
+
* @param leadId - ID of the lead.
|
|
445
|
+
* @param metadata - Metadata object indicating { refs, extra }
|
|
446
|
+
*/
|
|
447
|
+
updateMetadata<T = any>(leadId: string, metadata: {
|
|
448
|
+
refs?: Record<string, any>;
|
|
449
|
+
extra?: Record<string, any>;
|
|
450
|
+
}): Promise<T>;
|
|
451
|
+
/**
|
|
452
|
+
* Introspect available custom fields configured by the tenant limit.
|
|
453
|
+
*/
|
|
454
|
+
fields<T = any>(): Promise<T>;
|
|
455
|
+
/**
|
|
456
|
+
* Archive (soft-delete) a single lead.
|
|
457
|
+
*
|
|
458
|
+
* @param leadId - The ID of the lead to archive.
|
|
324
459
|
*/
|
|
325
460
|
delete(leadId: string): Promise<unknown>;
|
|
461
|
+
/**
|
|
462
|
+
* Bulk archive multiple leads.
|
|
463
|
+
*
|
|
464
|
+
* @param ids - Array of lead IDs to archive.
|
|
465
|
+
*/
|
|
466
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
declare class Payments extends APIResource {
|
|
470
|
+
/**
|
|
471
|
+
* Record an inbound payment against a lead or appointment.
|
|
472
|
+
*/
|
|
473
|
+
capture<T = any>(payload: {
|
|
474
|
+
leadId: string;
|
|
475
|
+
amount: number;
|
|
476
|
+
currency?: string;
|
|
477
|
+
description?: string;
|
|
478
|
+
appointmentId?: string;
|
|
479
|
+
}): Promise<T>;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
interface CreatePipelineParams {
|
|
483
|
+
name: string;
|
|
484
|
+
isDefault?: boolean;
|
|
485
|
+
stages?: any[];
|
|
486
|
+
}
|
|
487
|
+
interface PipelineStageParams {
|
|
488
|
+
name: string;
|
|
489
|
+
color?: string;
|
|
490
|
+
probability?: number;
|
|
491
|
+
}
|
|
492
|
+
declare class Pipelines extends APIResource {
|
|
493
|
+
/**
|
|
494
|
+
* List all pipelines matching the optional query parameters.
|
|
495
|
+
*/
|
|
496
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
497
|
+
/**
|
|
498
|
+
* Create a new pipeline.
|
|
499
|
+
*/
|
|
500
|
+
create<T = any>(params: CreatePipelineParams): Promise<T>;
|
|
501
|
+
/**
|
|
502
|
+
* Retrieve a single pipeline.
|
|
503
|
+
*/
|
|
504
|
+
retrieve<T = any>(pipelineId: string): Promise<T>;
|
|
505
|
+
/**
|
|
506
|
+
* Update a pipeline's details.
|
|
507
|
+
*/
|
|
508
|
+
update<T = any>(pipelineId: string, params: {
|
|
509
|
+
name?: string;
|
|
510
|
+
description?: string;
|
|
511
|
+
}): Promise<T>;
|
|
512
|
+
/**
|
|
513
|
+
* Set pipeline as the tenant's default.
|
|
514
|
+
*/
|
|
515
|
+
setDefault<T = any>(pipelineId: string): Promise<T>;
|
|
516
|
+
/**
|
|
517
|
+
* Duplicate a pipeline with a new name.
|
|
518
|
+
*/
|
|
519
|
+
duplicate<T = any>(pipelineId: string, newName: string): Promise<T>;
|
|
520
|
+
/**
|
|
521
|
+
* Archive a pipeline.
|
|
522
|
+
*/
|
|
523
|
+
archive<T = any>(pipelineId: string): Promise<T>;
|
|
524
|
+
/**
|
|
525
|
+
* Delete a pipeline permanently.
|
|
526
|
+
*/
|
|
527
|
+
delete(pipelineId: string): Promise<unknown>;
|
|
528
|
+
/**
|
|
529
|
+
* Retrieve a Kanban-style board representation of the pipeline with leads nested.
|
|
530
|
+
*/
|
|
531
|
+
board<T = any>(pipelineId: string): Promise<T>;
|
|
532
|
+
/**
|
|
533
|
+
* Retrieve a revenue forecast based on stage probabilities for a pipeline.
|
|
534
|
+
*/
|
|
535
|
+
forecast<T = any>(pipelineId: string): Promise<T>;
|
|
536
|
+
/**
|
|
537
|
+
* Add a new stage to the pipeline.
|
|
538
|
+
*/
|
|
539
|
+
addStage<T = any>(pipelineId: string, params: PipelineStageParams): Promise<T>;
|
|
540
|
+
/**
|
|
541
|
+
* Change the order of stages inside the pipeline.
|
|
542
|
+
*/
|
|
543
|
+
reorderStages<T = any>(pipelineId: string, orderArray: string[]): Promise<T>;
|
|
544
|
+
/**
|
|
545
|
+
* Update a specific stage.
|
|
546
|
+
*/
|
|
547
|
+
updateStage<T = any>(stageId: string, params: Partial<PipelineStageParams>): Promise<T>;
|
|
548
|
+
/**
|
|
549
|
+
* Delete a stage. Optionally provide a fallback stageId to move active leads to.
|
|
550
|
+
*/
|
|
551
|
+
deleteStage(stageId: string, moveLeadsToStageId?: string): Promise<unknown>;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
interface ScoringConfig {
|
|
555
|
+
decayDays: number;
|
|
556
|
+
thresholds: {
|
|
557
|
+
hot: number;
|
|
558
|
+
warm: number;
|
|
559
|
+
};
|
|
560
|
+
rules: any[];
|
|
561
|
+
}
|
|
562
|
+
declare class Scoring extends APIResource {
|
|
563
|
+
/**
|
|
564
|
+
* Retrieve the tenant's global lead scoring configuration.
|
|
565
|
+
*/
|
|
566
|
+
getConfig<T = any>(): Promise<T>;
|
|
567
|
+
/**
|
|
568
|
+
* Update scoring configuration.
|
|
569
|
+
*/
|
|
570
|
+
updateConfig<T = any>(payload: Partial<ScoringConfig>): Promise<T>;
|
|
571
|
+
/**
|
|
572
|
+
* Force recalculate the score for a specific lead.
|
|
573
|
+
*/
|
|
574
|
+
recalculate<T = any>(leadId: string): Promise<T>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
declare class Sequences extends APIResource {
|
|
578
|
+
/**
|
|
579
|
+
* Manually enroll a lead in a drip sequence (automation rule).
|
|
580
|
+
*/
|
|
581
|
+
enroll<T = any>(payload: {
|
|
582
|
+
leadId: string;
|
|
583
|
+
ruleId: string;
|
|
584
|
+
variables?: Record<string, any>;
|
|
585
|
+
}): Promise<T>;
|
|
586
|
+
/**
|
|
587
|
+
* Unenroll a lead from a running sequence.
|
|
588
|
+
*/
|
|
589
|
+
unenroll<T = any>(enrollmentId: string): Promise<T>;
|
|
590
|
+
/**
|
|
591
|
+
* List active sequence enrollments for a specific lead.
|
|
592
|
+
*/
|
|
593
|
+
listForLead<T = any>(leadId: string): Promise<T>;
|
|
326
594
|
}
|
|
327
595
|
|
|
328
596
|
declare class CRM {
|
|
329
597
|
leads: Leads;
|
|
598
|
+
pipelines: Pipelines;
|
|
599
|
+
activities: Activities;
|
|
600
|
+
analytics: Analytics;
|
|
601
|
+
automations: Automations;
|
|
602
|
+
sequences: Sequences;
|
|
603
|
+
scoring: Scoring;
|
|
604
|
+
payments: Payments;
|
|
605
|
+
automationDashboard: AutomationDashboard;
|
|
330
606
|
constructor(client: AxiosInstance);
|
|
331
607
|
}
|
|
332
608
|
|
|
609
|
+
/**
|
|
610
|
+
* Payload to send a high-throughput email campaign.
|
|
611
|
+
*/
|
|
612
|
+
interface SendCampaignPayload {
|
|
613
|
+
/** Array of recipient email addresses. */
|
|
614
|
+
recipients: string[];
|
|
615
|
+
/** Subject line of the email. */
|
|
616
|
+
subject: string;
|
|
617
|
+
/** HTML body of the email. */
|
|
618
|
+
html: string;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Interface representing the result of a campaign dispatch.
|
|
622
|
+
*/
|
|
623
|
+
interface CampaignResult {
|
|
624
|
+
success: boolean;
|
|
625
|
+
message?: string;
|
|
626
|
+
[key: string]: any;
|
|
627
|
+
}
|
|
628
|
+
declare class EmailResource extends APIResource {
|
|
629
|
+
/**
|
|
630
|
+
* Send an HTML email campaign to a list of recipients.
|
|
631
|
+
*
|
|
632
|
+
* @param payload - The campaign details (recipients, subject, html).
|
|
633
|
+
* @returns The dispatch result.
|
|
634
|
+
*/
|
|
635
|
+
sendEmailCampaign(payload: SendCampaignPayload): Promise<CampaignResult>;
|
|
636
|
+
/**
|
|
637
|
+
* Send a system verification/test email to validate SMTP configuration.
|
|
638
|
+
*
|
|
639
|
+
* @param to - The recipient's email address.
|
|
640
|
+
* @returns The dispatch result.
|
|
641
|
+
*/
|
|
642
|
+
sendTestEmail(to: string): Promise<CampaignResult>;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Event definition representing an entry point capable of triggering automations.
|
|
647
|
+
*/
|
|
648
|
+
interface EventDefinition {
|
|
649
|
+
name: string;
|
|
650
|
+
displayName: string;
|
|
651
|
+
description?: string;
|
|
652
|
+
pipelineId?: string;
|
|
653
|
+
stageId?: string;
|
|
654
|
+
defaultSource?: string;
|
|
655
|
+
[key: string]: any;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Payload to register/assign a new custom event definition.
|
|
659
|
+
*/
|
|
660
|
+
interface AssignEventPayload {
|
|
661
|
+
/** The internal machine-readable name of the event (e.g. "webinar_joined") */
|
|
662
|
+
name: string;
|
|
663
|
+
/** Human-readable display name */
|
|
664
|
+
displayName: string;
|
|
665
|
+
/** Event description */
|
|
666
|
+
description?: string;
|
|
667
|
+
/** ID of the pipeline to associate with matching leads */
|
|
668
|
+
pipelineId?: string;
|
|
669
|
+
/** ID of the stage within the pipeline */
|
|
670
|
+
stageId?: string;
|
|
671
|
+
/** Default source tag for leads created via this event */
|
|
672
|
+
defaultSource?: string;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Payload to programmatically trigger an event/workflow.
|
|
676
|
+
*/
|
|
677
|
+
interface TriggerPayload {
|
|
678
|
+
/** The name of the event to fire (e.g., "webinar_joined") */
|
|
679
|
+
trigger: string;
|
|
680
|
+
/** Phone number of the lead (E.164 format) */
|
|
681
|
+
phone: string;
|
|
682
|
+
/** Email of the lead */
|
|
683
|
+
email?: string;
|
|
684
|
+
/** Key-value pairs for string templates */
|
|
685
|
+
variables?: Record<string, string>;
|
|
686
|
+
/** Deep payload data mapping to the event */
|
|
687
|
+
data?: any;
|
|
688
|
+
/** URL to receive an acknowledgment callback when processing completes */
|
|
689
|
+
callbackUrl?: string;
|
|
690
|
+
/** Secret metadata passed back to the callback URL */
|
|
691
|
+
callbackMetadata?: any;
|
|
692
|
+
/** Auto-create lead if phone does not exist in CRM */
|
|
693
|
+
createLeadIfMissing?: boolean;
|
|
694
|
+
/** Pre-fill data if creating a new lead */
|
|
695
|
+
leadData?: {
|
|
696
|
+
firstName?: string;
|
|
697
|
+
lastName?: string;
|
|
698
|
+
source?: string;
|
|
699
|
+
};
|
|
700
|
+
/** Delay execution of matched workflows (in seconds) */
|
|
701
|
+
delaySeconds?: number;
|
|
702
|
+
/** Delay execution of matched workflows (in minutes) */
|
|
703
|
+
delayMinutes?: number;
|
|
704
|
+
/** Explicit ISO timestamp to trigger the workflow run */
|
|
705
|
+
runAt?: string;
|
|
706
|
+
/** Automatically generate a Google Meet appointment if matched actions require it */
|
|
707
|
+
requiresMeet?: boolean;
|
|
708
|
+
/** Configuration details for the generated Google Meet appointment */
|
|
709
|
+
meetConfig?: {
|
|
710
|
+
summary?: string;
|
|
711
|
+
description?: string;
|
|
712
|
+
startTime?: string;
|
|
713
|
+
duration?: number;
|
|
714
|
+
timezone?: string;
|
|
715
|
+
attendees?: string[];
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Response returned when triggering an event.
|
|
720
|
+
*/
|
|
721
|
+
interface TriggerResponse {
|
|
722
|
+
success: boolean;
|
|
723
|
+
data?: {
|
|
724
|
+
eventLogId: string;
|
|
725
|
+
trigger: string;
|
|
726
|
+
leadId: string;
|
|
727
|
+
rulesMatched: number;
|
|
728
|
+
};
|
|
729
|
+
message?: string;
|
|
730
|
+
code?: string;
|
|
731
|
+
}
|
|
732
|
+
declare class EventsResource extends APIResource {
|
|
733
|
+
/**
|
|
734
|
+
* Retrieve all valid events (system + custom) that can be used as Automation Rule triggers.
|
|
735
|
+
*/
|
|
736
|
+
list(): Promise<{
|
|
737
|
+
success: boolean;
|
|
738
|
+
data: EventDefinition[];
|
|
739
|
+
}>;
|
|
740
|
+
/**
|
|
741
|
+
* Register a new custom event entry point into the CRM automation engine.
|
|
742
|
+
* Useful when introducing new granular triggers.
|
|
743
|
+
*/
|
|
744
|
+
assign(payload: AssignEventPayload): Promise<{
|
|
745
|
+
success: boolean;
|
|
746
|
+
data: EventDefinition;
|
|
747
|
+
}>;
|
|
748
|
+
/**
|
|
749
|
+
* Deactivate a custom event assignment by name.
|
|
750
|
+
*/
|
|
751
|
+
unassign(name: string): Promise<{
|
|
752
|
+
success: boolean;
|
|
753
|
+
data: any;
|
|
754
|
+
}>;
|
|
755
|
+
/**
|
|
756
|
+
* Deactivate multiple custom event assignments simultaneously.
|
|
757
|
+
*/
|
|
758
|
+
unassignBulk(names: string[]): Promise<{
|
|
759
|
+
success: boolean;
|
|
760
|
+
message: string;
|
|
761
|
+
}>;
|
|
762
|
+
/**
|
|
763
|
+
* Programmatically fire an event into the CRM automation engine.
|
|
764
|
+
* Emits to the internal EventBus to match with active Workflow Automation Rules.
|
|
765
|
+
*/
|
|
766
|
+
trigger(payload: TriggerPayload): Promise<TriggerResponse>;
|
|
767
|
+
/**
|
|
768
|
+
* List all custom event definitions.
|
|
769
|
+
*/
|
|
770
|
+
listCustomEvents<T = any>(): Promise<T>;
|
|
771
|
+
/**
|
|
772
|
+
* Create or upsert a custom event definition.
|
|
773
|
+
*/
|
|
774
|
+
createCustomEvent<T = any>(payload: {
|
|
775
|
+
name: string;
|
|
776
|
+
displayName: string;
|
|
777
|
+
description?: string;
|
|
778
|
+
}): Promise<T>;
|
|
779
|
+
/**
|
|
780
|
+
* Delete a custom event definition.
|
|
781
|
+
*/
|
|
782
|
+
deleteCustomEvent<T = any>(id: string): Promise<T>;
|
|
783
|
+
/**
|
|
784
|
+
* Manually emit a custom event to trigger workflows based on its definition.
|
|
785
|
+
*/
|
|
786
|
+
emit<T = any>(payload: {
|
|
787
|
+
eventName: string;
|
|
788
|
+
leadId: string;
|
|
789
|
+
data?: any;
|
|
790
|
+
}): Promise<T>;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
interface SystemHealth {
|
|
794
|
+
status: string;
|
|
795
|
+
version: string;
|
|
796
|
+
env: string;
|
|
797
|
+
uptime: number;
|
|
798
|
+
db: string;
|
|
799
|
+
queueDepth: number;
|
|
800
|
+
timestamp: string;
|
|
801
|
+
}
|
|
802
|
+
interface ClientHealth {
|
|
803
|
+
clientCode: string;
|
|
804
|
+
services: {
|
|
805
|
+
whatsapp: "connected" | "not_configured";
|
|
806
|
+
email: "configured" | "not_configured";
|
|
807
|
+
googleMeet: "configured" | "not_configured";
|
|
808
|
+
};
|
|
809
|
+
activeAutomations: number;
|
|
810
|
+
queueDepth: number;
|
|
811
|
+
timestamp: string;
|
|
812
|
+
}
|
|
813
|
+
interface JobStatus {
|
|
814
|
+
jobId: string;
|
|
815
|
+
status: string;
|
|
816
|
+
attempts: number;
|
|
817
|
+
maxAttempts: number;
|
|
818
|
+
lastError: any;
|
|
819
|
+
runAt: string;
|
|
820
|
+
completedAt: string | null;
|
|
821
|
+
failedAt: string | null;
|
|
822
|
+
createdAt: string;
|
|
823
|
+
}
|
|
824
|
+
declare class Health extends APIResource {
|
|
825
|
+
/**
|
|
826
|
+
* Global platform health check.
|
|
827
|
+
*/
|
|
828
|
+
system(): Promise<SystemHealth>;
|
|
829
|
+
/**
|
|
830
|
+
* Tenant-specific health check. Identifies configured services.
|
|
831
|
+
*/
|
|
832
|
+
clientHealth(): Promise<ClientHealth>;
|
|
833
|
+
/**
|
|
834
|
+
* Job execution status lookup.
|
|
835
|
+
*/
|
|
836
|
+
jobStatus(jobId: string): Promise<JobStatus>;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
interface SendCampaignParams {
|
|
840
|
+
recipients: string[];
|
|
841
|
+
subject: string;
|
|
842
|
+
html: string;
|
|
843
|
+
}
|
|
844
|
+
declare class Emails extends APIResource {
|
|
845
|
+
/**
|
|
846
|
+
* Dispatch a bulk email campaign.
|
|
847
|
+
*/
|
|
848
|
+
sendCampaign<T = any>(params: SendCampaignParams): Promise<T>;
|
|
849
|
+
/**
|
|
850
|
+
* Send a test verification email (used to verify SMTP functionality).
|
|
851
|
+
*/
|
|
852
|
+
sendTest<T = any>(to: string): Promise<T>;
|
|
853
|
+
}
|
|
854
|
+
declare class Campaigns extends APIResource {
|
|
855
|
+
/**
|
|
856
|
+
* List email and SMS marketing campaigns.
|
|
857
|
+
*/
|
|
858
|
+
list<T = any>(params?: {
|
|
859
|
+
status?: string;
|
|
860
|
+
limit?: number;
|
|
861
|
+
}): Promise<T>;
|
|
862
|
+
/**
|
|
863
|
+
* Create a new campaign.
|
|
864
|
+
*/
|
|
865
|
+
create<T = any>(payload: {
|
|
866
|
+
name: string;
|
|
867
|
+
type: string;
|
|
868
|
+
subject?: string;
|
|
869
|
+
html?: string;
|
|
870
|
+
templateId?: string;
|
|
871
|
+
recipients?: string[];
|
|
872
|
+
}): Promise<T>;
|
|
873
|
+
/**
|
|
874
|
+
* Retrieve campaign details.
|
|
875
|
+
*/
|
|
876
|
+
retrieve<T = any>(campaignId: string): Promise<T>;
|
|
877
|
+
/**
|
|
878
|
+
* Update a campaign.
|
|
879
|
+
*/
|
|
880
|
+
update<T = any>(campaignId: string, payload: any): Promise<T>;
|
|
881
|
+
/**
|
|
882
|
+
* Delete a campaign.
|
|
883
|
+
*/
|
|
884
|
+
delete<T = any>(campaignId: string): Promise<T>;
|
|
885
|
+
/**
|
|
886
|
+
* Send or schedule a campaign.
|
|
887
|
+
*/
|
|
888
|
+
send<T = any>(campaignId: string, payload?: {
|
|
889
|
+
scheduledAt?: string;
|
|
890
|
+
}): Promise<T>;
|
|
891
|
+
/**
|
|
892
|
+
* Get campaign stats (opens, clicks, bounces).
|
|
893
|
+
*/
|
|
894
|
+
stats<T = any>(campaignId: string): Promise<T>;
|
|
895
|
+
}
|
|
896
|
+
declare class WhatsAppMarketing extends APIResource {
|
|
897
|
+
/**
|
|
898
|
+
* Dispatch a template-based WhatsApp message with CRM-integrated variable resolution.
|
|
899
|
+
*
|
|
900
|
+
* Unlike direct WhatsApp sending, this endpoint automatically pulls data from the CRM
|
|
901
|
+
* based on the provided variables mapping.
|
|
902
|
+
*/
|
|
903
|
+
sendTemplate<T = any>(params: {
|
|
904
|
+
phone: string;
|
|
905
|
+
templateName: string;
|
|
906
|
+
languageCode?: string;
|
|
907
|
+
variables?: Record<string, string>;
|
|
908
|
+
resolvedVariables?: Record<string, string>;
|
|
909
|
+
}): Promise<T>;
|
|
910
|
+
}
|
|
911
|
+
declare class Marketing extends APIResource {
|
|
912
|
+
emails: Emails;
|
|
913
|
+
campaigns: Campaigns;
|
|
914
|
+
whatsapp: WhatsAppMarketing;
|
|
915
|
+
constructor(client: any);
|
|
916
|
+
}
|
|
917
|
+
|
|
333
918
|
/**
|
|
334
919
|
* Options for the `upload()` elite helper.
|
|
335
920
|
*/
|
|
@@ -597,7 +1182,15 @@ declare class Meetings extends APIResource {
|
|
|
597
1182
|
* });
|
|
598
1183
|
* ```
|
|
599
1184
|
*/
|
|
600
|
-
update(meetingId: string, data: UpdateMeetingParams): Promise<
|
|
1185
|
+
update<T = any>(meetingId: string, data: UpdateMeetingParams): Promise<T>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Reschedule an existing meeting. Provides explicit method for time modifications.
|
|
1188
|
+
*/
|
|
1189
|
+
reschedule<T = any>(meetingId: string, params: {
|
|
1190
|
+
startTime: Date | string;
|
|
1191
|
+
endTime: Date | string;
|
|
1192
|
+
duration?: number;
|
|
1193
|
+
}): Promise<T>;
|
|
601
1194
|
/**
|
|
602
1195
|
* Cancel a meeting. This sets the meeting status to `"cancelled"`.
|
|
603
1196
|
*
|
|
@@ -722,155 +1315,103 @@ declare class Notifications extends APIResource {
|
|
|
722
1315
|
* ```
|
|
723
1316
|
*/
|
|
724
1317
|
listCallbacks(params?: Omit<LogFilter, "trigger" | "phone">): Promise<unknown>;
|
|
1318
|
+
/**
|
|
1319
|
+
* List active CRM notifications/alerts for the current agent.
|
|
1320
|
+
*/
|
|
1321
|
+
listAlerts<T = any>(params?: {
|
|
1322
|
+
limit?: number;
|
|
1323
|
+
unreadOnly?: boolean;
|
|
1324
|
+
}): Promise<T>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Dismiss a specific notification alert.
|
|
1327
|
+
*/
|
|
1328
|
+
dismissAlert<T = any>(notificationId: string): Promise<T>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Clear (dismiss) all notifications for the current agent.
|
|
1331
|
+
*/
|
|
1332
|
+
clearAllAlerts<T = any>(): Promise<T>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Retry an action from a notification (e.g. failed send).
|
|
1335
|
+
*/
|
|
1336
|
+
retryAction<T = any>(notificationId: string): Promise<T>;
|
|
725
1337
|
}
|
|
726
1338
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
/** Subject line of the email. */
|
|
734
|
-
subject: string;
|
|
735
|
-
/** HTML body of the email. */
|
|
736
|
-
html: string;
|
|
1339
|
+
interface JobStats {
|
|
1340
|
+
waiting: number;
|
|
1341
|
+
active: number;
|
|
1342
|
+
completed: number;
|
|
1343
|
+
failed: number;
|
|
1344
|
+
delayed: number;
|
|
737
1345
|
}
|
|
738
|
-
|
|
739
|
-
* Interface representing the result of a campaign dispatch.
|
|
740
|
-
*/
|
|
741
|
-
interface CampaignResult {
|
|
742
|
-
success: boolean;
|
|
743
|
-
message?: string;
|
|
744
|
-
[key: string]: any;
|
|
745
|
-
}
|
|
746
|
-
declare class EmailResource extends APIResource {
|
|
1346
|
+
declare class Queue extends APIResource {
|
|
747
1347
|
/**
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* @param payload - The campaign details (recipients, subject, html).
|
|
751
|
-
* @returns The dispatch result.
|
|
1348
|
+
* List all failed jobs.
|
|
752
1349
|
*/
|
|
753
|
-
|
|
1350
|
+
listFailed<T = any>(): Promise<T>;
|
|
754
1351
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
* @param to - The recipient's email address.
|
|
758
|
-
* @returns The dispatch result.
|
|
1352
|
+
* Get queue health statistics.
|
|
759
1353
|
*/
|
|
760
|
-
|
|
1354
|
+
getStats<T = JobStats>(): Promise<T>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Retry a failed job.
|
|
1357
|
+
*/
|
|
1358
|
+
retryJob<T = any>(jobId: string): Promise<T>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Remove a job from the queue.
|
|
1361
|
+
*/
|
|
1362
|
+
deleteJob<T = any>(jobId: string): Promise<T>;
|
|
761
1363
|
}
|
|
762
1364
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
name: string
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
defaultSource?: string;
|
|
773
|
-
[key: string]: any;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Payload to register/assign a new custom event definition.
|
|
777
|
-
*/
|
|
778
|
-
interface AssignEventPayload {
|
|
779
|
-
/** The internal machine-readable name of the event (e.g. "webinar_joined") */
|
|
780
|
-
name: string;
|
|
781
|
-
/** Human-readable display name */
|
|
782
|
-
displayName: string;
|
|
783
|
-
/** Event description */
|
|
784
|
-
description?: string;
|
|
785
|
-
/** ID of the pipeline to associate with matching leads */
|
|
786
|
-
pipelineId?: string;
|
|
787
|
-
/** ID of the stage within the pipeline */
|
|
788
|
-
stageId?: string;
|
|
789
|
-
/** Default source tag for leads created via this event */
|
|
790
|
-
defaultSource?: string;
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Payload to programmatically trigger an event/workflow.
|
|
794
|
-
*/
|
|
795
|
-
interface TriggerPayload {
|
|
796
|
-
/** The name of the event to fire (e.g., "webinar_joined") */
|
|
797
|
-
trigger: string;
|
|
798
|
-
/** Phone number of the lead (E.164 format) */
|
|
799
|
-
phone: string;
|
|
800
|
-
/** Email of the lead */
|
|
801
|
-
email?: string;
|
|
802
|
-
/** Key-value pairs for string templates */
|
|
803
|
-
variables?: Record<string, string>;
|
|
804
|
-
/** Deep payload data mapping to the event */
|
|
805
|
-
data?: any;
|
|
806
|
-
/** URL to receive an acknowledgment callback when processing completes */
|
|
807
|
-
callbackUrl?: string;
|
|
808
|
-
/** Secret metadata passed back to the callback URL */
|
|
809
|
-
callbackMetadata?: any;
|
|
810
|
-
/** Auto-create lead if phone does not exist in CRM */
|
|
811
|
-
createLeadIfMissing?: boolean;
|
|
812
|
-
/** Pre-fill data if creating a new lead */
|
|
813
|
-
leadData?: {
|
|
814
|
-
firstName?: string;
|
|
815
|
-
lastName?: string;
|
|
816
|
-
source?: string;
|
|
817
|
-
};
|
|
818
|
-
/** Delay execution of matched workflows (in seconds) */
|
|
819
|
-
delaySeconds?: number;
|
|
820
|
-
/** Delay execution of matched workflows (in minutes) */
|
|
821
|
-
delayMinutes?: number;
|
|
822
|
-
/** Explicit ISO timestamp to trigger the workflow run */
|
|
823
|
-
runAt?: string;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Response returned when triggering an event.
|
|
827
|
-
*/
|
|
828
|
-
interface TriggerResponse {
|
|
829
|
-
success: boolean;
|
|
830
|
-
data?: {
|
|
831
|
-
eventLogId: string;
|
|
832
|
-
trigger: string;
|
|
833
|
-
leadId: string;
|
|
834
|
-
rulesMatched: number;
|
|
835
|
-
};
|
|
836
|
-
message?: string;
|
|
837
|
-
code?: string;
|
|
1365
|
+
declare class Folders extends APIResource {
|
|
1366
|
+
/**
|
|
1367
|
+
* Create a new folder.
|
|
1368
|
+
*/
|
|
1369
|
+
create<T = any>(name: string): Promise<T>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Delete a folder and its contents.
|
|
1372
|
+
*/
|
|
1373
|
+
delete<T = any>(folderPath: string): Promise<T>;
|
|
838
1374
|
}
|
|
839
|
-
declare class
|
|
1375
|
+
declare class Files extends APIResource {
|
|
840
1376
|
/**
|
|
841
|
-
*
|
|
1377
|
+
* List files in a folder.
|
|
842
1378
|
*/
|
|
843
|
-
list(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}>;
|
|
1379
|
+
list<T = any>(folder: string, params?: {
|
|
1380
|
+
year?: string;
|
|
1381
|
+
month?: string;
|
|
1382
|
+
}): Promise<T>;
|
|
847
1383
|
/**
|
|
848
|
-
*
|
|
849
|
-
* Useful when introducing new granular triggers.
|
|
1384
|
+
* Get a presigned upload URL for direct-to-cloud browser uploads.
|
|
850
1385
|
*/
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1386
|
+
getUploadUrl<T = any>(params: {
|
|
1387
|
+
folder: string;
|
|
1388
|
+
filename: string;
|
|
1389
|
+
contentType: string;
|
|
1390
|
+
}): Promise<T>;
|
|
855
1391
|
/**
|
|
856
|
-
*
|
|
1392
|
+
* Notify backend after a successful direct browser upload.
|
|
857
1393
|
*/
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}>;
|
|
1394
|
+
confirmUpload<T = any>(params: {
|
|
1395
|
+
key: string;
|
|
1396
|
+
sizeBytes: number;
|
|
1397
|
+
}): Promise<T>;
|
|
862
1398
|
/**
|
|
863
|
-
*
|
|
1399
|
+
* Get a presigned download URL for an R2 key.
|
|
864
1400
|
*/
|
|
865
|
-
|
|
866
|
-
success: boolean;
|
|
867
|
-
message: string;
|
|
868
|
-
}>;
|
|
1401
|
+
getDownloadUrl<T = any>(key: string): Promise<T>;
|
|
869
1402
|
/**
|
|
870
|
-
*
|
|
871
|
-
* Emits to the internal EventBus to match with active Workflow Automation Rules.
|
|
1403
|
+
* Delete a file by key.
|
|
872
1404
|
*/
|
|
873
|
-
|
|
1405
|
+
delete(key: string): Promise<unknown>;
|
|
1406
|
+
}
|
|
1407
|
+
declare class Storage extends APIResource {
|
|
1408
|
+
folders: Folders;
|
|
1409
|
+
files: Files;
|
|
1410
|
+
constructor(client: any);
|
|
1411
|
+
/**
|
|
1412
|
+
* Get tenant storage usage and quota limitations.
|
|
1413
|
+
*/
|
|
1414
|
+
usage<T = any>(): Promise<T>;
|
|
874
1415
|
}
|
|
875
1416
|
|
|
876
1417
|
/**
|
|
@@ -967,6 +1508,317 @@ declare class Webhooks {
|
|
|
967
1508
|
constructEvent(payload: string | Buffer, signature: string | string[] | undefined, secret: string): Promise<any>;
|
|
968
1509
|
}
|
|
969
1510
|
|
|
1511
|
+
interface CreateBroadcastParams {
|
|
1512
|
+
/** Optional name for the broadcast campaign */
|
|
1513
|
+
name?: string;
|
|
1514
|
+
/** Name of the Meta template to send */
|
|
1515
|
+
templateName: string;
|
|
1516
|
+
/** Language code (defaults to en_US) */
|
|
1517
|
+
templateLanguage?: string;
|
|
1518
|
+
/** List of recipients with their phone numbers and variable overrides */
|
|
1519
|
+
recipients: {
|
|
1520
|
+
phone: string;
|
|
1521
|
+
variables?: string[];
|
|
1522
|
+
}[];
|
|
1523
|
+
}
|
|
1524
|
+
declare class Broadcasts extends APIResource {
|
|
1525
|
+
/**
|
|
1526
|
+
* List past and active broadcasts.
|
|
1527
|
+
*/
|
|
1528
|
+
list<T = any>(params?: Record<string, any>): Promise<T>;
|
|
1529
|
+
/**
|
|
1530
|
+
* Create a new broadcast to send a template message to multiple recipients.
|
|
1531
|
+
*/
|
|
1532
|
+
create<T = any>(params: CreateBroadcastParams): Promise<T>;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
interface ListParams {
|
|
1536
|
+
limit?: number;
|
|
1537
|
+
before?: string;
|
|
1538
|
+
after?: string;
|
|
1539
|
+
status?: string;
|
|
1540
|
+
}
|
|
1541
|
+
declare class Conversations extends APIResource {
|
|
1542
|
+
/**
|
|
1543
|
+
* List conversations for the tenant.
|
|
1544
|
+
*/
|
|
1545
|
+
list<T = any>(params?: ListParams): Promise<T>;
|
|
1546
|
+
/**
|
|
1547
|
+
* Create a new conversation explicitly.
|
|
1548
|
+
*
|
|
1549
|
+
* @param params - Conversation details.
|
|
1550
|
+
*/
|
|
1551
|
+
create<T = any>(params: {
|
|
1552
|
+
phone: string;
|
|
1553
|
+
name?: string;
|
|
1554
|
+
}): Promise<T>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Retrieve details of a specific conversation.
|
|
1557
|
+
*/
|
|
1558
|
+
retrieve<T = any>(conversationId: string): Promise<T>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Get messages for a specific conversation.
|
|
1561
|
+
*/
|
|
1562
|
+
messages<T = any>(conversationId: string, params?: ListParams): Promise<T>;
|
|
1563
|
+
/**
|
|
1564
|
+
* Link a conversation to a lead.
|
|
1565
|
+
*/
|
|
1566
|
+
linkLead<T = any>(conversationId: string, leadId: string, leadData?: any): Promise<T>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Mark a conversation as read (clear unread count).
|
|
1569
|
+
*/
|
|
1570
|
+
markRead<T = any>(conversationId: string): Promise<T>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Delete a conversation.
|
|
1573
|
+
*/
|
|
1574
|
+
delete(conversationId: string): Promise<unknown>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Bulk delete conversations.
|
|
1577
|
+
*/
|
|
1578
|
+
bulkDelete(ids: string[]): Promise<unknown>;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Parameters for sending a free-form WhatsApp message.
|
|
1583
|
+
*/
|
|
1584
|
+
interface SendMessageParams {
|
|
1585
|
+
/**
|
|
1586
|
+
* Recipient's phone number in E.164 format.
|
|
1587
|
+
* @example "+919876543210"
|
|
1588
|
+
*/
|
|
1589
|
+
to: string;
|
|
1590
|
+
/** Plain text body of the message. */
|
|
1591
|
+
text?: string;
|
|
1592
|
+
/** Public URL of the media asset to send. */
|
|
1593
|
+
mediaUrl?: string;
|
|
1594
|
+
/** MIME category of the media. */
|
|
1595
|
+
mediaType?: "image" | "video" | "audio" | "document";
|
|
1596
|
+
/** The `messageId` of the message to reply to (quoted replies). */
|
|
1597
|
+
replyToId?: string;
|
|
1598
|
+
/** Filename shown to the recipient (required for `document` type). */
|
|
1599
|
+
filename?: string;
|
|
1600
|
+
/** Arbitrary metadata stored with the message record. */
|
|
1601
|
+
metadata?: Record<string, any>;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Parameters for sending a pre-approved WhatsApp Business template.
|
|
1605
|
+
*/
|
|
1606
|
+
interface SendTemplateParams {
|
|
1607
|
+
/**
|
|
1608
|
+
* Recipient's phone number in E.164 format.
|
|
1609
|
+
* @example "+919876543210"
|
|
1610
|
+
*/
|
|
1611
|
+
to: string;
|
|
1612
|
+
/** The exact template name as approved in Meta Business Manager. */
|
|
1613
|
+
templateName: string;
|
|
1614
|
+
/**
|
|
1615
|
+
* BCP-47 language code for the template.
|
|
1616
|
+
* @default "en_US"
|
|
1617
|
+
*/
|
|
1618
|
+
language?: string;
|
|
1619
|
+
/**
|
|
1620
|
+
* Ordered array of variable substitutions for template placeholders.
|
|
1621
|
+
* @example ["Alice", "10 April 2026", "10:00 AM"]
|
|
1622
|
+
*/
|
|
1623
|
+
variables?: string[];
|
|
1624
|
+
/** Optional header media URL (for templates with media headers). */
|
|
1625
|
+
mediaUrl?: string;
|
|
1626
|
+
/** Media type for the header (e.g. "image", "document"). */
|
|
1627
|
+
mediaType?: string;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* WhatsApp outbound messaging resource.
|
|
1631
|
+
*
|
|
1632
|
+
* Access via `ecod.whatsapp.messages`.
|
|
1633
|
+
*
|
|
1634
|
+
* @example
|
|
1635
|
+
* ```typescript
|
|
1636
|
+
* await ecod.whatsapp.messages.send({
|
|
1637
|
+
* to: "+919876543210",
|
|
1638
|
+
* text: "Your appointment is confirmed!",
|
|
1639
|
+
* });
|
|
1640
|
+
* ```
|
|
1641
|
+
*/
|
|
1642
|
+
declare class Messages extends APIResource {
|
|
1643
|
+
/**
|
|
1644
|
+
* Send a free-text or media message to a WhatsApp number.
|
|
1645
|
+
*
|
|
1646
|
+
* For text-only messages, supply `text`. For media, supply `mediaUrl`
|
|
1647
|
+
* and `mediaType`. Both can be combined.
|
|
1648
|
+
*
|
|
1649
|
+
* @param params - Message parameters.
|
|
1650
|
+
* @returns The created message record.
|
|
1651
|
+
*
|
|
1652
|
+
* @example Text message
|
|
1653
|
+
* ```typescript
|
|
1654
|
+
* await ecod.whatsapp.messages.send({
|
|
1655
|
+
* to: "+919876543210",
|
|
1656
|
+
* text: "Hello!",
|
|
1657
|
+
* });
|
|
1658
|
+
* ```
|
|
1659
|
+
*
|
|
1660
|
+
* @example Media message
|
|
1661
|
+
* ```typescript
|
|
1662
|
+
* await ecod.whatsapp.messages.send({
|
|
1663
|
+
* to: "+919876543210",
|
|
1664
|
+
* mediaUrl: "https://cdn.ecodrix.com/invoice.pdf",
|
|
1665
|
+
* mediaType: "document",
|
|
1666
|
+
* filename: "invoice.pdf",
|
|
1667
|
+
* });
|
|
1668
|
+
* ```
|
|
1669
|
+
*/
|
|
1670
|
+
send(params: SendMessageParams): Promise<unknown>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Send a pre-approved WhatsApp Business template message.
|
|
1673
|
+
*
|
|
1674
|
+
* Templates must be approved in Meta Business Manager before use.
|
|
1675
|
+
* Variable placeholders in the template body are filled left-to-right
|
|
1676
|
+
* from the `variables` array.
|
|
1677
|
+
*
|
|
1678
|
+
* @param params - Template message parameters.
|
|
1679
|
+
* @returns The created message record.
|
|
1680
|
+
*
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```typescript
|
|
1683
|
+
* await ecod.whatsapp.messages.sendTemplate({
|
|
1684
|
+
* to: "+919876543210",
|
|
1685
|
+
* templateName: "appointment_reminder",
|
|
1686
|
+
* language: "en_US",
|
|
1687
|
+
* variables: ["Alice", "10 April", "10:00 AM"],
|
|
1688
|
+
* });
|
|
1689
|
+
* ```
|
|
1690
|
+
*/
|
|
1691
|
+
sendTemplate(params: SendTemplateParams): Promise<unknown>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Star or unstar a message.
|
|
1694
|
+
*
|
|
1695
|
+
* @param messageId - The ID of the message.
|
|
1696
|
+
* @param isStarred - Boolean indicating whether to star or unstar.
|
|
1697
|
+
*/
|
|
1698
|
+
star<T = any>(messageId: string, isStarred: boolean): Promise<T>;
|
|
1699
|
+
/**
|
|
1700
|
+
* React to a message with an emoji.
|
|
1701
|
+
*
|
|
1702
|
+
* @param messageId - The ID of the message.
|
|
1703
|
+
* @param reaction - The emoji (e.g. "👍") to react with, or empty string to remove.
|
|
1704
|
+
*/
|
|
1705
|
+
react<T = any>(messageId: string, reaction: string): Promise<T>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Mark all messages in a conversation as read (double-tick).
|
|
1708
|
+
*
|
|
1709
|
+
* @param conversationId - The conversation to mark as read.
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ```typescript
|
|
1713
|
+
* await ecod.whatsapp.messages.markRead("conv_64abc...");
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
markRead(conversationId: string): Promise<unknown>;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
interface TemplateMapping {
|
|
1720
|
+
mappings: any[];
|
|
1721
|
+
onEmptyVariable: string;
|
|
1722
|
+
}
|
|
1723
|
+
declare class Templates extends APIResource {
|
|
1724
|
+
/**
|
|
1725
|
+
* List all templates from the tenant database.
|
|
1726
|
+
*/
|
|
1727
|
+
list<T = any>(params?: {
|
|
1728
|
+
status?: string;
|
|
1729
|
+
mappingStatus?: string;
|
|
1730
|
+
channel?: string;
|
|
1731
|
+
}): Promise<T>;
|
|
1732
|
+
/**
|
|
1733
|
+
* Synchronize templates from Meta API.
|
|
1734
|
+
*/
|
|
1735
|
+
sync<T = any>(): Promise<T>;
|
|
1736
|
+
/**
|
|
1737
|
+
* Get template details.
|
|
1738
|
+
*/
|
|
1739
|
+
retrieve<T = any>(templateIdentifier: string): Promise<T>;
|
|
1740
|
+
/**
|
|
1741
|
+
* Create a new template manually.
|
|
1742
|
+
*/
|
|
1743
|
+
create<T = any>(payload: any): Promise<T>;
|
|
1744
|
+
/**
|
|
1745
|
+
* Update an existing template.
|
|
1746
|
+
*/
|
|
1747
|
+
update<T = any>(templateId: string, payload: any): Promise<T>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Delete a template.
|
|
1750
|
+
*/
|
|
1751
|
+
deleteTemplate<T = any>(templateName: string, force?: boolean): Promise<T>;
|
|
1752
|
+
/**
|
|
1753
|
+
* List curated mapping config options.
|
|
1754
|
+
*/
|
|
1755
|
+
mappingConfig<T = any>(): Promise<T>;
|
|
1756
|
+
/**
|
|
1757
|
+
* List CRM collections for variable mapping.
|
|
1758
|
+
*/
|
|
1759
|
+
collections<T = any>(): Promise<T>;
|
|
1760
|
+
/**
|
|
1761
|
+
* List CRM fields for a collection.
|
|
1762
|
+
*/
|
|
1763
|
+
collectionFields<T = any>(collectionName: string): Promise<T>;
|
|
1764
|
+
/**
|
|
1765
|
+
* Update variable mappings for a template.
|
|
1766
|
+
*/
|
|
1767
|
+
updateMapping<T = any>(templateName: string, payload: TemplateMapping): Promise<T>;
|
|
1768
|
+
/**
|
|
1769
|
+
* Validate mapping readiness.
|
|
1770
|
+
*/
|
|
1771
|
+
validate<T = any>(templateName: string): Promise<T>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Preview a template resolution.
|
|
1774
|
+
*/
|
|
1775
|
+
preview<T = any>(templateName: string, context: {
|
|
1776
|
+
lead?: any;
|
|
1777
|
+
vars?: any;
|
|
1778
|
+
}): Promise<T>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Check automation usage of a template.
|
|
1781
|
+
*/
|
|
1782
|
+
checkUsage<T = any>(templateName: string): Promise<T>;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
interface SendTemplatePayload {
|
|
1786
|
+
/** Phone number in E.164 format. */
|
|
1787
|
+
phone: string;
|
|
1788
|
+
/** Name of the pre-approved WhatsApp template. */
|
|
1789
|
+
templateName: string;
|
|
1790
|
+
/** Language code (defaults to "en"). */
|
|
1791
|
+
languageCode?: string;
|
|
1792
|
+
/** Key-value pairs matching variables in your template (e.g., {{1}}, {{2}}). */
|
|
1793
|
+
variables?: Record<string, string>;
|
|
1794
|
+
/** Explicitly resolved variables if bypassing the internal resolution engine. */
|
|
1795
|
+
resolvedVariables?: any[];
|
|
1796
|
+
}
|
|
1797
|
+
declare class WhatsApp extends APIResource {
|
|
1798
|
+
messages: Messages;
|
|
1799
|
+
conversations: Conversations;
|
|
1800
|
+
broadcasts: Broadcasts;
|
|
1801
|
+
templates: Templates;
|
|
1802
|
+
constructor(client: AxiosInstance);
|
|
1803
|
+
/**
|
|
1804
|
+
* Upload an asset directly to chat storage.
|
|
1805
|
+
*/
|
|
1806
|
+
upload<T = any>(file: Blob | Buffer | File | any, filename: string): Promise<T>;
|
|
1807
|
+
/**
|
|
1808
|
+
* Dispatch a WhatsApp template message directly to a specific phone number.
|
|
1809
|
+
* Bypasses the automation queue for immediate high-priority delivery.
|
|
1810
|
+
*
|
|
1811
|
+
* @param payload - The template dispatch payload.
|
|
1812
|
+
* @returns Information about the dispatched message.
|
|
1813
|
+
*/
|
|
1814
|
+
sendTemplate(payload: SendTemplatePayload): Promise<{
|
|
1815
|
+
success: boolean;
|
|
1816
|
+
messageId?: string;
|
|
1817
|
+
templateName?: string;
|
|
1818
|
+
resolvedVariables?: any[];
|
|
1819
|
+
}>;
|
|
1820
|
+
}
|
|
1821
|
+
|
|
970
1822
|
/**
|
|
971
1823
|
* Configuration options for the Ecodrix client.
|
|
972
1824
|
*/
|
|
@@ -1035,6 +1887,14 @@ declare class Ecodrix {
|
|
|
1035
1887
|
readonly events: EventsResource;
|
|
1036
1888
|
/** Cryptographic webhook signature verification. */
|
|
1037
1889
|
readonly webhooks: Webhooks;
|
|
1890
|
+
/** Tenant Cloud Storage mapping. */
|
|
1891
|
+
readonly storage: Storage;
|
|
1892
|
+
/** Email and SMS Marketing Campaigns. */
|
|
1893
|
+
readonly marketing: Marketing;
|
|
1894
|
+
/** Platform and tenant health diagnostics. */
|
|
1895
|
+
readonly health: Health;
|
|
1896
|
+
/** Background job queue management. */
|
|
1897
|
+
readonly queue: Queue;
|
|
1038
1898
|
constructor(options: EcodrixOptions);
|
|
1039
1899
|
private setupSocket;
|
|
1040
1900
|
/**
|
|
@@ -1093,4 +1953,4 @@ declare class Ecodrix {
|
|
|
1093
1953
|
request<T = any>(method: Method, path: string, data?: any, params?: any): Promise<T>;
|
|
1094
1954
|
}
|
|
1095
1955
|
|
|
1096
|
-
export { APIError, type AssignEventPayload, AuthenticationError, type CampaignResult, Conversations, type CreateLeadParams, type CreateMeetingParams, Ecodrix, EcodrixError, type EcodrixOptions, EmailResource, type EventDefinition, EventsResource, Leads, type ListParams, type LogFilter, MediaResource, Meetings, Messages, Notifications, RateLimitError, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, WebhookSignatureError, Webhooks, WhatsApp, Ecodrix as default };
|
|
1956
|
+
export { APIError, Activities, Analytics, type AnalyticsParams, type AnalyticsRange, type AssignEventPayload, AuthenticationError, AutomationDashboard, type AutomationRulePayload, Automations, Broadcasts, CRM, type CampaignResult, Campaigns, type ClientHealth, Conversations, type CreateBroadcastParams, type CreateLeadParams, type CreateMeetingParams, type CreatePipelineParams, Ecodrix, EcodrixError, type EcodrixOptions, EmailResource, Emails, type EventDefinition, EventsResource, Files, Folders, Health, type JobStats, type JobStatus, type LeadSource, type LeadStatus, Leads, type ListLeadsParams, type ListParams, type LogActivityParams, type LogCallParams, type LogFilter, Marketing, MediaResource, Meetings, Messages, Notes, Notifications, Payments, type PipelineStageParams, Pipelines, Queue, RateLimitError, Scoring, type ScoringConfig, type SendCampaignParams, type SendCampaignPayload, type SendMessageParams, type SendTemplateParams, type SendTemplatePayload, Sequences, Storage, type SystemHealth, type TemplateMapping, Templates, type TriggerPayload, type TriggerResponse, type UpdateMeetingParams, type UploadOptions, type UpsertLeadParams, WebhookSignatureError, Webhooks, WhatsApp, WhatsAppMarketing, Ecodrix as default };
|