getricky 0.1.26 → 0.1.29

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.
@@ -26,1962 +26,2157 @@ export type Error = {
26
26
  };
27
27
  };
28
28
  /**
29
- * A campaign of a connected ad account.
29
+ * The ad as Ricky's Meta Ads sync last stored it, matched by `ad_id`. It is Ricky's lookup in the connected ad account, not part of the message Meta sent. `GET /ads/ads` reads the same ad live from Meta.
30
30
  */
31
- export type MetaAdsCampaign = {
31
+ export type AdReferralResolution = {
32
+ /**
33
+ * Name of the ad in Meta.
34
+ */
35
+ ad_name: string | null;
32
36
  /**
33
37
  * Campaign ID at Meta.
34
38
  */
35
- id: string;
39
+ campaign_id: string | null;
36
40
  /**
37
- * Ad account ID at Meta.
41
+ * Campaign name in Meta.
38
42
  */
39
- account_id: string;
43
+ campaign_name: string | null;
40
44
  /**
41
- * Name in Meta.
45
+ * Ad set ID at Meta.
42
46
  */
43
- name: string;
47
+ ad_set_id: string | null;
44
48
  /**
45
- * Objective, such as `OUTCOME_ENGAGEMENT`.
49
+ * Ad set name in Meta.
46
50
  */
47
- objective: string | null;
51
+ ad_set_name: string | null;
48
52
  /**
49
- * Status the advertiser set: `ACTIVE`, `PAUSED`, …
53
+ * Ad account ID at Meta.
50
54
  */
51
- status: string;
55
+ ad_account_id: string | null;
52
56
  /**
53
- * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
57
+ * When Ricky last synced this ad from Meta.
54
58
  */
55
- effective_status: string;
59
+ synced_at: string | null;
60
+ };
61
+ /**
62
+ * A Meta ad a customer came from: an inbound message whose Meta referral names an ad (Click to WhatsApp, Instagram or Messenger ads). The same definition as `GET /reports/ads`.
63
+ */
64
+ export type AdReferral = {
56
65
  /**
57
- * `AUCTION` or `RESERVED`.
66
+ * Meta's ID of the ad, as Meta sent it in the message's referral: WhatsApp `source_id`, Instagram and Messenger `ad_id`. The same ID as `GET /ads/ads` and `ad_id` in `GET /ads/insights`.
58
67
  */
59
- buying_type: string | null;
68
+ ad_id: string;
60
69
  /**
61
- * Bid strategy, when the campaign sets one.
70
+ * Channel the customer wrote on.
62
71
  */
63
- bid_strategy: string | null;
72
+ channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
64
73
  /**
65
- * Budget as Meta reports it, in the ad account currency.
74
+ * The customer message that carried the referral.
66
75
  */
67
- budget: {
68
- /**
69
- * Daily budget in the account currency; null when not set.
70
- */
71
- daily: number | null;
72
- /**
73
- * Lifetime budget in the account currency; null when not set.
74
- */
75
- lifetime: number | null;
76
- /**
77
- * Budget left in the account currency.
78
- */
79
- remaining: number | null;
80
- };
76
+ message_id: string;
81
77
  /**
82
- * ISO 8601 time as Meta reports it; null if unset.
78
+ * Conversation of that message.
83
79
  */
84
- start_time: string | null;
80
+ conversation_id: string;
81
+ contact_id: string | null;
85
82
  /**
86
- * ISO 8601 time as Meta reports it; null if unset.
83
+ * When the customer sent that message.
87
84
  */
88
- stop_time: string | null;
85
+ referred_at: string;
89
86
  /**
90
- * ISO 8601 time as Meta reports it; null if unset.
87
+ * Meta's kind of source: WhatsApp's `source_type` (`ad`) or Instagram and Messenger's `source` (`ADS`).
91
88
  */
92
- created_time: string | null;
89
+ source_type: string | null;
93
90
  /**
94
- * ISO 8601 time as Meta reports it; null if unset.
91
+ * Link to the ad's post on Facebook or Instagram, as Meta sent it. WhatsApp only.
95
92
  */
96
- updated_time: string | null;
97
- };
98
- /**
99
- * An ad set of a connected ad account.
100
- */
101
- export type MetaAdsAdSet = {
93
+ source_url: string | null;
102
94
  /**
103
- * Ad set ID at Meta.
95
+ * The ad's title as Meta sent it: WhatsApp `headline`, Instagram and Messenger `ads_context_data.ad_title`.
104
96
  */
105
- id: string;
97
+ headline: string | null;
106
98
  /**
107
- * Ad account ID at Meta.
99
+ * The ad's text as Meta sent it. WhatsApp only.
108
100
  */
109
- account_id: string;
101
+ body: string | null;
110
102
  /**
111
- * Campaign ID at Meta.
103
+ * `image` or `video`, as Meta sent it. WhatsApp only.
112
104
  */
113
- campaign_id: string;
105
+ media_type: string | null;
114
106
  /**
115
- * Name in Meta.
107
+ * The ad's image: Ricky's permanent copy of the image Meta sent, else Meta's own link while it has not expired; null otherwise.
116
108
  */
117
- name: string;
109
+ image_url: string | null;
118
110
  /**
119
- * Status the advertiser set: `ACTIVE`, `PAUSED`, …
111
+ * Meta's link to the ad's video, as Meta sent it; it can expire.
120
112
  */
121
- status: string;
113
+ video_url: string | null;
122
114
  /**
123
- * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
115
+ * Meta's click ID of the Click to WhatsApp ad, as Meta sent it; send it back to Meta's Conversions API to attribute an event. WhatsApp only.
124
116
  */
125
- effective_status: string;
117
+ ctwa_clid: string | null;
126
118
  /**
127
- * What Meta optimizes delivery for.
119
+ * The `ref` parameter of the ad link, as Meta sent it. Instagram and Messenger only.
128
120
  */
129
- optimization_goal: string | null;
121
+ ref: string | null;
130
122
  /**
131
- * What Meta charges for.
123
+ * The ad's name, campaign and ad set from Ricky's Meta Ads sync; null when the ad is not in a connected ad account Ricky has synced.
132
124
  */
133
- billing_event: string | null;
125
+ resolved: AdReferralResolution | null;
126
+ };
127
+ /**
128
+ * The days a report covers, in America/Panama time, and the period it is compared with.
129
+ */
130
+ export type ReportPeriod = {
134
131
  /**
135
- * Bid strategy, when the campaign sets one.
132
+ * First day, inclusive.
136
133
  */
137
- bid_strategy: string | null;
134
+ from: string;
138
135
  /**
139
- * Budget as Meta reports it, in the ad account currency.
136
+ * Last day, inclusive. A `to` after today is today.
140
137
  */
141
- budget: {
142
- /**
143
- * Daily budget in the account currency; null when not set.
144
- */
145
- daily: number | null;
146
- /**
147
- * Lifetime budget in the account currency; null when not set.
148
- */
149
- lifetime: number | null;
150
- /**
151
- * Budget left in the account currency.
152
- */
153
- remaining: number | null;
154
- };
138
+ to: string;
155
139
  /**
156
- * ISO 8601 time as Meta reports it; null if unset.
140
+ * Days in the period.
157
141
  */
158
- start_time: string | null;
142
+ days: number;
159
143
  /**
160
- * ISO 8601 time as Meta reports it; null if unset.
144
+ * `hour` when the period is one day: series then have 24 hourly slots.
161
145
  */
162
- end_time: string | null;
146
+ granularity: 'day' | 'hour';
163
147
  /**
164
- * Meta's targeting spec as Meta returns it: ages, locations, interests, …
148
+ * The time zone of every day and hour in the report.
165
149
  */
166
- targeting: unknown;
150
+ time_zone: 'America/Panama';
167
151
  /**
168
- * ISO 8601 time as Meta reports it; null if unset.
152
+ * First day of the previous period: the same number of days, right before.
169
153
  */
170
- created_time: string | null;
154
+ previous_from: string;
171
155
  /**
172
- * ISO 8601 time as Meta reports it; null if unset.
156
+ * Last day of the previous period.
173
157
  */
174
- updated_time: string | null;
158
+ previous_to: string;
175
159
  };
176
160
  /**
177
- * An ad of a connected ad account, with its creative copy.
161
+ * How many customers write, whether they are new, and when. Only messages customers send count: a customer is a conversation with at least one of them in the period, and it is new when its first message ever falls in the period. Messages from the team, AI agents or campaigns and conversation openings and closes play no part.
178
162
  */
179
- export type MetaAdsAd = {
180
- /**
181
- * Ad ID at Meta.
182
- */
183
- id: string;
184
- /**
185
- * Ad account ID at Meta.
186
- */
187
- account_id: string;
188
- /**
189
- * Campaign ID at Meta.
190
- */
191
- campaign_id: string;
192
- /**
193
- * Ad set ID at Meta.
194
- */
195
- ad_set_id: string;
163
+ export type ConversationsReport = {
164
+ period: ReportPeriod;
196
165
  /**
197
- * Name in Meta.
166
+ * The channel filter the report applied.
198
167
  */
199
- name: string;
168
+ channel: 'all' | 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
200
169
  /**
201
- * Status the advertiser set: `ACTIVE`, `PAUSED`, …
170
+ * The period.
202
171
  */
203
- status: string;
172
+ totals: {
173
+ /**
174
+ * Conversations with at least one customer message in the period.
175
+ */
176
+ customers: number;
177
+ /**
178
+ * Customers whose first message ever falls in the period.
179
+ */
180
+ new_customers: number;
181
+ /**
182
+ * Customers who had written before the period.
183
+ */
184
+ returning_customers: number;
185
+ /**
186
+ * Messages customers sent in the period.
187
+ */
188
+ messages: number;
189
+ };
204
190
  /**
205
- * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
191
+ * The previous period.
206
192
  */
207
- effective_status: string;
193
+ previous: {
194
+ /**
195
+ * Conversations with at least one customer message in the period.
196
+ */
197
+ customers: number;
198
+ /**
199
+ * Customers whose first message ever falls in the period.
200
+ */
201
+ new_customers: number;
202
+ /**
203
+ * Customers who had written before the period.
204
+ */
205
+ returning_customers: number;
206
+ /**
207
+ * Messages customers sent in the period.
208
+ */
209
+ messages: number;
210
+ };
208
211
  /**
209
- * The creative the ad runs; null when Meta returns none.
212
+ * The period per channel, most customers first.
210
213
  */
211
- creative: {
214
+ by_channel: Array<{
212
215
  /**
213
- * Creative ID at Meta.
216
+ * Channel.
214
217
  */
215
- id: string;
218
+ channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
216
219
  /**
217
- * Headline.
220
+ * Conversations with at least one customer message in the period.
218
221
  */
219
- title: string | null;
222
+ customers: number;
220
223
  /**
221
- * Primary text.
224
+ * Customers whose first message ever falls in the period.
222
225
  */
223
- body: string | null;
226
+ new_customers: number;
224
227
  /**
225
- * Button, such as `LEARN_MORE`.
228
+ * Customers who had written before the period.
226
229
  */
227
- call_to_action_type: string | null;
230
+ returning_customers: number;
228
231
  /**
229
- * Image URL Meta returns.
232
+ * Messages customers sent in the period.
230
233
  */
231
- image_url: string | null;
234
+ messages: number;
235
+ }>;
236
+ /**
237
+ * One entry per day of the period, or per hour of a one-day period.
238
+ */
239
+ series: Array<{
232
240
  /**
233
- * Thumbnail URL Meta returns; it expires.
241
+ * America/Panama day `YYYY-MM-DD`, or hour `YYYY-MM-DDTHH` when the period is one day.
234
242
  */
235
- thumbnail_url: string | null;
243
+ slot: string;
236
244
  /**
237
- * The Instagram post it runs.
245
+ * Customers whose first message ever falls in this slot.
238
246
  */
239
- instagram_permalink_url: string | null;
247
+ new_customers: number;
240
248
  /**
241
- * Meta's story spec as Meta returns it: page, link, message and media.
249
+ * Customers who wrote in this slot and had written before.
242
250
  */
243
- object_story_spec: unknown;
244
- } | null;
251
+ returning_customers: number;
252
+ previous_customers: number | null;
253
+ }>;
245
254
  /**
246
- * ISO 8601 time as Meta reports it; null if unset.
255
+ * Customer messages of the period per weekday and hour; slots without any are left out.
247
256
  */
248
- created_time: string | null;
257
+ heatmap: Array<{
258
+ /**
259
+ * 0 is Sunday, 6 is Saturday.
260
+ */
261
+ day_of_week: number;
262
+ /**
263
+ * Hour of the day, 0–23.
264
+ */
265
+ hour: number;
266
+ /**
267
+ * Customer messages in that hour of that weekday.
268
+ */
269
+ messages: number;
270
+ }>;
249
271
  /**
250
- * ISO 8601 time as Meta reports it; null if unset.
272
+ * When Ricky computed the report.
251
273
  */
252
- updated_time: string | null;
274
+ generated_at: string;
253
275
  };
254
276
  /**
255
- * Performance Meta computed for one row of the requested level, period and breakdowns.
277
+ * Messages received from customers and sent to them in the period, and who sent them, dated when each message was sent.
256
278
  */
257
- export type MetaAdsInsight = {
258
- /**
259
- * Ad account ID at Meta.
260
- */
261
- account_id: string;
262
- /**
263
- * Campaign ID, at campaign level or below.
264
- */
265
- campaign_id: string | null;
266
- /**
267
- * Campaign name, at campaign level or below.
268
- */
269
- campaign_name: string | null;
270
- /**
271
- * Ad set ID, at ad set level or below.
272
- */
273
- ad_set_id: string | null;
274
- /**
275
- * Ad set name, at ad set level or below.
276
- */
277
- ad_set_name: string | null;
278
- /**
279
- * Ad ID, at ad level.
280
- */
281
- ad_id: string | null;
282
- /**
283
- * Ad name, at ad level.
284
- */
285
- ad_name: string | null;
286
- /**
287
- * First day of the row, in the ad account's time zone.
288
- */
289
- date_start: string;
279
+ export type MessagesReport = {
280
+ period: ReportPeriod;
290
281
  /**
291
- * Last day of the row, in the ad account's time zone.
282
+ * The channel filter the report applied.
292
283
  */
293
- date_stop: string;
284
+ channel: 'all' | 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
294
285
  /**
295
- * The value of each requested breakdown for this row, such as `{"age": "25-34"}`.
286
+ * The period.
296
287
  */
297
- breakdown: {
298
- [key: string]: string;
288
+ totals: {
289
+ /**
290
+ * Messages customers sent.
291
+ */
292
+ received: number;
293
+ /**
294
+ * Messages sent to customers, by anyone; the sum of `sent_by`.
295
+ */
296
+ sent: number;
297
+ /**
298
+ * Sent messages by sender; each message counts in one of them.
299
+ */
300
+ sent_by: {
301
+ /**
302
+ * Sent by a person in Ricky.
303
+ */
304
+ human: number;
305
+ /**
306
+ * Sent by an AI agent.
307
+ */
308
+ ai: number;
309
+ /**
310
+ * Sent by an automation.
311
+ */
312
+ automation: number;
313
+ /**
314
+ * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
315
+ */
316
+ campaign: number;
317
+ /**
318
+ * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
319
+ */
320
+ external: number;
321
+ };
299
322
  };
300
323
  /**
301
- * ISO 4217 currency of the ad account.
302
- */
303
- currency_code: string;
304
- /**
305
- * Spend in the account currency.
306
- */
307
- spend: number | null;
308
- /**
309
- * Impressions.
310
- */
311
- impressions: number | null;
312
- /**
313
- * People reached.
314
- */
315
- reach: number | null;
316
- /**
317
- * Impressions per person reached.
318
- */
319
- frequency: number | null;
320
- /**
321
- * Clicks.
322
- */
323
- clicks: number | null;
324
- /**
325
- * Click-through rate, in percent.
326
- */
327
- ctr: number | null;
328
- /**
329
- * Cost per click.
330
- */
331
- cpc: number | null;
332
- /**
333
- * Cost per 1,000 impressions.
324
+ * The previous period.
334
325
  */
335
- cpm: number | null;
326
+ previous: {
327
+ /**
328
+ * Messages customers sent.
329
+ */
330
+ received: number;
331
+ /**
332
+ * Messages sent to customers, by anyone; the sum of `sent_by`.
333
+ */
334
+ sent: number;
335
+ /**
336
+ * Sent messages by sender; each message counts in one of them.
337
+ */
338
+ sent_by: {
339
+ /**
340
+ * Sent by a person in Ricky.
341
+ */
342
+ human: number;
343
+ /**
344
+ * Sent by an AI agent.
345
+ */
346
+ ai: number;
347
+ /**
348
+ * Sent by an automation.
349
+ */
350
+ automation: number;
351
+ /**
352
+ * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
353
+ */
354
+ campaign: number;
355
+ /**
356
+ * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
357
+ */
358
+ external: number;
359
+ };
360
+ };
336
361
  /**
337
- * Actions Meta counted, per action type.
362
+ * The period per channel, most messages first.
338
363
  */
339
- actions: Array<{
364
+ by_channel: Array<{
340
365
  /**
341
- * Meta's action type, such as `link_click` or `onsite_conversion.messaging_conversation_started_7d`.
366
+ * Channel.
342
367
  */
343
- action_type: string;
368
+ channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
344
369
  /**
345
- * Count, or cost in the account currency.
370
+ * Messages customers sent.
346
371
  */
347
- value: number;
372
+ received: number;
373
+ /**
374
+ * Messages sent to customers, by anyone; the sum of `sent_by`.
375
+ */
376
+ sent: number;
377
+ /**
378
+ * Sent messages by sender; each message counts in one of them.
379
+ */
380
+ sent_by: {
381
+ /**
382
+ * Sent by a person in Ricky.
383
+ */
384
+ human: number;
385
+ /**
386
+ * Sent by an AI agent.
387
+ */
388
+ ai: number;
389
+ /**
390
+ * Sent by an automation.
391
+ */
392
+ automation: number;
393
+ /**
394
+ * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
395
+ */
396
+ campaign: number;
397
+ /**
398
+ * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
399
+ */
400
+ external: number;
401
+ };
348
402
  }>;
349
403
  /**
350
- * Cost of each action type.
404
+ * One entry per day of the period, or per hour of a one-day period.
351
405
  */
352
- cost_per_action: Array<{
406
+ series: Array<{
353
407
  /**
354
- * Meta's action type, such as `link_click` or `onsite_conversion.messaging_conversation_started_7d`.
408
+ * America/Panama day `YYYY-MM-DD`, or hour `YYYY-MM-DDTHH` when the period is one day.
355
409
  */
356
- action_type: string;
410
+ slot: string;
357
411
  /**
358
- * Count, or cost in the account currency.
412
+ * Messages customers sent.
359
413
  */
360
- value: number;
414
+ received: number;
415
+ /**
416
+ * Messages sent to customers, by anyone; the sum of `sent_by`.
417
+ */
418
+ sent: number;
419
+ /**
420
+ * Sent messages by sender; each message counts in one of them.
421
+ */
422
+ sent_by: {
423
+ /**
424
+ * Sent by a person in Ricky.
425
+ */
426
+ human: number;
427
+ /**
428
+ * Sent by an AI agent.
429
+ */
430
+ ai: number;
431
+ /**
432
+ * Sent by an automation.
433
+ */
434
+ automation: number;
435
+ /**
436
+ * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
437
+ */
438
+ campaign: number;
439
+ /**
440
+ * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
441
+ */
442
+ external: number;
443
+ };
444
+ previous_received: number | null;
445
+ previous_sent: number | null;
361
446
  }>;
447
+ /**
448
+ * When Ricky computed the report.
449
+ */
450
+ generated_at: string;
362
451
  };
363
452
  /**
364
- * An AI agent that answers conversations alongside the team.
453
+ * What the inbox looks like right now; it has no period.
365
454
  */
366
- export type Agent = {
367
- /**
368
- * Agent ID.
369
- */
370
- id: string;
371
- /**
372
- * Name the team sees.
373
- */
374
- name: string;
375
- /**
376
- * What the agent is for.
377
- */
378
- description: string | null;
455
+ export type DashboardReport = {
379
456
  /**
380
- * How the agent answers customers.
457
+ * Now.
381
458
  */
382
- instructions: string | null;
383
- /**
384
- * Voice on calls; one of `GET /agent-options`.
385
- */
386
- voice: string;
387
- /**
388
- * What the agent may do beyond replying, by capability `name`.
389
- */
390
- capabilities: Array<string>;
459
+ totals: {
460
+ /**
461
+ * Open conversations.
462
+ */
463
+ open_now: number;
464
+ /**
465
+ * Open conversations with no member or AI agent assigned.
466
+ */
467
+ unassigned: number;
468
+ /**
469
+ * Open conversations whose last message, reactions aside, is from the customer.
470
+ */
471
+ awaiting_reply: number;
472
+ /**
473
+ * Handoffs from an AI agent to a person still waiting.
474
+ */
475
+ pending_handoffs: number;
476
+ /**
477
+ * Conversations opened or reopened today, America/Panama.
478
+ */
479
+ opened_today: number;
480
+ /**
481
+ * Conversations closed today, America/Panama.
482
+ */
483
+ closed_today: number;
484
+ };
391
485
  /**
392
- * Members who receive the conversation when the agent hands it to a person.
486
+ * Open conversations per channel, most first.
393
487
  */
394
- handoff_user_ids: Array<string>;
488
+ by_channel: Array<{
489
+ /**
490
+ * Channel.
491
+ */
492
+ channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
493
+ /**
494
+ * Open conversations.
495
+ */
496
+ open: number;
497
+ }>;
395
498
  /**
396
- * When it was created.
499
+ * Open conversations per assignee, most first.
397
500
  */
398
- created_at: string;
501
+ assignees: Array<{
502
+ /**
503
+ * `human` is a member, `ai` an AI agent, `unassigned` nobody.
504
+ */
505
+ type: 'human' | 'ai' | 'unassigned';
506
+ /**
507
+ * User ID or AI agent ID; null for `unassigned`.
508
+ */
509
+ id: string | null;
510
+ /**
511
+ * Name; null when it has none and for `unassigned`.
512
+ */
513
+ name: string | null;
514
+ /**
515
+ * Open conversations they hold.
516
+ */
517
+ open: number;
518
+ /**
519
+ * Of those, the ones whose last message is from the customer.
520
+ */
521
+ awaiting_reply: number;
522
+ }>;
399
523
  /**
400
- * Last change to its settings.
524
+ * The 15 open conversations waiting longest for a reply, oldest first.
401
525
  */
402
- updated_at: string;
526
+ longest_waiting: Array<{
527
+ /**
528
+ * Conversation ID.
529
+ */
530
+ conversation_id: string;
531
+ /**
532
+ * Channel.
533
+ */
534
+ channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
535
+ /**
536
+ * Customer name as the inbox shows it: the contact’s saved name, else the channel profile name, else the contact’s phone.
537
+ */
538
+ participant_name: string | null;
539
+ /**
540
+ * When the customer message they wait on arrived.
541
+ */
542
+ waiting_since: string;
543
+ /**
544
+ * `human` is a member, `ai` an AI agent, `unassigned` nobody.
545
+ */
546
+ assignee_type: 'human' | 'ai' | 'unassigned';
547
+ /**
548
+ * Assignee name; null when there is none.
549
+ */
550
+ assignee_name: string | null;
551
+ }>;
403
552
  /**
404
- * When it was archived; null while active.
553
+ * When Ricky computed the report.
405
554
  */
406
- archived_at: string | null;
555
+ generated_at: string;
407
556
  };
408
557
  /**
409
- * What an agent can be configured with.
558
+ * A conversation a Meta ad opened or brought back in the period, with what happened after. One row per conversation and ad: a conversation two ads brought back has two rows.
410
559
  */
411
- export type AgentOptions = {
560
+ export type AdConversation = {
412
561
  /**
413
- * Voices an agent can use.
562
+ * The first customer message from this ad in this conversation within the period.
414
563
  */
415
- voices: Array<string>;
564
+ ad_referral: AdReferral;
416
565
  /**
417
- * Voice of an agent created without one.
566
+ * Whether that message started the conversation: no message came before it. False when the ad brought back someone who had written before.
418
567
  */
419
- default_voice: string;
568
+ opened_conversation: boolean;
420
569
  /**
421
- * Capabilities an agent can be given.
570
+ * Text of that message: what the customer wrote, often the greeting the ad prefilled.
422
571
  */
423
- capabilities: Array<{
572
+ message_text: string | null;
573
+ /**
574
+ * Who wrote.
575
+ */
576
+ contact: {
577
+ id: string | null;
424
578
  /**
425
- * Capability name, the value in `capabilities`.
579
+ * Name saved on the contact, else the name on the channel.
426
580
  */
427
- name: string;
581
+ name: string | null;
428
582
  /**
429
- * Display name in Ricky.
583
+ * Phone saved on the contact, in E.164.
430
584
  */
431
- label: string;
585
+ phone: string | null;
432
586
  /**
433
- * What it lets the agent do, as Ricky shows it.
587
+ * Address on the channel: phone digits for WhatsApp, account ID otherwise.
434
588
  */
435
- description: string;
589
+ external_id: string;
590
+ };
591
+ /**
592
+ * The conversation as it is now.
593
+ */
594
+ conversation: {
436
595
  /**
437
- * Integration it belongs to; it works only once the organization connects it in Ricky. `human_handoff` needs no connection but requires `handoff_user_ids`.
596
+ * Conversation ID.
438
597
  */
439
- family: string;
440
- }>;
441
- };
442
- /**
443
- * A label applied to contacts.
444
- */
445
- export type Tag = {
598
+ id: string;
599
+ /**
600
+ * Its state now.
601
+ */
602
+ status: 'open' | 'closed';
603
+ /**
604
+ * Why it was closed: `sale` when a member closed it as a sale, the only sign of a purchase Ricky records, without an amount. Null while open or when closed without a category.
605
+ */
606
+ close_category: 'resolved' | 'sale' | 'no_response' | 'spam' | 'other' | null;
607
+ /**
608
+ * When it was closed; null while open.
609
+ */
610
+ closed_at: string | null;
611
+ /**
612
+ * When Ricky created it.
613
+ */
614
+ created_at: string;
615
+ };
446
616
  /**
447
- * Tag ID.
617
+ * Messages the customer sent in the conversation from that message on, that one included; reactions do not count.
448
618
  */
449
- id: string;
619
+ customer_messages: number;
450
620
  /**
451
- * Display name.
621
+ * Replies from that message on by a member in Ricky, an AI agent or someone in the channel's own app. Automations, broadcasts, templates and reactions do not count.
452
622
  */
453
- name: string;
623
+ replies: number;
454
624
  /**
455
- * Display color.
625
+ * Seconds from that message to the first reply; null while unanswered.
456
626
  */
457
- color: 'gray' | 'red' | 'orange' | 'amber' | 'green' | 'teal' | 'blue' | 'indigo' | 'purple' | 'pink';
627
+ first_reply_seconds: number | null;
458
628
  };
459
629
  /**
460
- * How a contact is reached on one channel.
630
+ * A campaign of a connected ad account.
461
631
  */
462
- export type ContactIdentity = {
632
+ export type MetaAdsCampaign = {
463
633
  /**
464
- * Identity ID.
634
+ * Campaign ID at Meta.
465
635
  */
466
636
  id: string;
467
637
  /**
468
- * Channel this identity belongs to.
638
+ * Ad account ID at Meta.
469
639
  */
470
- channel_type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
640
+ account_id: string;
471
641
  /**
472
- * Address on that channel: phone digits for WhatsApp, account ID otherwise.
642
+ * Name in Meta.
473
643
  */
474
- external_id: string;
644
+ name: string;
475
645
  /**
476
- * Name the channel reports.
646
+ * Objective, such as `OUTCOME_ENGAGEMENT`.
477
647
  */
478
- display_name: string | null;
648
+ objective: string | null;
479
649
  /**
480
- * Handle on the channel, when it has one.
650
+ * Status the advertiser set: `ACTIVE`, `PAUSED`, …
481
651
  */
482
- username: string | null;
483
- };
484
- /**
485
- * A person in the CRM.
486
- */
487
- export type Contact = {
652
+ status: string;
488
653
  /**
489
- * Contact ID.
654
+ * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
490
655
  */
491
- id: string;
656
+ effective_status: string;
492
657
  /**
493
- * First name.
658
+ * `AUCTION` or `RESERVED`.
494
659
  */
495
- first_name: string | null;
660
+ buying_type: string | null;
496
661
  /**
497
- * Last name.
662
+ * Bid strategy, when the campaign sets one.
498
663
  */
499
- last_name: string | null;
664
+ bid_strategy: string | null;
500
665
  /**
501
- * Email, lowercased.
666
+ * Budget as Meta reports it, in the ad account currency.
502
667
  */
503
- primary_email: string | null;
668
+ budget: {
669
+ /**
670
+ * Daily budget in the account currency; null when not set.
671
+ */
672
+ daily: number | null;
673
+ /**
674
+ * Lifetime budget in the account currency; null when not set.
675
+ */
676
+ lifetime: number | null;
677
+ /**
678
+ * Budget left in the account currency.
679
+ */
680
+ remaining: number | null;
681
+ };
504
682
  /**
505
- * Phone in E.164.
683
+ * ISO 8601 time as Meta reports it; null if unset.
506
684
  */
507
- primary_phone: string | null;
685
+ start_time: string | null;
508
686
  /**
509
- * Company.
687
+ * ISO 8601 time as Meta reports it; null if unset.
510
688
  */
511
- company: string | null;
689
+ stop_time: string | null;
512
690
  /**
513
- * Job title.
691
+ * ISO 8601 time as Meta reports it; null if unset.
514
692
  */
515
- job_title: string | null;
693
+ created_time: string | null;
516
694
  /**
517
- * Birthday as `YYYY-MM-DD`.
695
+ * ISO 8601 time as Meta reports it; null if unset.
518
696
  */
519
- birthday: string | null;
697
+ updated_time: string | null;
698
+ };
699
+ /**
700
+ * An ad set of a connected ad account.
701
+ */
702
+ export type MetaAdsAdSet = {
520
703
  /**
521
- * City.
704
+ * Ad set ID at Meta.
522
705
  */
523
- city: string | null;
706
+ id: string;
524
707
  /**
525
- * State, province or region.
708
+ * Ad account ID at Meta.
526
709
  */
527
- region: string | null;
710
+ account_id: string;
528
711
  /**
529
- * Country.
712
+ * Campaign ID at Meta.
530
713
  */
531
- country: string | null;
714
+ campaign_id: string;
532
715
  /**
533
- * Street address.
716
+ * Name in Meta.
534
717
  */
535
- street_address: string | null;
718
+ name: string;
536
719
  /**
537
- * Postal code.
720
+ * Status the advertiser set: `ACTIVE`, `PAUSED`, …
538
721
  */
539
- postal_code: string | null;
722
+ status: string;
540
723
  /**
541
- * Website URL.
724
+ * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
542
725
  */
543
- website_url: string | null;
726
+ effective_status: string;
544
727
  /**
545
- * LinkedIn profile URL.
728
+ * What Meta optimizes delivery for.
546
729
  */
547
- linkedin_url: string | null;
548
- /**
549
- * Where the contact came from.
550
- */
551
- source: string | null;
552
- /**
553
- * Free-form notes.
554
- */
555
- notes: string | null;
730
+ optimization_goal: string | null;
556
731
  /**
557
- * Deprecated: contacts no longer have an owner; the member responsible is each conversation's `assigned_user_id`. Always `null`.
558
- *
559
- * @deprecated
732
+ * What Meta charges for.
560
733
  */
561
- owner_user_id: string | null;
734
+ billing_event: string | null;
562
735
  /**
563
- * Sales lead status.
736
+ * Bid strategy, when the campaign sets one.
564
737
  */
565
- lead_status: 'new' | 'open' | 'in_progress' | 'attempted' | 'connected' | 'unqualified' | 'bad_timing' | null;
738
+ bid_strategy: string | null;
566
739
  /**
567
- * Custom field values keyed by contact field ID. See `GET /contact-fields`.
740
+ * Budget as Meta reports it, in the ad account currency.
568
741
  */
569
- custom_values: {
570
- [key: string]: string | number | boolean | Array<string> | null;
742
+ budget: {
743
+ /**
744
+ * Daily budget in the account currency; null when not set.
745
+ */
746
+ daily: number | null;
747
+ /**
748
+ * Lifetime budget in the account currency; null when not set.
749
+ */
750
+ lifetime: number | null;
751
+ /**
752
+ * Budget left in the account currency.
753
+ */
754
+ remaining: number | null;
571
755
  };
572
756
  /**
573
- * Channel identities.
757
+ * ISO 8601 time as Meta reports it; null if unset.
574
758
  */
575
- identities: Array<ContactIdentity>;
759
+ start_time: string | null;
576
760
  /**
577
- * Tags applied to the contact.
761
+ * ISO 8601 time as Meta reports it; null if unset.
578
762
  */
579
- tags: Array<Tag>;
763
+ end_time: string | null;
580
764
  /**
581
- * Latest message in any of its conversations.
765
+ * Meta's targeting spec as Meta returns it: ages, locations, interests, …
582
766
  */
583
- last_activity_at: string | null;
767
+ targeting: unknown;
584
768
  /**
585
- * Text of that latest message.
769
+ * ISO 8601 time as Meta reports it; null if unset.
586
770
  */
587
- last_activity_preview: string | null;
588
- last_conversation_id: string | null;
771
+ created_time: string | null;
589
772
  /**
590
- * Last change to the contact.
773
+ * ISO 8601 time as Meta reports it; null if unset.
591
774
  */
592
- updated_at: string;
775
+ updated_time: string | null;
593
776
  };
594
777
  /**
595
- * A custom contact field defined by the organization.
778
+ * An ad of a connected ad account, with its creative copy.
596
779
  */
597
- export type ContactField = {
780
+ export type MetaAdsAd = {
598
781
  /**
599
- * Field ID; the key in `custom_values`.
782
+ * Ad ID at Meta.
600
783
  */
601
784
  id: string;
602
785
  /**
603
- * Display name.
786
+ * Ad account ID at Meta.
604
787
  */
605
- name: string;
788
+ account_id: string;
606
789
  /**
607
- * Value type: `number` takes a number, `boolean` a boolean, `date` `YYYY-MM-DD`, `select` one option, `multi_select` an array of options, the rest a string.
790
+ * Campaign ID at Meta.
608
791
  */
609
- type: 'text' | 'long_text' | 'number' | 'boolean' | 'date' | 'select' | 'multi_select';
792
+ campaign_id: string;
610
793
  /**
611
- * Allowed values for `select` and `multi_select`.
794
+ * Ad set ID at Meta.
612
795
  */
613
- options: Array<string>;
614
- };
615
- /**
616
- * A connected messaging channel.
617
- */
618
- export type Channel = {
796
+ ad_set_id: string;
619
797
  /**
620
- * Channel ID.
798
+ * Name in Meta.
621
799
  */
622
- id: string;
800
+ name: string;
623
801
  /**
624
- * Messaging channel.
802
+ * Status the advertiser set: `ACTIVE`, `PAUSED`, …
625
803
  */
626
- type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
804
+ status: string;
627
805
  /**
628
- * Name shown in Ricky.
806
+ * Delivery status, including a parent paused: `ACTIVE`, `CAMPAIGN_PAUSED`, …
629
807
  */
630
- name: string;
808
+ effective_status: string;
631
809
  /**
632
- * Phone in E.164 for WhatsApp, account or page name otherwise.
810
+ * The creative the ad runs; null when Meta returns none.
633
811
  */
634
- address: string | null;
812
+ creative: {
813
+ /**
814
+ * Creative ID at Meta.
815
+ */
816
+ id: string;
817
+ /**
818
+ * Headline.
819
+ */
820
+ title: string | null;
821
+ /**
822
+ * Primary text.
823
+ */
824
+ body: string | null;
825
+ /**
826
+ * Button, such as `LEARN_MORE`.
827
+ */
828
+ call_to_action_type: string | null;
829
+ /**
830
+ * Image URL Meta returns.
831
+ */
832
+ image_url: string | null;
833
+ /**
834
+ * Thumbnail URL Meta returns; it expires.
835
+ */
836
+ thumbnail_url: string | null;
837
+ /**
838
+ * The Instagram post it runs.
839
+ */
840
+ instagram_permalink_url: string | null;
841
+ /**
842
+ * Meta's story spec as Meta returns it: page, link, message and media.
843
+ */
844
+ object_story_spec: unknown;
845
+ } | null;
635
846
  /**
636
- * WhatsApp Business Account that owns the number; templates must belong to it.
847
+ * ISO 8601 time as Meta reports it; null if unset.
637
848
  */
638
- whatsapp_business_account_id: string | null;
849
+ created_time: string | null;
639
850
  /**
640
- * When it was connected.
851
+ * ISO 8601 time as Meta reports it; null if unset.
641
852
  */
642
- connected_at: string | null;
853
+ updated_time: string | null;
643
854
  };
644
855
  /**
645
- * A request for a person to take over from the AI agent, not resolved yet.
856
+ * Performance Meta computed for one row of the requested level, period and breakdowns.
646
857
  */
647
- export type ConversationHandoff = {
858
+ export type MetaAdsInsight = {
648
859
  /**
649
- * Handoff ID.
860
+ * Ad account ID at Meta.
650
861
  */
651
- id: string;
862
+ account_id: string;
652
863
  /**
653
- * `requested` until a member takes it; `assigned` once someone is responsible.
864
+ * Campaign ID, at campaign level or below.
654
865
  */
655
- status: 'requested' | 'assigned';
866
+ campaign_id: string | null;
656
867
  /**
657
- * Whether the AI agent or a member asked for it.
868
+ * Campaign name, at campaign level or below.
658
869
  */
659
- requested_by: 'agent' | 'operator';
870
+ campaign_name: string | null;
660
871
  /**
661
- * Why the conversation needs a person.
872
+ * Ad set ID, at ad set level or below.
662
873
  */
663
- reason: 'customer_requested' | 'low_confidence' | 'manual_takeover' | 'out_of_scope' | 'sensitive' | 'other';
874
+ ad_set_id: string | null;
664
875
  /**
665
- * What the person taking over needs to know.
876
+ * Ad set name, at ad set level or below.
666
877
  */
667
- summary: string;
668
- assigned_user_id: string | null;
878
+ ad_set_name: string | null;
669
879
  /**
670
- * When it was requested.
880
+ * Ad ID, at ad level.
671
881
  */
672
- requested_at: string;
673
- };
674
- /**
675
- * One contact talking to the organization on one channel.
676
- */
677
- export type Conversation = {
882
+ ad_id: string | null;
678
883
  /**
679
- * Conversation ID.
884
+ * Ad name, at ad level.
680
885
  */
681
- id: string;
682
- channel: {
683
- /**
684
- * Channel ID.
685
- */
686
- id: string;
687
- type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
688
- };
689
- contact: {
690
- id: string | null;
691
- /**
692
- * Name on the channel.
693
- */
694
- display_name: string | null;
695
- /**
696
- * Address on the channel.
697
- */
698
- external_id: string;
699
- /**
700
- * Handle, when the channel has one.
701
- */
702
- username: string | null;
703
- } | null;
704
- status: 'open' | 'closed';
886
+ ad_name: string | null;
705
887
  /**
706
- * Why it was closed; null while open or when closed without one.
888
+ * First day of the row, in the ad account's time zone.
707
889
  */
708
- close_category: 'resolved' | 'sale' | 'no_response' | 'spam' | 'other' | null;
709
- assigned_user_id: string | null;
710
- agent_id: string | null;
890
+ date_start: string;
711
891
  /**
712
- * When it was created.
892
+ * Last day of the row, in the ad account's time zone.
713
893
  */
714
- created_at: string;
894
+ date_stop: string;
715
895
  /**
716
- * Start of the current open span.
896
+ * The value of each requested breakdown for this row, such as `{"age": "25-34"}`.
717
897
  */
718
- opened_at: string;
898
+ breakdown: {
899
+ [key: string]: string;
900
+ };
719
901
  /**
720
- * When it was closed; null while open.
902
+ * ISO 4217 currency of the ad account.
721
903
  */
722
- closed_at: string | null;
904
+ currency_code: string;
723
905
  /**
724
- * Latest message.
906
+ * Spend in the account currency.
725
907
  */
726
- last_activity_at: string | null;
908
+ spend: number | null;
727
909
  /**
728
- * Text of the latest message.
910
+ * Impressions.
729
911
  */
730
- last_activity_preview: string | null;
912
+ impressions: number | null;
731
913
  /**
732
- * Whether it has messages the team has not read.
914
+ * People reached.
733
915
  */
734
- unread: boolean;
916
+ reach: number | null;
735
917
  /**
736
- * The handoff to a person waiting to be resolved; null when there is none.
918
+ * Impressions per person reached.
737
919
  */
738
- active_handoff: ConversationHandoff | null;
739
- };
740
- /**
741
- * One message in a conversation.
742
- */
743
- export type Message = {
920
+ frequency: number | null;
744
921
  /**
745
- * Message ID.
922
+ * Clicks.
746
923
  */
747
- id: string;
924
+ clicks: number | null;
748
925
  /**
749
- * Conversation ID.
926
+ * Click-through rate, in percent.
750
927
  */
751
- conversation_id: string;
752
- direction: 'inbound' | 'outbound';
928
+ ctr: number | null;
753
929
  /**
754
- * Message type: `text`, `image`, `audio`, `video`, `document`, `template`, …
930
+ * Cost per click.
755
931
  */
756
- type: string;
932
+ cpc: number | null;
757
933
  /**
758
- * Text, caption or rendered template body.
934
+ * Cost per 1,000 impressions.
759
935
  */
760
- text: string | null;
761
- sender: {
762
- /**
763
- * `contact`; a `member` in Ricky; an AI `agent`; an `automation`; or `channel_app`, sent from the channel's own app outside Ricky.
764
- */
765
- type: 'contact' | 'member' | 'agent' | 'automation' | 'channel_app';
766
- /**
767
- * Member, agent or workflow name; null for the contact and `channel_app`.
768
- */
769
- name: string | null;
770
- };
936
+ cpm: number | null;
771
937
  /**
772
- * Provider delivery status: `sent`, `delivered`, `read`, `failed`, …
938
+ * Actions Meta counted, per action type.
773
939
  */
774
- status: string;
775
- media: {
776
- /**
777
- * `image`, `audio`, `video`, `document` or `sticker`.
778
- */
779
- kind: string;
940
+ actions: Array<{
780
941
  /**
781
- * MIME type.
942
+ * Meta's action type, such as `link_click` or `onsite_conversion.messaging_conversation_started_7d`.
782
943
  */
783
- mime_type: string | null;
944
+ action_type: string;
784
945
  /**
785
- * File name, for documents.
946
+ * Count, or cost in the account currency.
786
947
  */
787
- filename: string | null;
788
- byte_size: number | null;
948
+ value: number;
949
+ }>;
950
+ /**
951
+ * Cost of each action type.
952
+ */
953
+ cost_per_action: Array<{
789
954
  /**
790
- * Transcript of a voice note.
955
+ * Meta's action type, such as `link_click` or `onsite_conversion.messaging_conversation_started_7d`.
791
956
  */
792
- transcript: string | null;
957
+ action_type: string;
793
958
  /**
794
- * Signed download URL, valid for one hour; null until downloaded.
959
+ * Count, or cost in the account currency.
795
960
  */
796
- url: string | null;
797
- } | null;
961
+ value: number;
962
+ }>;
963
+ };
964
+ /**
965
+ * An AI agent that answers conversations alongside the team.
966
+ */
967
+ export type Agent = {
798
968
  /**
799
- * Message ID at the provider.
969
+ * Agent ID.
800
970
  */
801
- provider_message_id: string | null;
971
+ id: string;
802
972
  /**
803
- * When Ricky recorded it.
973
+ * Name the team sees.
804
974
  */
805
- created_at: string;
975
+ name: string;
806
976
  /**
807
- * When the provider accepted it.
977
+ * What the agent is for.
808
978
  */
809
- sent_at: string | null;
979
+ description: string | null;
810
980
  /**
811
- * When it reached the device.
981
+ * How the agent answers customers.
812
982
  */
813
- delivered_at: string | null;
983
+ instructions: string | null;
814
984
  /**
815
- * When the recipient read it.
985
+ * Voice on calls; one of `GET /agent-options`.
816
986
  */
817
- read_at: string | null;
987
+ voice: string;
818
988
  /**
819
- * When delivery failed.
989
+ * What the agent may do beyond replying, by capability `name`.
820
990
  */
821
- failed_at: string | null;
991
+ capabilities: Array<string>;
822
992
  /**
823
- * When the sender edited it.
993
+ * Members who receive the conversation when the agent hands it to a person.
824
994
  */
825
- edited_at: string | null;
995
+ handoff_user_ids: Array<string>;
826
996
  /**
827
- * When the sender deleted it.
997
+ * When it was created.
828
998
  */
829
- deleted_at: string | null;
999
+ created_at: string;
1000
+ /**
1001
+ * Last change to its settings.
1002
+ */
1003
+ updated_at: string;
1004
+ /**
1005
+ * When it was archived; null while active.
1006
+ */
1007
+ archived_at: string | null;
830
1008
  };
831
1009
  /**
832
- * An outbound message Ricky accepted and is delivering.
1010
+ * What an agent can be configured with.
833
1011
  */
834
- export type Send = {
1012
+ export type AgentOptions = {
835
1013
  /**
836
- * Send ID. Poll `GET /sends/{send_id}` with it.
1014
+ * Voices an agent can use.
837
1015
  */
838
- id: string;
1016
+ voices: Array<string>;
839
1017
  /**
840
- * Conversation the message goes to.
1018
+ * Voice of an agent created without one.
841
1019
  */
842
- conversation_id: string;
1020
+ default_voice: string;
843
1021
  /**
844
- * `sent` once the provider accepted the message; `failed` for good, with the reason; `queued` otherwise, while Ricky retries.
1022
+ * Capabilities an agent can be given.
845
1023
  */
846
- status: 'queued' | 'sent' | 'failed';
847
- message_id: string | null;
1024
+ capabilities: Array<{
1025
+ /**
1026
+ * Capability name, the value in `capabilities`.
1027
+ */
1028
+ name: string;
1029
+ /**
1030
+ * Display name in Ricky.
1031
+ */
1032
+ label: string;
1033
+ /**
1034
+ * What it lets the agent do, as Ricky shows it.
1035
+ */
1036
+ description: string;
1037
+ /**
1038
+ * Integration it belongs to; it works only once the organization connects it in Ricky. `human_handoff` needs no connection but requires `handoff_user_ids`.
1039
+ */
1040
+ family: string;
1041
+ }>;
1042
+ };
1043
+ /**
1044
+ * A label applied to contacts.
1045
+ */
1046
+ export type Tag = {
848
1047
  /**
849
- * Why it failed; null unless `failed`.
1048
+ * Tag ID.
850
1049
  */
851
- failure_reason: string | null;
1050
+ id: string;
852
1051
  /**
853
- * When Ricky accepted it.
1052
+ * Display name.
854
1053
  */
855
- created_at: string;
1054
+ name: string;
1055
+ /**
1056
+ * Display color.
1057
+ */
1058
+ color: 'gray' | 'red' | 'orange' | 'amber' | 'green' | 'teal' | 'blue' | 'indigo' | 'purple' | 'pink';
856
1059
  };
857
1060
  /**
858
- * A person in the organization.
1061
+ * How a contact is reached on one channel.
859
1062
  */
860
- export type Member = {
1063
+ export type ContactIdentity = {
861
1064
  /**
862
- * User ID.
1065
+ * Identity ID.
863
1066
  */
864
1067
  id: string;
865
1068
  /**
866
- * Full name.
1069
+ * Channel this identity belongs to.
867
1070
  */
868
- name: string | null;
1071
+ channel_type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
869
1072
  /**
870
- * Email.
1073
+ * Address on that channel: phone digits for WhatsApp, account ID otherwise.
871
1074
  */
872
- email: string;
873
- role: 'owner' | 'admin' | 'member';
1075
+ external_id: string;
1076
+ /**
1077
+ * Name the channel reports.
1078
+ */
1079
+ display_name: string | null;
1080
+ /**
1081
+ * Handle on the channel, when it has one.
1082
+ */
1083
+ username: string | null;
874
1084
  };
875
1085
  /**
876
- * A WhatsApp message template.
1086
+ * A person in the CRM.
877
1087
  */
878
- export type Template = {
1088
+ export type Contact = {
879
1089
  /**
880
- * Template ID at Meta.
1090
+ * Contact ID.
881
1091
  */
882
1092
  id: string;
883
1093
  /**
884
- * Template name.
1094
+ * First name.
885
1095
  */
886
- name: string;
1096
+ first_name: string | null;
887
1097
  /**
888
- * Language code, for example `es` or `en_US`.
1098
+ * Last name.
889
1099
  */
890
- language: string;
1100
+ last_name: string | null;
891
1101
  /**
892
- * `MARKETING`, `UTILITY` or `AUTHENTICATION`.
1102
+ * Email, lowercased.
893
1103
  */
894
- category: string;
1104
+ primary_email: string | null;
895
1105
  /**
896
- * Meta review status. Only `APPROVED` templates can be sent.
1106
+ * Phone in E.164.
897
1107
  */
898
- status: string;
1108
+ primary_phone: string | null;
899
1109
  /**
900
- * Account that owns it.
1110
+ * Company.
901
1111
  */
902
- whatsapp_business_account_id: string;
1112
+ company: string | null;
903
1113
  /**
904
- * How variables are named: `{{1}}` or `{{name}}`.
1114
+ * Job title.
905
1115
  */
906
- parameter_format: 'POSITIONAL' | 'NAMED' | null;
1116
+ job_title: string | null;
907
1117
  /**
908
- * Header, body, footer and buttons, in the WhatsApp Cloud API format.
1118
+ * Birthday as `YYYY-MM-DD`.
909
1119
  */
910
- components: Array<{
911
- [key: string]: unknown;
912
- }>;
913
- };
914
- /**
915
- * One approved WhatsApp template sent to many numbers.
916
- */
917
- export type Broadcast = {
1120
+ birthday: string | null;
918
1121
  /**
919
- * Broadcast ID.
1122
+ * City.
920
1123
  */
921
- id: string;
1124
+ city: string | null;
922
1125
  /**
923
- * WhatsApp channel it is sent from.
1126
+ * State, province or region.
924
1127
  */
925
- channel_id: string;
1128
+ region: string | null;
926
1129
  /**
927
- * The approved template every recipient receives.
1130
+ * Country.
928
1131
  */
929
- template: {
930
- /**
931
- * Template ID at Meta.
932
- */
933
- id: string;
934
- /**
935
- * Template name.
936
- */
937
- name: string;
938
- /**
939
- * Language code.
940
- */
941
- language: string;
942
- };
1132
+ country: string | null;
943
1133
  /**
944
- * How the recipient list was built: a contact filter, chosen contacts, or phone numbers. The list itself is fixed when the broadcast is created.
1134
+ * Street address.
945
1135
  */
946
- audience: {
947
- type: 'filter';
948
- tag_id: string | null;
949
- /**
950
- * Only contacts whose name, phone, email or company contains it.
951
- */
952
- query: string | null;
953
- } | {
954
- type: 'contacts';
955
- } | {
956
- type: 'phones';
957
- };
1136
+ street_address: string | null;
958
1137
  /**
959
- * `scheduled` waits for `scheduled_at`; `queued` and `sending` are on their way; `completed` once every message was handed to WhatsApp; `canceled` before it started.
1138
+ * Postal code.
960
1139
  */
961
- status: 'scheduled' | 'queued' | 'sending' | 'completed' | 'canceled';
1140
+ postal_code: string | null;
962
1141
  /**
963
- * Recipients in each delivery status. Each recipient counts once, in its current one.
1142
+ * Website URL.
964
1143
  */
965
- counts: {
966
- /**
967
- * Numbers the broadcast goes to.
968
- */
969
- recipients: number;
970
- /**
971
- * Not sent yet, or WhatsApp has not answered yet.
972
- */
973
- pending: number;
974
- /**
975
- * Accepted by WhatsApp, not yet delivered.
976
- */
977
- sent: number;
978
- /**
979
- * Delivered to the phone, not yet read.
980
- */
981
- delivered: number;
982
- /**
983
- * Read by the recipient.
984
- */
985
- read: number;
986
- /**
987
- * Not delivered; each recipient says why.
988
- */
989
- failed: number;
990
- };
991
- /**
992
- * When it starts sending; null if it was sent at once.
993
- */
994
- scheduled_at: string | null;
995
- /**
996
- * When it was canceled; null otherwise.
997
- */
998
- canceled_at: string | null;
999
- /**
1000
- * When the last message was handed to WhatsApp.
1001
- */
1002
- completed_at: string | null;
1144
+ website_url: string | null;
1003
1145
  /**
1004
- * Member who created it, or who created the API key.
1146
+ * LinkedIn profile URL.
1005
1147
  */
1006
- created_by_user_id: string;
1148
+ linkedin_url: string | null;
1007
1149
  /**
1008
- * When it was created.
1150
+ * Where the contact came from.
1009
1151
  */
1010
- created_at: string;
1011
- };
1012
- /**
1013
- * One number of a broadcast and where its message stands.
1014
- */
1015
- export type BroadcastRecipient = {
1152
+ source: string | null;
1016
1153
  /**
1017
- * Recipient ID.
1154
+ * Free-form notes.
1018
1155
  */
1019
- id: string;
1156
+ notes: string | null;
1020
1157
  /**
1021
- * Number in E.164.
1158
+ * Deprecated: contacts no longer have an owner; the member responsible is each conversation's `assigned_user_id`. Always `null`.
1159
+ *
1160
+ * @deprecated
1022
1161
  */
1023
- phone: string;
1024
- contact_id: string | null;
1162
+ owner_user_id: string | null;
1025
1163
  /**
1026
- * `pending` until WhatsApp accepts or refuses the message; then `sent`, `delivered` and `read` as WhatsApp reports them, or `failed`.
1164
+ * Sales lead status.
1027
1165
  */
1028
- status: 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
1166
+ lead_status: 'new' | 'open' | 'in_progress' | 'attempted' | 'connected' | 'unqualified' | 'bad_timing' | null;
1029
1167
  /**
1030
- * Why it failed; null unless `failed`.
1168
+ * Custom field values keyed by contact field ID. See `GET /contact-fields`.
1031
1169
  */
1032
- failure_reason: string | null;
1033
- conversation_id: string | null;
1034
- message_id: string | null;
1170
+ custom_values: {
1171
+ [key: string]: string | number | boolean | Array<string> | null;
1172
+ };
1035
1173
  /**
1036
- * When the broadcast handed the message to WhatsApp or recorded why it could not.
1174
+ * Channel identities.
1037
1175
  */
1038
- processed_at: string | null;
1176
+ identities: Array<ContactIdentity>;
1039
1177
  /**
1040
- * When WhatsApp reported the latest status of the message; null before.
1178
+ * Tags applied to the contact.
1041
1179
  */
1042
- status_updated_at: string | null;
1043
- };
1044
- /**
1045
- * How many numbers an audience resolves to now.
1046
- */
1047
- export type BroadcastAudiencePreview = {
1180
+ tags: Array<Tag>;
1048
1181
  /**
1049
- * Numbers a broadcast to this audience would go to now, at most 5,000.
1182
+ * Latest message in any of its conversations.
1050
1183
  */
1051
- recipients: number;
1184
+ last_activity_at: string | null;
1052
1185
  /**
1053
- * Contacts or numbers left out because they have no valid WhatsApp number.
1186
+ * Text of that latest message.
1054
1187
  */
1055
- skipped: number;
1056
- };
1057
- /**
1058
- * The photo of a location, which the agents can look at and send when it helps.
1059
- */
1060
- export type KnowledgeLocationPhoto = {
1188
+ last_activity_preview: string | null;
1189
+ last_conversation_id: string | null;
1061
1190
  /**
1062
- * File type.
1191
+ * First touch: the earliest Meta ad this contact came from, in any of its conversations; null when none came from an ad.
1063
1192
  */
1064
- mime_type: 'image/jpeg' | 'image/png';
1193
+ first_ad_referral: AdReferral | null;
1065
1194
  /**
1066
- * Size in bytes.
1195
+ * Last touch: the latest Meta ad this contact came from; the same as `first_ad_referral` when only one ad brought them.
1067
1196
  */
1068
- size_bytes: number;
1197
+ last_ad_referral: AdReferral | null;
1069
1198
  /**
1070
- * Signed download URL, valid for five minutes. Only `GET /knowledge/locations/{location_id}` carries it; null elsewhere.
1199
+ * Last change to the contact.
1071
1200
  */
1072
- download_url: string | null;
1201
+ updated_at: string;
1073
1202
  };
1074
1203
  /**
1075
- * A branch or place the agents can send as a WhatsApp location.
1204
+ * A custom contact field defined by the organization.
1076
1205
  */
1077
- export type KnowledgeLocation = {
1206
+ export type ContactField = {
1078
1207
  /**
1079
- * Location ID.
1208
+ * Field ID; the key in `custom_values`.
1080
1209
  */
1081
1210
  id: string;
1082
1211
  /**
1083
- * Name customers know it by.
1212
+ * Display name.
1084
1213
  */
1085
1214
  name: string;
1086
1215
  /**
1087
- * Full address as customers read it.
1216
+ * Value type: `number` takes a number, `boolean` a boolean, `date` `YYYY-MM-DD`, `select` one option, `multi_select` an array of options, the rest a string.
1088
1217
  */
1089
- address: string;
1218
+ type: 'text' | 'long_text' | 'number' | 'boolean' | 'date' | 'select' | 'multi_select';
1090
1219
  /**
1091
- * Latitude of the map pin.
1220
+ * Allowed values for `select` and `multi_select`.
1092
1221
  */
1093
- latitude: number;
1222
+ options: Array<string>;
1223
+ };
1224
+ /**
1225
+ * A connected messaging channel.
1226
+ */
1227
+ export type Channel = {
1094
1228
  /**
1095
- * Longitude of the map pin.
1229
+ * Channel ID.
1096
1230
  */
1097
- longitude: number;
1231
+ id: string;
1098
1232
  /**
1099
- * Street.
1233
+ * Messaging channel.
1100
1234
  */
1101
- street: string | null;
1235
+ type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1102
1236
  /**
1103
- * City.
1237
+ * Name shown in Ricky.
1104
1238
  */
1105
- city: string | null;
1239
+ name: string;
1106
1240
  /**
1107
- * State, province or region.
1241
+ * Phone in E.164 for WhatsApp, account or page name otherwise.
1108
1242
  */
1109
- state: string | null;
1243
+ address: string | null;
1110
1244
  /**
1111
- * Postal code.
1245
+ * WhatsApp Business Account that owns the number; templates must belong to it.
1112
1246
  */
1113
- postal_code: string | null;
1247
+ whatsapp_business_account_id: string | null;
1114
1248
  /**
1115
- * Country.
1249
+ * When it was connected.
1116
1250
  */
1117
- country: string | null;
1251
+ connected_at: string | null;
1252
+ };
1253
+ /**
1254
+ * A request for a person to take over from the AI agent, not resolved yet.
1255
+ */
1256
+ export type ConversationHandoff = {
1118
1257
  /**
1119
- * Country code, ISO 3166-1 alpha-2.
1258
+ * Handoff ID.
1120
1259
  */
1121
- country_code: string | null;
1260
+ id: string;
1122
1261
  /**
1123
- * Phone in E.164.
1262
+ * `requested` until a member takes it; `assigned` once someone is responsible.
1124
1263
  */
1125
- phone: string | null;
1264
+ status: 'requested' | 'assigned';
1126
1265
  /**
1127
- * Email.
1266
+ * Whether the AI agent or a member asked for it.
1128
1267
  */
1129
- email: string | null;
1268
+ requested_by: 'agent' | 'operator';
1130
1269
  /**
1131
- * Opening hours, as free text.
1270
+ * Why the conversation needs a person.
1132
1271
  */
1133
- hours: string | null;
1272
+ reason: 'customer_requested' | 'low_confidence' | 'manual_takeover' | 'out_of_scope' | 'sensitive' | 'other';
1134
1273
  /**
1135
- * Its photo; null when it has none.
1274
+ * What the person taking over needs to know.
1136
1275
  */
1137
- photo: KnowledgeLocationPhoto | null;
1138
- };
1139
- /**
1140
- * A location, with its current photo, and where to put the bytes of the next one.
1141
- */
1142
- export type KnowledgeLocationPhotoUpload = {
1143
- location: KnowledgeLocation;
1276
+ summary: string;
1277
+ assigned_user_id: string | null;
1144
1278
  /**
1145
- * Signed URL valid for two hours. `PUT` the photo bytes to it with `Content-Type` set to `mime_type`, then call `POST /knowledge/locations/{location_id}/photo/complete`.
1279
+ * When it was requested.
1146
1280
  */
1147
- upload_url: string;
1281
+ requested_at: string;
1148
1282
  };
1149
1283
  /**
1150
- * A contact card in the knowledge directory, which agents can send to customers.
1284
+ * One contact talking to the organization on one channel.
1151
1285
  */
1152
- export type KnowledgeContact = {
1286
+ export type Conversation = {
1153
1287
  /**
1154
- * Knowledge contact ID.
1288
+ * Conversation ID.
1155
1289
  */
1156
1290
  id: string;
1291
+ channel: {
1292
+ /**
1293
+ * Channel ID.
1294
+ */
1295
+ id: string;
1296
+ type: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1297
+ };
1298
+ contact: {
1299
+ id: string | null;
1300
+ /**
1301
+ * Name on the channel.
1302
+ */
1303
+ display_name: string | null;
1304
+ /**
1305
+ * Address on the channel.
1306
+ */
1307
+ external_id: string;
1308
+ /**
1309
+ * Handle, when the channel has one.
1310
+ */
1311
+ username: string | null;
1312
+ } | null;
1313
+ status: 'open' | 'closed';
1157
1314
  /**
1158
- * Name shown on the contact card.
1159
- */
1160
- display_name: string;
1161
- /**
1162
- * First name.
1315
+ * Why it was closed; null while open or when closed without one.
1163
1316
  */
1164
- first_name: string | null;
1317
+ close_category: 'resolved' | 'sale' | 'no_response' | 'spam' | 'other' | null;
1318
+ assigned_user_id: string | null;
1319
+ agent_id: string | null;
1165
1320
  /**
1166
- * Last name.
1321
+ * When it was created.
1167
1322
  */
1168
- last_name: string | null;
1323
+ created_at: string;
1169
1324
  /**
1170
- * Name prefix, such as `Dr.`.
1325
+ * Start of the current open span.
1171
1326
  */
1172
- prefix: string | null;
1327
+ opened_at: string;
1173
1328
  /**
1174
- * Name suffix.
1329
+ * When it was closed; null while open.
1175
1330
  */
1176
- suffix: string | null;
1331
+ closed_at: string | null;
1177
1332
  /**
1178
- * Company.
1333
+ * Latest message.
1179
1334
  */
1180
- company: string | null;
1335
+ last_activity_at: string | null;
1181
1336
  /**
1182
- * Department.
1337
+ * Text of the latest message.
1183
1338
  */
1184
- department: string | null;
1339
+ last_activity_preview: string | null;
1185
1340
  /**
1186
- * Job title.
1341
+ * Whether it has messages the team has not read.
1187
1342
  */
1188
- job_title: string | null;
1343
+ unread: boolean;
1189
1344
  /**
1190
- * When the agents should share it.
1345
+ * The handoff to a person waiting to be resolved; null when there is none.
1191
1346
  */
1192
- description: string | null;
1347
+ active_handoff: ConversationHandoff | null;
1193
1348
  /**
1194
- * Phone in E.164.
1349
+ * The earliest Meta ad that brought the contact to this conversation; null when none did.
1195
1350
  */
1196
- phone: string | null;
1351
+ first_ad_referral: AdReferral | null;
1197
1352
  /**
1198
- * `CELL`, `WORK` or `HOME`.
1353
+ * The latest Meta ad that brought the contact back to this conversation; the same as `first_ad_referral` when only one did.
1199
1354
  */
1200
- phone_type: string | null;
1201
- /**
1202
- * Email.
1203
- */
1204
- email: string | null;
1205
- /**
1206
- * `WORK` or `PERSONAL`.
1207
- */
1208
- email_type: string | null;
1355
+ latest_ad_referral: AdReferral | null;
1209
1356
  };
1210
1357
  /**
1211
- * A document or image the agents can consult or send.
1358
+ * One message in a conversation.
1212
1359
  */
1213
- export type KnowledgeFile = {
1360
+ export type Message = {
1214
1361
  /**
1215
- * File ID.
1362
+ * Message ID.
1216
1363
  */
1217
1364
  id: string;
1218
1365
  /**
1219
- * Title the agents see.
1366
+ * Conversation ID.
1220
1367
  */
1221
- title: string;
1368
+ conversation_id: string;
1369
+ direction: 'inbound' | 'outbound';
1222
1370
  /**
1223
- * When the agents should use it; may be empty.
1371
+ * Message type: `text`, `image`, `audio`, `video`, `document`, `template`, …
1224
1372
  */
1225
- description: string;
1373
+ type: string;
1226
1374
  /**
1227
- * Original file name.
1375
+ * Text, caption or rendered template body.
1228
1376
  */
1229
- filename: string;
1377
+ text: string | null;
1378
+ sender: {
1379
+ /**
1380
+ * `contact`; a `member` in Ricky; an AI `agent`; an `automation`; or `channel_app`, sent from the channel's own app outside Ricky.
1381
+ */
1382
+ type: 'contact' | 'member' | 'agent' | 'automation' | 'channel_app';
1383
+ /**
1384
+ * Member, agent or workflow name; null for the contact and `channel_app`.
1385
+ */
1386
+ name: string | null;
1387
+ };
1230
1388
  /**
1231
- * File type.
1389
+ * Provider delivery status: `sent`, `delivered`, `read`, `failed`, …
1232
1390
  */
1233
- mime_type: 'application/pdf' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'image/jpeg' | 'image/png';
1391
+ status: string;
1392
+ media: {
1393
+ /**
1394
+ * `image`, `audio`, `video`, `document` or `sticker`.
1395
+ */
1396
+ kind: string;
1397
+ /**
1398
+ * MIME type.
1399
+ */
1400
+ mime_type: string | null;
1401
+ /**
1402
+ * File name, for documents.
1403
+ */
1404
+ filename: string | null;
1405
+ byte_size: number | null;
1406
+ /**
1407
+ * Transcript of a voice note.
1408
+ */
1409
+ transcript: string | null;
1410
+ /**
1411
+ * Signed download URL, valid for one hour; null until downloaded.
1412
+ */
1413
+ url: string | null;
1414
+ } | null;
1234
1415
  /**
1235
- * Size in bytes.
1416
+ * Message ID at the provider.
1236
1417
  */
1237
- size_bytes: number;
1418
+ provider_message_id: string | null;
1238
1419
  /**
1239
- * `uploading` until `POST /knowledge/files/{file_id}/complete` reads it; then `ready`, also when Ricky could not read useful content, which `extraction_error` then says. Ricky does not set `failed` today.
1420
+ * When Ricky recorded it.
1240
1421
  */
1241
- status: 'uploading' | 'ready' | 'failed';
1422
+ created_at: string;
1242
1423
  /**
1243
- * Agents may read it to answer.
1424
+ * When the provider accepted it.
1244
1425
  */
1245
- consult_enabled: boolean;
1426
+ sent_at: string | null;
1246
1427
  /**
1247
- * Agents may send the file itself to customers.
1428
+ * When it reached the device.
1248
1429
  */
1249
- send_enabled: boolean;
1430
+ delivered_at: string | null;
1250
1431
  /**
1251
- * Pages of a PDF; null otherwise.
1432
+ * When the recipient read it.
1252
1433
  */
1253
- page_count: number | null;
1434
+ read_at: string | null;
1254
1435
  /**
1255
- * Why Ricky could not read useful content; null when it could.
1436
+ * When delivery failed.
1256
1437
  */
1257
- extraction_error: string | null;
1438
+ failed_at: string | null;
1258
1439
  /**
1259
- * Signed download URL, valid for five minutes. Only `GET /knowledge/files/{file_id}` of a `ready` file carries it; null elsewhere.
1440
+ * When the sender edited it.
1260
1441
  */
1261
- download_url: string | null;
1442
+ edited_at: string | null;
1262
1443
  /**
1263
- * When the upload began.
1444
+ * When the sender deleted it.
1264
1445
  */
1265
- created_at: string;
1446
+ deleted_at: string | null;
1266
1447
  /**
1267
- * Last change.
1448
+ * The Meta ad this customer message came from; null for every other message.
1268
1449
  */
1269
- updated_at: string;
1450
+ ad_referral: AdReferral | null;
1270
1451
  };
1271
1452
  /**
1272
- * Everything Ricky read from a file, what the agents consult to answer.
1453
+ * An outbound message Ricky accepted and is delivering.
1273
1454
  */
1274
- export type KnowledgeFileReading = {
1275
- /**
1276
- * File ID.
1277
- */
1278
- file_id: string;
1455
+ export type Send = {
1279
1456
  /**
1280
- * In page order. Empty when Ricky read no useful content (`extraction_error`).
1457
+ * Send ID. Poll `GET /sends/{send_id}` with it.
1281
1458
  */
1282
- sections: Array<{
1283
- /**
1284
- * PDF page it was read from; null for formats without pages.
1285
- */
1286
- page: number | null;
1287
- /**
1288
- * Everything Ricky read from that page, in Markdown: text in reading order, tables, and one line per picture saying what it shows.
1289
- */
1290
- text: string;
1291
- }>;
1292
- };
1293
- /**
1294
- * A file waiting for its bytes, and where to put them.
1295
- */
1296
- export type KnowledgeFileUpload = {
1297
- file: KnowledgeFile;
1459
+ id: string;
1298
1460
  /**
1299
- * Signed URL valid for two hours. `PUT` the file bytes to it with `Content-Type` set to `mime_type`, then call `POST /knowledge/files/{file_id}/complete`.
1461
+ * Conversation the message goes to.
1300
1462
  */
1301
- upload_url: string;
1302
- };
1303
- /**
1304
- * A webhook subscription.
1305
- */
1306
- export type Webhook = {
1463
+ conversation_id: string;
1307
1464
  /**
1308
- * Webhook ID.
1465
+ * `sent` once the provider accepted the message; `failed` for good, with the reason; `queued` otherwise, while Ricky retries.
1309
1466
  */
1310
- id: string;
1467
+ status: 'queued' | 'sent' | 'failed';
1468
+ message_id: string | null;
1311
1469
  /**
1312
- * HTTPS endpoint Ricky posts to.
1470
+ * Why it failed; null unless `failed`.
1313
1471
  */
1314
- url: string;
1315
- event_types: Array<'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready'>;
1316
- status: 'active' | 'disabled';
1472
+ failure_reason: string | null;
1317
1473
  /**
1318
- * When it was created.
1474
+ * When Ricky accepted it.
1319
1475
  */
1320
1476
  created_at: string;
1321
- /**
1322
- * When it was disabled.
1323
- */
1324
- disabled_at: string | null;
1325
1477
  };
1326
1478
  /**
1327
- * A new webhook subscription with its signing secret.
1479
+ * A person in the organization.
1328
1480
  */
1329
- export type CreatedWebhook = {
1481
+ export type Member = {
1330
1482
  /**
1331
- * Webhook ID.
1483
+ * User ID.
1332
1484
  */
1333
1485
  id: string;
1334
1486
  /**
1335
- * HTTPS endpoint Ricky posts to.
1336
- */
1337
- url: string;
1338
- event_types: Array<'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready'>;
1339
- status: 'active' | 'disabled';
1340
- /**
1341
- * When it was created.
1342
- */
1343
- created_at: string;
1344
- /**
1345
- * When it was disabled.
1487
+ * Full name.
1346
1488
  */
1347
- disabled_at: string | null;
1489
+ name: string | null;
1348
1490
  /**
1349
- * HMAC key for `X-Ricky-Signature`. Returned only here, once.
1491
+ * Email.
1350
1492
  */
1351
- signing_secret: string;
1493
+ email: string;
1494
+ role: 'owner' | 'admin' | 'member';
1352
1495
  };
1353
1496
  /**
1354
- * One webhook delivery.
1497
+ * A WhatsApp message template.
1355
1498
  */
1356
- export type WebhookDelivery = {
1499
+ export type Template = {
1357
1500
  /**
1358
- * Delivery ID; equals the event `id` and `X-Ricky-Delivery-Id`.
1501
+ * Template ID at Meta.
1359
1502
  */
1360
1503
  id: string;
1361
- event_type: 'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready';
1362
- status: 'pending' | 'processing' | 'delivered' | 'failed';
1363
1504
  /**
1364
- * Delivery attempts so far; Ricky makes at most ten.
1505
+ * Template name.
1365
1506
  */
1366
- attempts: number;
1507
+ name: string;
1367
1508
  /**
1368
- * HTTP status of the last attempt.
1509
+ * Language code, for example `es` or `en_US`.
1369
1510
  */
1370
- last_response_status: number | null;
1511
+ language: string;
1371
1512
  /**
1372
- * Why the last attempt failed.
1513
+ * `MARKETING`, `UTILITY` or `AUTHENTICATION`.
1373
1514
  */
1374
- last_error: string | null;
1515
+ category: string;
1375
1516
  /**
1376
- * When the event happened.
1517
+ * Meta review status. Only `APPROVED` templates can be sent.
1377
1518
  */
1378
- created_at: string;
1519
+ status: string;
1379
1520
  /**
1380
- * When Ricky tries next, while pending.
1521
+ * Account that owns it.
1381
1522
  */
1382
- next_attempt_at: string;
1523
+ whatsapp_business_account_id: string;
1383
1524
  /**
1384
- * When the endpoint answered 2xx.
1525
+ * How variables are named: `{{1}}` or `{{name}}`.
1385
1526
  */
1386
- delivered_at: string | null;
1527
+ parameter_format: 'POSITIONAL' | 'NAMED' | null;
1528
+ /**
1529
+ * Header, body, footer and buttons, in the WhatsApp Cloud API format.
1530
+ */
1531
+ components: Array<{
1532
+ [key: string]: unknown;
1533
+ }>;
1387
1534
  };
1388
1535
  /**
1389
- * The JSON body Ricky posts to a webhook endpoint.
1536
+ * One approved WhatsApp template sent to many numbers.
1390
1537
  */
1391
- export type WebhookEvent = {
1538
+ export type Broadcast = {
1392
1539
  /**
1393
- * Delivery ID. Deduplicate by it.
1540
+ * Broadcast ID.
1394
1541
  */
1395
1542
  id: string;
1396
- type: 'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready' | 'webhook.test';
1397
1543
  /**
1398
- * When it happened.
1544
+ * WhatsApp channel it is sent from.
1399
1545
  */
1400
- occurred_at: string;
1546
+ channel_id: string;
1401
1547
  /**
1402
- * Organization.
1548
+ * The approved template every recipient receives.
1403
1549
  */
1404
- organization_id: string;
1405
- data: {
1406
- /**
1407
- * Conversation, for `message.*` and `conversation.*` events.
1408
- */
1409
- conversation_id?: string;
1550
+ template: {
1410
1551
  /**
1411
- * Message, for `message.*` events.
1552
+ * Template ID at Meta.
1412
1553
  */
1413
- message_id?: string;
1554
+ id: string;
1414
1555
  /**
1415
- * Contact, for `contact.*` events.
1556
+ * Template name.
1416
1557
  */
1417
- contact_id?: string;
1558
+ name: string;
1418
1559
  /**
1419
- * Broadcast, for `broadcast.*` events.
1560
+ * Language code.
1420
1561
  */
1421
- broadcast_id?: string;
1562
+ language: string;
1563
+ };
1564
+ /**
1565
+ * How the recipient list was built: a contact filter, chosen contacts, or phone numbers. The list itself is fixed when the broadcast is created.
1566
+ */
1567
+ audience: {
1568
+ type: 'filter';
1569
+ tag_id: string | null;
1422
1570
  /**
1423
- * Template ID at Meta, for `template.status_changed`.
1571
+ * Only contacts whose name, phone, email or company contains it.
1424
1572
  */
1425
- template_id?: string;
1573
+ query: string | null;
1574
+ } | {
1575
+ type: 'contacts';
1576
+ } | {
1577
+ type: 'phones';
1578
+ };
1579
+ /**
1580
+ * `scheduled` waits for `scheduled_at`; `queued` and `sending` are on their way; `completed` once every message was handed to WhatsApp; `canceled` before it started.
1581
+ */
1582
+ status: 'scheduled' | 'queued' | 'sending' | 'completed' | 'canceled';
1583
+ /**
1584
+ * Recipients in each delivery status. Each recipient counts once, in its current one.
1585
+ */
1586
+ counts: {
1426
1587
  /**
1427
- * Workflow, for `workflow.execution_failed`.
1588
+ * Numbers the broadcast goes to.
1428
1589
  */
1429
- workflow_id?: string;
1590
+ recipients: number;
1430
1591
  /**
1431
- * Execution, for `workflow.execution_failed`.
1592
+ * Not sent yet, or WhatsApp has not answered yet.
1432
1593
  */
1433
- workflow_execution_id?: string;
1594
+ pending: number;
1434
1595
  /**
1435
- * Knowledge file, for `knowledge_file.ready`.
1596
+ * Accepted by WhatsApp, not yet delivered.
1436
1597
  */
1437
- knowledge_file_id?: string;
1598
+ sent: number;
1438
1599
  /**
1439
- * Webhook, for `webhook.test`.
1600
+ * Delivered to the phone, not yet read.
1440
1601
  */
1441
- webhook_id?: string;
1602
+ delivered: number;
1603
+ /**
1604
+ * Read by the recipient.
1605
+ */
1606
+ read: number;
1607
+ /**
1608
+ * Not delivered; each recipient says why.
1609
+ */
1610
+ failed: number;
1442
1611
  };
1443
- };
1444
- /**
1445
- * What the endpoint answered to a `webhook.test` event.
1446
- */
1447
- export type WebhookTestResult = {
1448
1612
  /**
1449
- * True when the endpoint answered 2xx.
1613
+ * When it starts sending; null if it was sent at once.
1450
1614
  */
1451
- delivered: boolean;
1615
+ scheduled_at: string | null;
1452
1616
  /**
1453
- * HTTP status the endpoint answered; null if none.
1617
+ * When it was canceled; null otherwise.
1454
1618
  */
1455
- response_status: number | null;
1619
+ canceled_at: string | null;
1456
1620
  /**
1457
- * Why it failed: the HTTP status, a timeout or a refused destination.
1621
+ * When the last message was handed to WhatsApp.
1458
1622
  */
1459
- error: string | null;
1623
+ completed_at: string | null;
1460
1624
  /**
1461
- * Time until the endpoint answered.
1625
+ * Member who created it, or who created the API key.
1462
1626
  */
1463
- duration_ms: number;
1627
+ created_by_user_id: string;
1628
+ /**
1629
+ * When it was created.
1630
+ */
1631
+ created_at: string;
1464
1632
  };
1465
1633
  /**
1466
- * What a tag change did to one contact.
1634
+ * One number of a broadcast and where its message stands.
1467
1635
  */
1468
- export type ContactTagChange = {
1636
+ export type BroadcastRecipient = {
1469
1637
  /**
1470
- * Contact ID.
1638
+ * Recipient ID.
1471
1639
  */
1472
- contact_id: string;
1640
+ id: string;
1473
1641
  /**
1474
- * `updated`; `not_found` when the organization has no such contact; `failed` when Ricky could not save it, so retry that contact.
1642
+ * Number in E.164.
1475
1643
  */
1476
- status: 'updated' | 'not_found' | 'failed';
1644
+ phone: string;
1645
+ contact_id: string | null;
1477
1646
  /**
1478
- * The contact's tags after the change; null unless `updated`.
1647
+ * `pending` until WhatsApp accepts or refuses the message; then `sent`, `delivered` and `read` as WhatsApp reports them, or `failed`.
1479
1648
  */
1480
- tags: Array<Tag> | null;
1649
+ status: 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
1650
+ /**
1651
+ * Why it failed; null unless `failed`.
1652
+ */
1653
+ failure_reason: string | null;
1654
+ conversation_id: string | null;
1655
+ message_id: string | null;
1656
+ /**
1657
+ * When the broadcast handed the message to WhatsApp or recorded why it could not.
1658
+ */
1659
+ processed_at: string | null;
1660
+ /**
1661
+ * When WhatsApp reported the latest status of the message; null before.
1662
+ */
1663
+ status_updated_at: string | null;
1481
1664
  };
1482
1665
  /**
1483
- * A message whose text matches the search.
1666
+ * How many numbers an audience resolves to now.
1484
1667
  */
1485
- export type MessageSearchResult = {
1486
- /**
1487
- * Message ID.
1488
- */
1489
- message_id: string;
1668
+ export type BroadcastAudiencePreview = {
1490
1669
  /**
1491
- * Conversation ID.
1670
+ * Numbers a broadcast to this audience would go to now, at most 5,000.
1492
1671
  */
1493
- conversation_id: string;
1494
- direction: 'inbound' | 'outbound';
1672
+ recipients: number;
1495
1673
  /**
1496
- * Message type: `text`, `image`, `audio`, `template`, …
1674
+ * Contacts or numbers left out because they have no valid WhatsApp number.
1497
1675
  */
1498
- type: string;
1676
+ skipped: number;
1677
+ };
1678
+ /**
1679
+ * The photo of a location, which the agents can look at and send when it helps.
1680
+ */
1681
+ export type KnowledgeLocationPhoto = {
1499
1682
  /**
1500
- * The matching text: the message, or what Ricky derived from a voice note or file.
1683
+ * File type.
1501
1684
  */
1502
- text: string;
1503
- contact: {
1504
- /**
1505
- * Contact name, or the name on the channel.
1506
- */
1507
- name: string | null;
1508
- /**
1509
- * Address on the channel.
1510
- */
1511
- external_id: string;
1512
- };
1685
+ mime_type: 'image/jpeg' | 'image/png';
1513
1686
  /**
1514
- * AI agent that wrote it; null otherwise.
1687
+ * Size in bytes.
1515
1688
  */
1516
- agent_name: string | null;
1689
+ size_bytes: number;
1517
1690
  /**
1518
- * When it was sent or received.
1691
+ * Signed download URL, valid for five minutes. Only `GET /knowledge/locations/{location_id}` carries it; null elsewhere.
1519
1692
  */
1520
- messaged_at: string;
1693
+ download_url: string | null;
1521
1694
  };
1522
1695
  /**
1523
- * A saved answer operators insert into a message.
1696
+ * A branch or place the agents can send as a WhatsApp location.
1524
1697
  */
1525
- export type QuickReply = {
1698
+ export type KnowledgeLocation = {
1526
1699
  /**
1527
- * Quick reply ID.
1700
+ * Location ID.
1528
1701
  */
1529
1702
  id: string;
1530
1703
  /**
1531
- * Name operators pick it by, unique in the organization regardless of case.
1704
+ * Name customers know it by.
1532
1705
  */
1533
- title: string;
1706
+ name: string;
1534
1707
  /**
1535
- * Text inserted into the message.
1708
+ * Full address as customers read it.
1536
1709
  */
1537
- body: string;
1538
- };
1539
- /**
1540
- * What a bulk assignment did to one conversation.
1541
- */
1542
- export type ConversationAssignmentResult = {
1710
+ address: string;
1543
1711
  /**
1544
- * Conversation ID.
1712
+ * Latitude of the map pin.
1545
1713
  */
1546
- conversation_id: string;
1714
+ latitude: number;
1547
1715
  /**
1548
- * Member it was to be assigned to.
1716
+ * Longitude of the map pin.
1549
1717
  */
1550
- assigned_user_id: string;
1718
+ longitude: number;
1551
1719
  /**
1552
- * `assigned`; `not_found` when the organization has no such conversation; `failed` when Ricky could not save it, so retry that conversation.
1720
+ * Street.
1553
1721
  */
1554
- status: 'assigned' | 'not_found' | 'failed';
1555
- };
1556
- /**
1557
- * The days a report covers, in America/Panama time, and the period it is compared with.
1558
- */
1559
- export type ReportPeriod = {
1722
+ street: string | null;
1560
1723
  /**
1561
- * First day, inclusive.
1724
+ * City.
1562
1725
  */
1563
- from: string;
1726
+ city: string | null;
1564
1727
  /**
1565
- * Last day, inclusive. A `to` after today is today.
1728
+ * State, province or region.
1566
1729
  */
1567
- to: string;
1730
+ state: string | null;
1568
1731
  /**
1569
- * Days in the period.
1732
+ * Postal code.
1570
1733
  */
1571
- days: number;
1734
+ postal_code: string | null;
1572
1735
  /**
1573
- * `hour` when the period is one day: series then have 24 hourly slots.
1736
+ * Country.
1574
1737
  */
1575
- granularity: 'day' | 'hour';
1738
+ country: string | null;
1576
1739
  /**
1577
- * The time zone of every day and hour in the report.
1740
+ * Country code, ISO 3166-1 alpha-2.
1578
1741
  */
1579
- time_zone: 'America/Panama';
1742
+ country_code: string | null;
1580
1743
  /**
1581
- * First day of the previous period: the same number of days, right before.
1744
+ * Phone in E.164.
1582
1745
  */
1583
- previous_from: string;
1746
+ phone: string | null;
1584
1747
  /**
1585
- * Last day of the previous period.
1748
+ * Email.
1586
1749
  */
1587
- previous_to: string;
1750
+ email: string | null;
1751
+ /**
1752
+ * Opening hours, as free text.
1753
+ */
1754
+ hours: string | null;
1755
+ /**
1756
+ * Its photo; null when it has none.
1757
+ */
1758
+ photo: KnowledgeLocationPhoto | null;
1588
1759
  };
1589
1760
  /**
1590
- * How many customers write, whether they are new, and when. Only messages customers send count: a customer is a conversation with at least one of them in the period, and it is new when its first message ever falls in the period. Messages from the team, AI agents or campaigns and conversation openings and closes play no part.
1761
+ * A location, with its current photo, and where to put the bytes of the next one.
1591
1762
  */
1592
- export type ConversationsReport = {
1593
- period: ReportPeriod;
1763
+ export type KnowledgeLocationPhotoUpload = {
1764
+ location: KnowledgeLocation;
1594
1765
  /**
1595
- * The channel filter the report applied.
1766
+ * Signed URL valid for two hours. `PUT` the photo bytes to it with `Content-Type` set to `mime_type`, then call `POST /knowledge/locations/{location_id}/photo/complete`.
1596
1767
  */
1597
- channel: 'all' | 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1768
+ upload_url: string;
1769
+ };
1770
+ /**
1771
+ * A contact card in the knowledge directory, which agents can send to customers.
1772
+ */
1773
+ export type KnowledgeContact = {
1598
1774
  /**
1599
- * The period.
1775
+ * Knowledge contact ID.
1600
1776
  */
1601
- totals: {
1602
- /**
1603
- * Conversations with at least one customer message in the period.
1604
- */
1605
- customers: number;
1606
- /**
1607
- * Customers whose first message ever falls in the period.
1608
- */
1609
- new_customers: number;
1610
- /**
1611
- * Customers who had written before the period.
1612
- */
1613
- returning_customers: number;
1614
- /**
1615
- * Messages customers sent in the period.
1616
- */
1617
- messages: number;
1618
- };
1777
+ id: string;
1619
1778
  /**
1620
- * The previous period.
1779
+ * Name shown on the contact card.
1621
1780
  */
1622
- previous: {
1623
- /**
1624
- * Conversations with at least one customer message in the period.
1625
- */
1626
- customers: number;
1627
- /**
1628
- * Customers whose first message ever falls in the period.
1629
- */
1630
- new_customers: number;
1631
- /**
1632
- * Customers who had written before the period.
1633
- */
1634
- returning_customers: number;
1635
- /**
1636
- * Messages customers sent in the period.
1637
- */
1638
- messages: number;
1639
- };
1781
+ display_name: string;
1640
1782
  /**
1641
- * The period per channel, most customers first.
1783
+ * First name.
1642
1784
  */
1643
- by_channel: Array<{
1644
- /**
1645
- * Channel.
1646
- */
1647
- channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1648
- /**
1649
- * Conversations with at least one customer message in the period.
1650
- */
1651
- customers: number;
1652
- /**
1653
- * Customers whose first message ever falls in the period.
1654
- */
1655
- new_customers: number;
1656
- /**
1657
- * Customers who had written before the period.
1658
- */
1659
- returning_customers: number;
1660
- /**
1661
- * Messages customers sent in the period.
1662
- */
1663
- messages: number;
1664
- }>;
1785
+ first_name: string | null;
1665
1786
  /**
1666
- * One entry per day of the period, or per hour of a one-day period.
1787
+ * Last name.
1667
1788
  */
1668
- series: Array<{
1669
- /**
1670
- * America/Panama day `YYYY-MM-DD`, or hour `YYYY-MM-DDTHH` when the period is one day.
1671
- */
1672
- slot: string;
1673
- /**
1674
- * Customers whose first message ever falls in this slot.
1675
- */
1676
- new_customers: number;
1677
- /**
1678
- * Customers who wrote in this slot and had written before.
1679
- */
1680
- returning_customers: number;
1681
- previous_customers: number | null;
1682
- }>;
1789
+ last_name: string | null;
1683
1790
  /**
1684
- * Customer messages of the period per weekday and hour; slots without any are left out.
1791
+ * Name prefix, such as `Dr.`.
1685
1792
  */
1686
- heatmap: Array<{
1687
- /**
1688
- * 0 is Sunday, 6 is Saturday.
1689
- */
1690
- day_of_week: number;
1691
- /**
1692
- * Hour of the day, 0–23.
1693
- */
1694
- hour: number;
1695
- /**
1696
- * Customer messages in that hour of that weekday.
1697
- */
1698
- messages: number;
1699
- }>;
1793
+ prefix: string | null;
1700
1794
  /**
1701
- * When Ricky computed the report.
1795
+ * Name suffix.
1702
1796
  */
1703
- generated_at: string;
1797
+ suffix: string | null;
1798
+ /**
1799
+ * Company.
1800
+ */
1801
+ company: string | null;
1802
+ /**
1803
+ * Department.
1804
+ */
1805
+ department: string | null;
1806
+ /**
1807
+ * Job title.
1808
+ */
1809
+ job_title: string | null;
1810
+ /**
1811
+ * When the agents should share it.
1812
+ */
1813
+ description: string | null;
1814
+ /**
1815
+ * Phone in E.164.
1816
+ */
1817
+ phone: string | null;
1818
+ /**
1819
+ * `CELL`, `WORK` or `HOME`.
1820
+ */
1821
+ phone_type: string | null;
1822
+ /**
1823
+ * Email.
1824
+ */
1825
+ email: string | null;
1826
+ /**
1827
+ * `WORK` or `PERSONAL`.
1828
+ */
1829
+ email_type: string | null;
1704
1830
  };
1705
1831
  /**
1706
- * Messages received from customers and sent to them in the period, and who sent them, dated when each message was sent.
1832
+ * A document or image the agents can consult or send.
1707
1833
  */
1708
- export type MessagesReport = {
1709
- period: ReportPeriod;
1834
+ export type KnowledgeFile = {
1710
1835
  /**
1711
- * The channel filter the report applied.
1836
+ * File ID.
1712
1837
  */
1713
- channel: 'all' | 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1838
+ id: string;
1714
1839
  /**
1715
- * The period.
1840
+ * Title the agents see.
1716
1841
  */
1717
- totals: {
1718
- /**
1719
- * Messages customers sent.
1720
- */
1721
- received: number;
1722
- /**
1723
- * Messages sent to customers, by anyone; the sum of `sent_by`.
1724
- */
1725
- sent: number;
1726
- /**
1727
- * Sent messages by sender; each message counts in one of them.
1728
- */
1729
- sent_by: {
1730
- /**
1731
- * Sent by a person in Ricky.
1732
- */
1733
- human: number;
1734
- /**
1735
- * Sent by an AI agent.
1736
- */
1737
- ai: number;
1738
- /**
1739
- * Sent by an automation.
1740
- */
1741
- automation: number;
1742
- /**
1743
- * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
1744
- */
1745
- campaign: number;
1746
- /**
1747
- * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
1748
- */
1749
- external: number;
1750
- };
1751
- };
1842
+ title: string;
1752
1843
  /**
1753
- * The previous period.
1844
+ * When the agents should use it; may be empty.
1754
1845
  */
1755
- previous: {
1756
- /**
1757
- * Messages customers sent.
1758
- */
1759
- received: number;
1760
- /**
1761
- * Messages sent to customers, by anyone; the sum of `sent_by`.
1762
- */
1763
- sent: number;
1764
- /**
1765
- * Sent messages by sender; each message counts in one of them.
1766
- */
1767
- sent_by: {
1768
- /**
1769
- * Sent by a person in Ricky.
1770
- */
1771
- human: number;
1772
- /**
1773
- * Sent by an AI agent.
1774
- */
1775
- ai: number;
1776
- /**
1777
- * Sent by an automation.
1778
- */
1779
- automation: number;
1780
- /**
1781
- * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
1782
- */
1783
- campaign: number;
1784
- /**
1785
- * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
1786
- */
1787
- external: number;
1788
- };
1789
- };
1846
+ description: string;
1790
1847
  /**
1791
- * The period per channel, most messages first.
1848
+ * Original file name.
1792
1849
  */
1793
- by_channel: Array<{
1794
- /**
1795
- * Channel.
1796
- */
1797
- channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1798
- /**
1799
- * Messages customers sent.
1800
- */
1801
- received: number;
1850
+ filename: string;
1851
+ /**
1852
+ * File type.
1853
+ */
1854
+ mime_type: 'application/pdf' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'image/jpeg' | 'image/png';
1855
+ /**
1856
+ * Size in bytes.
1857
+ */
1858
+ size_bytes: number;
1859
+ /**
1860
+ * `uploading` until `POST /knowledge/files/{file_id}/complete` reads it; then `ready`, also when Ricky could not read useful content, which `extraction_error` then says. Ricky does not set `failed` today.
1861
+ */
1862
+ status: 'uploading' | 'ready' | 'failed';
1863
+ /**
1864
+ * Agents may read it to answer.
1865
+ */
1866
+ consult_enabled: boolean;
1867
+ /**
1868
+ * Agents may send the file itself to customers.
1869
+ */
1870
+ send_enabled: boolean;
1871
+ /**
1872
+ * Pages of a PDF; null otherwise.
1873
+ */
1874
+ page_count: number | null;
1875
+ /**
1876
+ * Why Ricky could not read useful content; null when it could.
1877
+ */
1878
+ extraction_error: string | null;
1879
+ /**
1880
+ * Signed download URL, valid for five minutes. Only `GET /knowledge/files/{file_id}` of a `ready` file carries it; null elsewhere.
1881
+ */
1882
+ download_url: string | null;
1883
+ /**
1884
+ * When the upload began.
1885
+ */
1886
+ created_at: string;
1887
+ /**
1888
+ * Last change.
1889
+ */
1890
+ updated_at: string;
1891
+ };
1892
+ /**
1893
+ * Everything Ricky read from a file, what the agents consult to answer.
1894
+ */
1895
+ export type KnowledgeFileReading = {
1896
+ /**
1897
+ * File ID.
1898
+ */
1899
+ file_id: string;
1900
+ /**
1901
+ * In page order. Empty when Ricky read no useful content (`extraction_error`).
1902
+ */
1903
+ sections: Array<{
1802
1904
  /**
1803
- * Messages sent to customers, by anyone; the sum of `sent_by`.
1905
+ * PDF page it was read from; null for formats without pages.
1804
1906
  */
1805
- sent: number;
1907
+ page: number | null;
1806
1908
  /**
1807
- * Sent messages by sender; each message counts in one of them.
1909
+ * Everything Ricky read from that page, in Markdown: text in reading order, tables, and one line per picture saying what it shows.
1808
1910
  */
1809
- sent_by: {
1810
- /**
1811
- * Sent by a person in Ricky.
1812
- */
1813
- human: number;
1814
- /**
1815
- * Sent by an AI agent.
1816
- */
1817
- ai: number;
1818
- /**
1819
- * Sent by an automation.
1820
- */
1821
- automation: number;
1822
- /**
1823
- * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
1824
- */
1825
- campaign: number;
1826
- /**
1827
- * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
1828
- */
1829
- external: number;
1830
- };
1911
+ text: string;
1831
1912
  }>;
1913
+ };
1914
+ /**
1915
+ * A file waiting for its bytes, and where to put them.
1916
+ */
1917
+ export type KnowledgeFileUpload = {
1918
+ file: KnowledgeFile;
1919
+ /**
1920
+ * Signed URL valid for two hours. `PUT` the file bytes to it with `Content-Type` set to `mime_type`, then call `POST /knowledge/files/{file_id}/complete`.
1921
+ */
1922
+ upload_url: string;
1923
+ };
1924
+ /**
1925
+ * A webhook subscription.
1926
+ */
1927
+ export type Webhook = {
1928
+ /**
1929
+ * Webhook ID.
1930
+ */
1931
+ id: string;
1932
+ /**
1933
+ * HTTPS endpoint Ricky posts to.
1934
+ */
1935
+ url: string;
1936
+ event_types: Array<'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready'>;
1937
+ status: 'active' | 'disabled';
1938
+ /**
1939
+ * When it was created.
1940
+ */
1941
+ created_at: string;
1942
+ /**
1943
+ * When it was disabled.
1944
+ */
1945
+ disabled_at: string | null;
1946
+ };
1947
+ /**
1948
+ * A new webhook subscription with its signing secret.
1949
+ */
1950
+ export type CreatedWebhook = {
1951
+ /**
1952
+ * Webhook ID.
1953
+ */
1954
+ id: string;
1955
+ /**
1956
+ * HTTPS endpoint Ricky posts to.
1957
+ */
1958
+ url: string;
1959
+ event_types: Array<'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready'>;
1960
+ status: 'active' | 'disabled';
1961
+ /**
1962
+ * When it was created.
1963
+ */
1964
+ created_at: string;
1965
+ /**
1966
+ * When it was disabled.
1967
+ */
1968
+ disabled_at: string | null;
1969
+ /**
1970
+ * HMAC key for `X-Ricky-Signature`. Returned only here, once.
1971
+ */
1972
+ signing_secret: string;
1973
+ };
1974
+ /**
1975
+ * One webhook delivery.
1976
+ */
1977
+ export type WebhookDelivery = {
1978
+ /**
1979
+ * Delivery ID; equals the event `id` and `X-Ricky-Delivery-Id`.
1980
+ */
1981
+ id: string;
1982
+ event_type: 'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready';
1983
+ status: 'pending' | 'processing' | 'delivered' | 'failed';
1832
1984
  /**
1833
- * One entry per day of the period, or per hour of a one-day period.
1985
+ * Delivery attempts so far; Ricky makes at most ten.
1834
1986
  */
1835
- series: Array<{
1836
- /**
1837
- * America/Panama day `YYYY-MM-DD`, or hour `YYYY-MM-DDTHH` when the period is one day.
1838
- */
1839
- slot: string;
1840
- /**
1841
- * Messages customers sent.
1842
- */
1843
- received: number;
1844
- /**
1845
- * Messages sent to customers, by anyone; the sum of `sent_by`.
1846
- */
1847
- sent: number;
1848
- /**
1849
- * Sent messages by sender; each message counts in one of them.
1850
- */
1851
- sent_by: {
1852
- /**
1853
- * Sent by a person in Ricky.
1854
- */
1855
- human: number;
1856
- /**
1857
- * Sent by an AI agent.
1858
- */
1859
- ai: number;
1860
- /**
1861
- * Sent by an automation.
1862
- */
1863
- automation: number;
1864
- /**
1865
- * Templates not sent by an automation: broadcasts and templates sent by hand or through the API.
1866
- */
1867
- campaign: number;
1868
- /**
1869
- * Sent from the channel's own app, with no sender in Ricky: WhatsApp Business app coexistence and imported history.
1870
- */
1871
- external: number;
1872
- };
1873
- previous_received: number | null;
1874
- previous_sent: number | null;
1875
- }>;
1987
+ attempts: number;
1876
1988
  /**
1877
- * When Ricky computed the report.
1989
+ * HTTP status of the last attempt.
1878
1990
  */
1879
- generated_at: string;
1991
+ last_response_status: number | null;
1992
+ /**
1993
+ * Why the last attempt failed.
1994
+ */
1995
+ last_error: string | null;
1996
+ /**
1997
+ * When the event happened.
1998
+ */
1999
+ created_at: string;
2000
+ /**
2001
+ * When Ricky tries next, while pending.
2002
+ */
2003
+ next_attempt_at: string;
2004
+ /**
2005
+ * When the endpoint answered 2xx.
2006
+ */
2007
+ delivered_at: string | null;
1880
2008
  };
1881
2009
  /**
1882
- * What the inbox looks like right now; it has no period.
2010
+ * The JSON body Ricky posts to a webhook endpoint.
1883
2011
  */
1884
- export type DashboardReport = {
2012
+ export type WebhookEvent = {
1885
2013
  /**
1886
- * Now.
2014
+ * Delivery ID. Deduplicate by it.
1887
2015
  */
1888
- totals: {
2016
+ id: string;
2017
+ type: 'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready' | 'webhook.test';
2018
+ /**
2019
+ * When it happened.
2020
+ */
2021
+ occurred_at: string;
2022
+ /**
2023
+ * Organization.
2024
+ */
2025
+ organization_id: string;
2026
+ data: {
1889
2027
  /**
1890
- * Open conversations.
2028
+ * Conversation, for `message.*` and `conversation.*` events.
1891
2029
  */
1892
- open_now: number;
2030
+ conversation_id?: string;
1893
2031
  /**
1894
- * Open conversations with no member or AI agent assigned.
2032
+ * Message, for `message.*` events.
1895
2033
  */
1896
- unassigned: number;
2034
+ message_id?: string;
1897
2035
  /**
1898
- * Open conversations whose last message, reactions aside, is from the customer.
2036
+ * Meta's ID of the ad the customer came from, for a `message.received` whose message carries an ad referral. Read the message for the rest of the referral.
1899
2037
  */
1900
- awaiting_reply: number;
2038
+ ad_id?: string;
1901
2039
  /**
1902
- * Handoffs from an AI agent to a person still waiting.
2040
+ * Contact, for `contact.*` events.
1903
2041
  */
1904
- pending_handoffs: number;
2042
+ contact_id?: string;
1905
2043
  /**
1906
- * Conversations opened or reopened today, America/Panama.
2044
+ * Broadcast, for `broadcast.*` events.
1907
2045
  */
1908
- opened_today: number;
2046
+ broadcast_id?: string;
1909
2047
  /**
1910
- * Conversations closed today, America/Panama.
2048
+ * Template ID at Meta, for `template.status_changed`.
1911
2049
  */
1912
- closed_today: number;
1913
- };
1914
- /**
1915
- * Open conversations per channel, most first.
1916
- */
1917
- by_channel: Array<{
2050
+ template_id?: string;
1918
2051
  /**
1919
- * Channel.
2052
+ * Workflow, for `workflow.execution_failed`.
1920
2053
  */
1921
- channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
2054
+ workflow_id?: string;
1922
2055
  /**
1923
- * Open conversations.
2056
+ * Execution, for `workflow.execution_failed`.
1924
2057
  */
1925
- open: number;
1926
- }>;
1927
- /**
1928
- * Open conversations per assignee, most first.
1929
- */
1930
- assignees: Array<{
2058
+ workflow_execution_id?: string;
1931
2059
  /**
1932
- * `human` is a member, `ai` an AI agent, `unassigned` nobody.
2060
+ * Knowledge file, for `knowledge_file.ready`.
1933
2061
  */
1934
- type: 'human' | 'ai' | 'unassigned';
2062
+ knowledge_file_id?: string;
1935
2063
  /**
1936
- * User ID or AI agent ID; null for `unassigned`.
2064
+ * Webhook, for `webhook.test`.
1937
2065
  */
1938
- id: string | null;
2066
+ webhook_id?: string;
2067
+ };
2068
+ };
2069
+ /**
2070
+ * What the endpoint answered to a `webhook.test` event.
2071
+ */
2072
+ export type WebhookTestResult = {
2073
+ /**
2074
+ * True when the endpoint answered 2xx.
2075
+ */
2076
+ delivered: boolean;
2077
+ /**
2078
+ * HTTP status the endpoint answered; null if none.
2079
+ */
2080
+ response_status: number | null;
2081
+ /**
2082
+ * Why it failed: the HTTP status, a timeout or a refused destination.
2083
+ */
2084
+ error: string | null;
2085
+ /**
2086
+ * Time until the endpoint answered.
2087
+ */
2088
+ duration_ms: number;
2089
+ };
2090
+ /**
2091
+ * What a tag change did to one contact.
2092
+ */
2093
+ export type ContactTagChange = {
2094
+ /**
2095
+ * Contact ID.
2096
+ */
2097
+ contact_id: string;
2098
+ /**
2099
+ * `updated`; `not_found` when the organization has no such contact; `failed` when Ricky could not save it, so retry that contact.
2100
+ */
2101
+ status: 'updated' | 'not_found' | 'failed';
2102
+ /**
2103
+ * The contact's tags after the change; null unless `updated`.
2104
+ */
2105
+ tags: Array<Tag> | null;
2106
+ };
2107
+ /**
2108
+ * A message whose text matches the search.
2109
+ */
2110
+ export type MessageSearchResult = {
2111
+ /**
2112
+ * Message ID.
2113
+ */
2114
+ message_id: string;
2115
+ /**
2116
+ * Conversation ID.
2117
+ */
2118
+ conversation_id: string;
2119
+ direction: 'inbound' | 'outbound';
2120
+ /**
2121
+ * Message type: `text`, `image`, `audio`, `template`, …
2122
+ */
2123
+ type: string;
2124
+ /**
2125
+ * The matching text: the message, or what Ricky derived from a voice note or file.
2126
+ */
2127
+ text: string;
2128
+ contact: {
1939
2129
  /**
1940
- * Name; null when it has none and for `unassigned`.
2130
+ * Contact name, or the name on the channel.
1941
2131
  */
1942
2132
  name: string | null;
1943
2133
  /**
1944
- * Open conversations they hold.
1945
- */
1946
- open: number;
1947
- /**
1948
- * Of those, the ones whose last message is from the customer.
2134
+ * Address on the channel.
1949
2135
  */
1950
- awaiting_reply: number;
1951
- }>;
2136
+ external_id: string;
2137
+ };
1952
2138
  /**
1953
- * The 15 open conversations waiting longest for a reply, oldest first.
2139
+ * AI agent that wrote it; null otherwise.
1954
2140
  */
1955
- longest_waiting: Array<{
1956
- /**
1957
- * Conversation ID.
1958
- */
1959
- conversation_id: string;
1960
- /**
1961
- * Channel.
1962
- */
1963
- channel: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
1964
- /**
1965
- * Name the channel reports for the customer.
1966
- */
1967
- participant_name: string | null;
1968
- /**
1969
- * When the customer message they wait on arrived.
1970
- */
1971
- waiting_since: string;
1972
- /**
1973
- * `human` is a member, `ai` an AI agent, `unassigned` nobody.
1974
- */
1975
- assignee_type: 'human' | 'ai' | 'unassigned';
1976
- /**
1977
- * Assignee name; null when there is none.
1978
- */
1979
- assignee_name: string | null;
1980
- }>;
2141
+ agent_name: string | null;
2142
+ /**
2143
+ * When it was sent or received.
2144
+ */
2145
+ messaged_at: string;
2146
+ };
2147
+ /**
2148
+ * A saved answer operators insert into a message.
2149
+ */
2150
+ export type QuickReply = {
2151
+ /**
2152
+ * Quick reply ID.
2153
+ */
2154
+ id: string;
2155
+ /**
2156
+ * Name operators pick it by, unique in the organization regardless of case.
2157
+ */
2158
+ title: string;
2159
+ /**
2160
+ * Text inserted into the message.
2161
+ */
2162
+ body: string;
2163
+ };
2164
+ /**
2165
+ * What a bulk assignment did to one conversation.
2166
+ */
2167
+ export type ConversationAssignmentResult = {
1981
2168
  /**
1982
- * When Ricky computed the report.
2169
+ * Conversation ID.
1983
2170
  */
1984
- generated_at: string;
2171
+ conversation_id: string;
2172
+ /**
2173
+ * Member it was to be assigned to.
2174
+ */
2175
+ assigned_user_id: string;
2176
+ /**
2177
+ * `assigned`; `not_found` when the organization has no such conversation; `failed` when Ricky could not save it, so retry that conversation.
2178
+ */
2179
+ status: 'assigned' | 'not_found' | 'failed';
1985
2180
  };
1986
2181
  /**
1987
2182
  * People and AI agents side by side: what they were assigned, what they sent, what they closed and how fast.
@@ -2786,6 +2981,124 @@ export type ReminderHistory = {
2786
2981
  error: string | null;
2787
2982
  }>;
2788
2983
  };
2984
+ export type BusinessHours = {
2985
+ /**
2986
+ * IANA time zone, for example `America/Panama`.
2987
+ */
2988
+ timezone: string;
2989
+ /**
2990
+ * Open ranges of each weekday, in `timezone`; a range never crosses midnight. A day left out of a request is closed. When sent, `start`, `end` and `weekdays` are ignored.
2991
+ */
2992
+ days: {
2993
+ /**
2994
+ * Up to 3 ranges in order; empty when closed that day.
2995
+ */
2996
+ monday: Array<{
2997
+ /**
2998
+ * Opens, `HH:MM`.
2999
+ */
3000
+ start: string;
3001
+ /**
3002
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3003
+ */
3004
+ end: string;
3005
+ }>;
3006
+ /**
3007
+ * Up to 3 ranges in order; empty when closed that day.
3008
+ */
3009
+ tuesday: Array<{
3010
+ /**
3011
+ * Opens, `HH:MM`.
3012
+ */
3013
+ start: string;
3014
+ /**
3015
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3016
+ */
3017
+ end: string;
3018
+ }>;
3019
+ /**
3020
+ * Up to 3 ranges in order; empty when closed that day.
3021
+ */
3022
+ wednesday: Array<{
3023
+ /**
3024
+ * Opens, `HH:MM`.
3025
+ */
3026
+ start: string;
3027
+ /**
3028
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3029
+ */
3030
+ end: string;
3031
+ }>;
3032
+ /**
3033
+ * Up to 3 ranges in order; empty when closed that day.
3034
+ */
3035
+ thursday: Array<{
3036
+ /**
3037
+ * Opens, `HH:MM`.
3038
+ */
3039
+ start: string;
3040
+ /**
3041
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3042
+ */
3043
+ end: string;
3044
+ }>;
3045
+ /**
3046
+ * Up to 3 ranges in order; empty when closed that day.
3047
+ */
3048
+ friday: Array<{
3049
+ /**
3050
+ * Opens, `HH:MM`.
3051
+ */
3052
+ start: string;
3053
+ /**
3054
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3055
+ */
3056
+ end: string;
3057
+ }>;
3058
+ /**
3059
+ * Up to 3 ranges in order; empty when closed that day.
3060
+ */
3061
+ saturday: Array<{
3062
+ /**
3063
+ * Opens, `HH:MM`.
3064
+ */
3065
+ start: string;
3066
+ /**
3067
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3068
+ */
3069
+ end: string;
3070
+ }>;
3071
+ /**
3072
+ * Up to 3 ranges in order; empty when closed that day.
3073
+ */
3074
+ sunday: Array<{
3075
+ /**
3076
+ * Opens, `HH:MM`.
3077
+ */
3078
+ start: string;
3079
+ /**
3080
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
3081
+ */
3082
+ end: string;
3083
+ }>;
3084
+ };
3085
+ /**
3086
+ * Local dates closed whatever the weekday says, such as holidays, `YYYY-MM-DD`.
3087
+ */
3088
+ closed_dates: Array<string>;
3089
+ /**
3090
+ * Deprecated, read `days`: opening time when every open day has the same hours; otherwise the earliest opening of the week.
3091
+ */
3092
+ start: string;
3093
+ /**
3094
+ * Deprecated, read `days`: closing time when every open day has the same hours (before `start` when they cross midnight); otherwise the latest closing of the week.
3095
+ */
3096
+ end: string;
3097
+ /**
3098
+ * Deprecated, read `days`: open days, 0 for Sunday to 6 for Saturday.
3099
+ */
3100
+ weekdays: Array<number>;
3101
+ };
2789
3102
  /**
2790
3103
  * An automation Ricky runs for the organization.
2791
3104
  */
@@ -2808,9 +3121,9 @@ export type Workflow = {
2808
3121
  type: 'conversation' | 'scheduled';
2809
3122
  definition: {
2810
3123
  /**
2811
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves.
3124
+ * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
2812
3125
  */
2813
- trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away';
3126
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away' | 'call_received';
2814
3127
  /**
2815
3128
  * Channels it listens to. See `GET /channels`.
2816
3129
  */
@@ -2850,44 +3163,10 @@ export type Workflow = {
2850
3163
  */
2851
3164
  condition: {
2852
3165
  kind: 'inside_business_hours';
2853
- business_hours: {
2854
- /**
2855
- * Opening time, `HH:MM`.
2856
- */
2857
- start: string;
2858
- /**
2859
- * Closing time, `HH:MM`.
2860
- */
2861
- end: string;
2862
- /**
2863
- * IANA time zone, for example `America/Panama`.
2864
- */
2865
- timezone: string;
2866
- /**
2867
- * Open days, 0 for Sunday to 6 for Saturday.
2868
- */
2869
- weekdays: Array<number>;
2870
- };
3166
+ business_hours: BusinessHours;
2871
3167
  } | {
2872
3168
  kind: 'outside_business_hours';
2873
- business_hours: {
2874
- /**
2875
- * Opening time, `HH:MM`.
2876
- */
2877
- start: string;
2878
- /**
2879
- * Closing time, `HH:MM`.
2880
- */
2881
- end: string;
2882
- /**
2883
- * IANA time zone, for example `America/Panama`.
2884
- */
2885
- timezone: string;
2886
- /**
2887
- * Open days, 0 for Sunday to 6 for Saturday.
2888
- */
2889
- weekdays: Array<number>;
2890
- };
3169
+ business_hours: BusinessHours;
2891
3170
  } | null;
2892
3171
  /**
2893
3172
  * The steps and how they connect.
@@ -2898,7 +3177,7 @@ export type Workflow = {
2898
3177
  */
2899
3178
  entry: string;
2900
3179
  /**
2901
- * One step. `close_conversation` and `end` finish the flow; every other step continues at its target.
3180
+ * One step. `close_conversation`, `end`, `answer_call` and `decline_call` finish the flow; every other step continues at its target.
2902
3181
  */
2903
3182
  steps: Array<{
2904
3183
  /**
@@ -2974,12 +3253,19 @@ export type Workflow = {
2974
3253
  /**
2975
3254
  * Name the answer is kept under, for a later `branch`.
2976
3255
  */
2977
- answer_key: string;
2978
- operator: 'equals' | 'contains' | 'exists';
3256
+ answer_key?: string;
3257
+ /**
3258
+ * How the answer is compared. With `answer_key` and `value`.
3259
+ */
3260
+ operator?: 'equals' | 'contains' | 'exists';
2979
3261
  /**
2980
3262
  * Value compared with the answer.
2981
3263
  */
2982
- value: string;
3264
+ value?: string;
3265
+ /**
3266
+ * Holds while the business is open at the moment the step runs. Send it instead of `answer_key`, `operator` and `value`.
3267
+ */
3268
+ business_hours?: BusinessHours;
2983
3269
  /**
2984
3270
  * Step to run when the condition does not hold; `next` when it does.
2985
3271
  */
@@ -3050,6 +3336,34 @@ export type Workflow = {
3050
3336
  */
3051
3337
  next: string | null;
3052
3338
  kind: 'end';
3339
+ } | {
3340
+ /**
3341
+ * Step ID: letters, digits, `_` or `-`, up to 64.
3342
+ */
3343
+ id: string;
3344
+ /**
3345
+ * Step to run next; null ends the flow.
3346
+ */
3347
+ next: string | null;
3348
+ kind: 'answer_call';
3349
+ /**
3350
+ * AI agent that answers the call, in a `call_received` workflow. The conversation keeps whoever holds it.
3351
+ */
3352
+ agent_id: string;
3353
+ } | {
3354
+ /**
3355
+ * Step ID: letters, digits, `_` or `-`, up to 64.
3356
+ */
3357
+ id: string;
3358
+ /**
3359
+ * Step to run next; null ends the flow.
3360
+ */
3361
+ next: string | null;
3362
+ kind: 'decline_call';
3363
+ /**
3364
+ * In a `call_received` workflow: Ricky rejects the call and sends this text to the caller's WhatsApp chat.
3365
+ */
3366
+ text: string;
3053
3367
  }>;
3054
3368
  };
3055
3369
  } | {
@@ -3377,70 +3691,6 @@ export type WhatsAppNumber = {
3377
3691
  profile_picture_url: string | null;
3378
3692
  };
3379
3693
  };
3380
- /**
3381
- * Only `name` is required; it does not connect the agent to any channel.
3382
- */
3383
- export type CreateAgent = {
3384
- /**
3385
- * Name the team sees.
3386
- */
3387
- name: string;
3388
- /**
3389
- * What the agent is for.
3390
- */
3391
- description?: string | null;
3392
- /**
3393
- * How the agent answers customers.
3394
- */
3395
- instructions?: string | null;
3396
- /**
3397
- * A voice of `GET /agent-options`. Without one, the default voice.
3398
- */
3399
- voice?: string;
3400
- /**
3401
- * The complete set of capability names. Replaces the current ones.
3402
- */
3403
- capabilities?: Array<string>;
3404
- /**
3405
- * The complete set of members who receive handed-off conversations. Required with `ricky.handoff.request`.
3406
- */
3407
- handoff_user_ids?: Array<string>;
3408
- };
3409
- /**
3410
- * Only the fields you send change. Send `null` to clear a text.
3411
- */
3412
- export type UpdateAgent = {
3413
- /**
3414
- * Name the team sees.
3415
- */
3416
- name?: string;
3417
- /**
3418
- * What the agent is for.
3419
- */
3420
- description?: string | null;
3421
- /**
3422
- * How the agent answers customers.
3423
- */
3424
- instructions?: string | null;
3425
- /**
3426
- * A voice of `GET /agent-options`. Without one, the default voice.
3427
- */
3428
- voice?: string;
3429
- /**
3430
- * The complete set of capability names. Replaces the current ones.
3431
- */
3432
- capabilities?: Array<string>;
3433
- /**
3434
- * The complete set of members who receive handed-off conversations. Required with `ricky.handoff.request`.
3435
- */
3436
- handoff_user_ids?: Array<string>;
3437
- };
3438
- export type AssignConversationAgent = {
3439
- /**
3440
- * Agent that answers from now on; null turns the AI off for the conversation.
3441
- */
3442
- agent_id: string | null;
3443
- };
3444
3694
  /**
3445
3695
  * How the handoff ends.
3446
3696
  */
@@ -3814,11 +4064,75 @@ export type CreateWebhook = {
3814
4064
  url: string;
3815
4065
  event_types: Array<'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'conversation.opened' | 'conversation.closed' | 'conversation.assignment_changed' | 'conversation.agent_changed' | 'conversation.handoff_requested' | 'conversation.handoff_resolved' | 'contact.created' | 'contact.updated' | 'contact.tags_changed' | 'broadcast.completed' | 'broadcast.failed' | 'template.status_changed' | 'workflow.execution_failed' | 'knowledge_file.ready'>;
3816
4066
  };
3817
- export type RotateWebhookSecret = {
4067
+ export type RotateWebhookSecret = {
4068
+ /**
4069
+ * How long deliveries keep the previous signature too, so you can deploy the new secret first. 0 ends the previous secret now.
4070
+ */
4071
+ expire_previous_after_hours?: number;
4072
+ };
4073
+ /**
4074
+ * Only `name` is required; it does not connect the agent to any channel.
4075
+ */
4076
+ export type CreateAgent = {
4077
+ /**
4078
+ * Name the team sees.
4079
+ */
4080
+ name: string;
4081
+ /**
4082
+ * What the agent is for.
4083
+ */
4084
+ description?: string | null;
4085
+ /**
4086
+ * How the agent answers customers.
4087
+ */
4088
+ instructions?: string | null;
4089
+ /**
4090
+ * A voice of `GET /agent-options`. Without one, the default voice.
4091
+ */
4092
+ voice?: string;
4093
+ /**
4094
+ * The complete set of capability names. Replaces the current ones.
4095
+ */
4096
+ capabilities?: Array<string>;
4097
+ /**
4098
+ * The complete set of members who receive handed-off conversations. Required with `ricky.handoff.request`.
4099
+ */
4100
+ handoff_user_ids?: Array<string>;
4101
+ };
4102
+ /**
4103
+ * Only the fields you send change. Send `null` to clear a text.
4104
+ */
4105
+ export type UpdateAgent = {
4106
+ /**
4107
+ * Name the team sees.
4108
+ */
4109
+ name?: string;
4110
+ /**
4111
+ * What the agent is for.
4112
+ */
4113
+ description?: string | null;
4114
+ /**
4115
+ * How the agent answers customers.
4116
+ */
4117
+ instructions?: string | null;
4118
+ /**
4119
+ * A voice of `GET /agent-options`. Without one, the default voice.
4120
+ */
4121
+ voice?: string;
4122
+ /**
4123
+ * The complete set of capability names. Replaces the current ones.
4124
+ */
4125
+ capabilities?: Array<string>;
4126
+ /**
4127
+ * The complete set of members who receive handed-off conversations. Required with `ricky.handoff.request`.
4128
+ */
4129
+ handoff_user_ids?: Array<string>;
4130
+ };
4131
+ export type AssignConversationAgent = {
3818
4132
  /**
3819
- * How long deliveries keep the previous signature too, so you can deploy the new secret first. 0 ends the previous secret now.
4133
+ * Agent that answers from now on; null turns the AI off for the conversation.
3820
4134
  */
3821
- expire_previous_after_hours?: number;
4135
+ agent_id: string | null;
3822
4136
  };
3823
4137
  /**
3824
4138
  * Sends an approved template to many numbers, now or at a set time.
@@ -4304,6 +4618,124 @@ export type UploadWorkflowHeaderMedia = {
4304
4618
  */
4305
4619
  file_name?: string;
4306
4620
  };
4621
+ export type BusinessHoursInput = {
4622
+ /**
4623
+ * IANA time zone, for example `America/Panama`.
4624
+ */
4625
+ timezone: string;
4626
+ /**
4627
+ * Open ranges of each weekday, in `timezone`; a range never crosses midnight. A day left out of a request is closed. When sent, `start`, `end` and `weekdays` are ignored.
4628
+ */
4629
+ days?: {
4630
+ /**
4631
+ * Up to 3 ranges in order; empty when closed that day.
4632
+ */
4633
+ monday?: Array<{
4634
+ /**
4635
+ * Opens, `HH:MM`.
4636
+ */
4637
+ start: string;
4638
+ /**
4639
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4640
+ */
4641
+ end: string;
4642
+ }>;
4643
+ /**
4644
+ * Up to 3 ranges in order; empty when closed that day.
4645
+ */
4646
+ tuesday?: Array<{
4647
+ /**
4648
+ * Opens, `HH:MM`.
4649
+ */
4650
+ start: string;
4651
+ /**
4652
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4653
+ */
4654
+ end: string;
4655
+ }>;
4656
+ /**
4657
+ * Up to 3 ranges in order; empty when closed that day.
4658
+ */
4659
+ wednesday?: Array<{
4660
+ /**
4661
+ * Opens, `HH:MM`.
4662
+ */
4663
+ start: string;
4664
+ /**
4665
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4666
+ */
4667
+ end: string;
4668
+ }>;
4669
+ /**
4670
+ * Up to 3 ranges in order; empty when closed that day.
4671
+ */
4672
+ thursday?: Array<{
4673
+ /**
4674
+ * Opens, `HH:MM`.
4675
+ */
4676
+ start: string;
4677
+ /**
4678
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4679
+ */
4680
+ end: string;
4681
+ }>;
4682
+ /**
4683
+ * Up to 3 ranges in order; empty when closed that day.
4684
+ */
4685
+ friday?: Array<{
4686
+ /**
4687
+ * Opens, `HH:MM`.
4688
+ */
4689
+ start: string;
4690
+ /**
4691
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4692
+ */
4693
+ end: string;
4694
+ }>;
4695
+ /**
4696
+ * Up to 3 ranges in order; empty when closed that day.
4697
+ */
4698
+ saturday?: Array<{
4699
+ /**
4700
+ * Opens, `HH:MM`.
4701
+ */
4702
+ start: string;
4703
+ /**
4704
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4705
+ */
4706
+ end: string;
4707
+ }>;
4708
+ /**
4709
+ * Up to 3 ranges in order; empty when closed that day.
4710
+ */
4711
+ sunday?: Array<{
4712
+ /**
4713
+ * Opens, `HH:MM`.
4714
+ */
4715
+ start: string;
4716
+ /**
4717
+ * Closes, `HH:MM`, after `start`; `24:00` is the end of the day.
4718
+ */
4719
+ end: string;
4720
+ }>;
4721
+ };
4722
+ /**
4723
+ * Local dates closed whatever the weekday says, such as holidays, `YYYY-MM-DD`.
4724
+ */
4725
+ closed_dates?: Array<string>;
4726
+ /**
4727
+ * Deprecated, read `days`: opening time when every open day has the same hours; otherwise the earliest opening of the week.
4728
+ */
4729
+ start?: string;
4730
+ /**
4731
+ * Deprecated, read `days`: closing time when every open day has the same hours (before `start` when they cross midnight); otherwise the latest closing of the week.
4732
+ */
4733
+ end?: string;
4734
+ /**
4735
+ * Deprecated, read `days`: open days, 0 for Sunday to 6 for Saturday.
4736
+ */
4737
+ weekdays?: Array<number>;
4738
+ };
4307
4739
  /**
4308
4740
  * Creates a conversation workflow as a `draft`. Activating it is a separate call.
4309
4741
  */
@@ -4317,9 +4749,9 @@ export type CreateWorkflow = {
4317
4749
  */
4318
4750
  definition: {
4319
4751
  /**
4320
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves.
4752
+ * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
4321
4753
  */
4322
- trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away';
4754
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away' | 'call_received';
4323
4755
  /**
4324
4756
  * Channels it listens to. See `GET /channels`.
4325
4757
  */
@@ -4359,44 +4791,10 @@ export type CreateWorkflow = {
4359
4791
  */
4360
4792
  condition: {
4361
4793
  kind: 'inside_business_hours';
4362
- business_hours: {
4363
- /**
4364
- * Opening time, `HH:MM`.
4365
- */
4366
- start: string;
4367
- /**
4368
- * Closing time, `HH:MM`.
4369
- */
4370
- end: string;
4371
- /**
4372
- * IANA time zone, for example `America/Panama`.
4373
- */
4374
- timezone: string;
4375
- /**
4376
- * Open days, 0 for Sunday to 6 for Saturday.
4377
- */
4378
- weekdays: Array<number>;
4379
- };
4794
+ business_hours: BusinessHoursInput;
4380
4795
  } | {
4381
4796
  kind: 'outside_business_hours';
4382
- business_hours: {
4383
- /**
4384
- * Opening time, `HH:MM`.
4385
- */
4386
- start: string;
4387
- /**
4388
- * Closing time, `HH:MM`.
4389
- */
4390
- end: string;
4391
- /**
4392
- * IANA time zone, for example `America/Panama`.
4393
- */
4394
- timezone: string;
4395
- /**
4396
- * Open days, 0 for Sunday to 6 for Saturday.
4397
- */
4398
- weekdays: Array<number>;
4399
- };
4797
+ business_hours: BusinessHoursInput;
4400
4798
  } | null;
4401
4799
  /**
4402
4800
  * The steps and how they connect.
@@ -4407,7 +4805,7 @@ export type CreateWorkflow = {
4407
4805
  */
4408
4806
  entry: string;
4409
4807
  /**
4410
- * One step. `close_conversation` and `end` finish the flow; every other step continues at its target.
4808
+ * One step. `close_conversation`, `end`, `answer_call` and `decline_call` finish the flow; every other step continues at its target.
4411
4809
  */
4412
4810
  steps: Array<{
4413
4811
  /**
@@ -4483,12 +4881,19 @@ export type CreateWorkflow = {
4483
4881
  /**
4484
4882
  * Name the answer is kept under, for a later `branch`.
4485
4883
  */
4486
- answer_key: string;
4487
- operator: 'equals' | 'contains' | 'exists';
4884
+ answer_key?: string;
4885
+ /**
4886
+ * How the answer is compared. With `answer_key` and `value`.
4887
+ */
4888
+ operator?: 'equals' | 'contains' | 'exists';
4488
4889
  /**
4489
4890
  * Value compared with the answer.
4490
4891
  */
4491
- value: string;
4892
+ value?: string;
4893
+ /**
4894
+ * Holds while the business is open at the moment the step runs. Send it instead of `answer_key`, `operator` and `value`.
4895
+ */
4896
+ business_hours?: BusinessHoursInput;
4492
4897
  /**
4493
4898
  * Step to run when the condition does not hold; `next` when it does.
4494
4899
  */
@@ -4559,6 +4964,34 @@ export type CreateWorkflow = {
4559
4964
  */
4560
4965
  next: string | null;
4561
4966
  kind: 'end';
4967
+ } | {
4968
+ /**
4969
+ * Step ID: letters, digits, `_` or `-`, up to 64.
4970
+ */
4971
+ id: string;
4972
+ /**
4973
+ * Step to run next; null ends the flow.
4974
+ */
4975
+ next: string | null;
4976
+ kind: 'answer_call';
4977
+ /**
4978
+ * AI agent that answers the call, in a `call_received` workflow. The conversation keeps whoever holds it.
4979
+ */
4980
+ agent_id: string;
4981
+ } | {
4982
+ /**
4983
+ * Step ID: letters, digits, `_` or `-`, up to 64.
4984
+ */
4985
+ id: string;
4986
+ /**
4987
+ * Step to run next; null ends the flow.
4988
+ */
4989
+ next: string | null;
4990
+ kind: 'decline_call';
4991
+ /**
4992
+ * In a `call_received` workflow: Ricky rejects the call and sends this text to the caller's WhatsApp chat.
4993
+ */
4994
+ text: string;
4562
4995
  }>;
4563
4996
  };
4564
4997
  };
@@ -4576,9 +5009,9 @@ export type UpdateWorkflow = {
4576
5009
  */
4577
5010
  definition?: {
4578
5011
  /**
4579
- * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves.
5012
+ * `conversation_opened` runs when a conversation opens; `first_message_received` when the first message from the contact in a conversation arrives; `message_received` on every incoming message. `team_away` runs nothing: during `coverage` the agent of its only `assign_agent` step answers every conversation of its channels and no assignee moves. `call_received` decides who answers a WhatsApp call on its channels (WhatsApp numbers with AI calls on): its flow takes only `answer_call`, `decline_call` and a `branch` on `business_hours`, and the first active one that reaches a call step decides, over whoever holds the conversation.
4580
5013
  */
4581
- trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away';
5014
+ trigger: 'conversation_opened' | 'first_message_received' | 'message_received' | 'team_away' | 'call_received';
4582
5015
  /**
4583
5016
  * Channels it listens to. See `GET /channels`.
4584
5017
  */
@@ -4618,44 +5051,10 @@ export type UpdateWorkflow = {
4618
5051
  */
4619
5052
  condition: {
4620
5053
  kind: 'inside_business_hours';
4621
- business_hours: {
4622
- /**
4623
- * Opening time, `HH:MM`.
4624
- */
4625
- start: string;
4626
- /**
4627
- * Closing time, `HH:MM`.
4628
- */
4629
- end: string;
4630
- /**
4631
- * IANA time zone, for example `America/Panama`.
4632
- */
4633
- timezone: string;
4634
- /**
4635
- * Open days, 0 for Sunday to 6 for Saturday.
4636
- */
4637
- weekdays: Array<number>;
4638
- };
5054
+ business_hours: BusinessHoursInput;
4639
5055
  } | {
4640
5056
  kind: 'outside_business_hours';
4641
- business_hours: {
4642
- /**
4643
- * Opening time, `HH:MM`.
4644
- */
4645
- start: string;
4646
- /**
4647
- * Closing time, `HH:MM`.
4648
- */
4649
- end: string;
4650
- /**
4651
- * IANA time zone, for example `America/Panama`.
4652
- */
4653
- timezone: string;
4654
- /**
4655
- * Open days, 0 for Sunday to 6 for Saturday.
4656
- */
4657
- weekdays: Array<number>;
4658
- };
5057
+ business_hours: BusinessHoursInput;
4659
5058
  } | null;
4660
5059
  /**
4661
5060
  * The steps and how they connect.
@@ -4666,7 +5065,7 @@ export type UpdateWorkflow = {
4666
5065
  */
4667
5066
  entry: string;
4668
5067
  /**
4669
- * One step. `close_conversation` and `end` finish the flow; every other step continues at its target.
5068
+ * One step. `close_conversation`, `end`, `answer_call` and `decline_call` finish the flow; every other step continues at its target.
4670
5069
  */
4671
5070
  steps: Array<{
4672
5071
  /**
@@ -4742,12 +5141,19 @@ export type UpdateWorkflow = {
4742
5141
  /**
4743
5142
  * Name the answer is kept under, for a later `branch`.
4744
5143
  */
4745
- answer_key: string;
4746
- operator: 'equals' | 'contains' | 'exists';
5144
+ answer_key?: string;
5145
+ /**
5146
+ * How the answer is compared. With `answer_key` and `value`.
5147
+ */
5148
+ operator?: 'equals' | 'contains' | 'exists';
4747
5149
  /**
4748
5150
  * Value compared with the answer.
4749
5151
  */
4750
- value: string;
5152
+ value?: string;
5153
+ /**
5154
+ * Holds while the business is open at the moment the step runs. Send it instead of `answer_key`, `operator` and `value`.
5155
+ */
5156
+ business_hours?: BusinessHoursInput;
4751
5157
  /**
4752
5158
  * Step to run when the condition does not hold; `next` when it does.
4753
5159
  */
@@ -4818,6 +5224,34 @@ export type UpdateWorkflow = {
4818
5224
  */
4819
5225
  next: string | null;
4820
5226
  kind: 'end';
5227
+ } | {
5228
+ /**
5229
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5230
+ */
5231
+ id: string;
5232
+ /**
5233
+ * Step to run next; null ends the flow.
5234
+ */
5235
+ next: string | null;
5236
+ kind: 'answer_call';
5237
+ /**
5238
+ * AI agent that answers the call, in a `call_received` workflow. The conversation keeps whoever holds it.
5239
+ */
5240
+ agent_id: string;
5241
+ } | {
5242
+ /**
5243
+ * Step ID: letters, digits, `_` or `-`, up to 64.
5244
+ */
5245
+ id: string;
5246
+ /**
5247
+ * Step to run next; null ends the flow.
5248
+ */
5249
+ next: string | null;
5250
+ kind: 'decline_call';
5251
+ /**
5252
+ * In a `call_received` workflow: Ricky rejects the call and sends this text to the caller's WhatsApp chat.
5253
+ */
5254
+ text: string;
4821
5255
  }>;
4822
5256
  };
4823
5257
  };
@@ -5282,6 +5716,26 @@ export type ListContactsData = {
5282
5716
  * Only contacts reachable on this channel.
5283
5717
  */
5284
5718
  channel?: 'whatsapp' | 'instagram' | 'messenger' | 'webchat';
5719
+ /**
5720
+ * Only contacts with a customer message, in any of their conversations, from this Meta ad. Ad filters apply together to one customer message: from that ad, campaign or ad set, at that time.
5721
+ */
5722
+ ad_id?: string;
5723
+ /**
5724
+ * Only contacts with a customer message, in any of their conversations, from an ad of this Meta campaign. Matches the ads Ricky synced from a connected ad account.
5725
+ */
5726
+ campaign_id?: string;
5727
+ /**
5728
+ * Only contacts with a customer message, in any of their conversations, from an ad of this Meta ad set. Matches the ads Ricky synced from a connected ad account.
5729
+ */
5730
+ ad_set_id?: string;
5731
+ /**
5732
+ * Only contacts with a customer message, in any of their conversations, from a Meta ad sent at or after this time, ISO 8601.
5733
+ */
5734
+ referred_after?: string;
5735
+ /**
5736
+ * Only contacts with a customer message, in any of their conversations, from a Meta ad sent before this time, ISO 8601.
5737
+ */
5738
+ referred_before?: string;
5285
5739
  };
5286
5740
  url: '/contacts';
5287
5741
  };
@@ -5715,6 +6169,34 @@ export type ListConversationsData = {
5715
6169
  * `customer`: only conversations whose latest message came from the contact.
5716
6170
  */
5717
6171
  last_message_from?: 'customer';
6172
+ /**
6173
+ * Only conversations whose latest message is at or after this time, ISO 8601.
6174
+ */
6175
+ last_activity_after?: string;
6176
+ /**
6177
+ * Only conversations whose latest message is before this time, ISO 8601.
6178
+ */
6179
+ last_activity_before?: string;
6180
+ /**
6181
+ * Only conversations with a customer message from this Meta ad. Ad filters apply together to one customer message: from that ad, campaign or ad set, at that time.
6182
+ */
6183
+ ad_id?: string;
6184
+ /**
6185
+ * Only conversations with a customer message from an ad of this Meta campaign. Matches the ads Ricky synced from a connected ad account.
6186
+ */
6187
+ campaign_id?: string;
6188
+ /**
6189
+ * Only conversations with a customer message from an ad of this Meta ad set. Matches the ads Ricky synced from a connected ad account.
6190
+ */
6191
+ ad_set_id?: string;
6192
+ /**
6193
+ * Only conversations with a customer message from a Meta ad sent at or after this time, ISO 8601.
6194
+ */
6195
+ referred_after?: string;
6196
+ /**
6197
+ * Only conversations with a customer message from a Meta ad sent before this time, ISO 8601.
6198
+ */
6199
+ referred_before?: string;
5718
6200
  };
5719
6201
  url: '/conversations';
5720
6202
  };
@@ -8154,6 +8636,81 @@ export type GetMetaAdsInsightsResponses = {
8154
8636
  };
8155
8637
  };
8156
8638
  export type GetMetaAdsInsightsResponse = GetMetaAdsInsightsResponses[keyof GetMetaAdsInsightsResponses];
8639
+ export type ListAdConversationsData = {
8640
+ body?: never;
8641
+ path?: never;
8642
+ query?: {
8643
+ /**
8644
+ * First day, `YYYY-MM-DD`, America/Panama, inclusive. Send it with `to`; without both, the report covers the last 7 days including today.
8645
+ */
8646
+ from?: string;
8647
+ /**
8648
+ * Last day, `YYYY-MM-DD`, America/Panama, inclusive. A day after today counts as today. The period is at most 366 days.
8649
+ */
8650
+ to?: string;
8651
+ /**
8652
+ * Only this Meta ad.
8653
+ */
8654
+ ad_id?: string;
8655
+ /**
8656
+ * Only ads of this Meta campaign, among the ads Ricky synced from a connected ad account.
8657
+ */
8658
+ campaign_id?: string;
8659
+ /**
8660
+ * Only ads of this Meta ad set, among the ads Ricky synced from a connected ad account.
8661
+ */
8662
+ ad_set_id?: string;
8663
+ /**
8664
+ * Only conversations on this channel.
8665
+ */
8666
+ channel?: 'whatsapp' | 'instagram' | 'messenger';
8667
+ /**
8668
+ * Items per page.
8669
+ */
8670
+ page_size?: number;
8671
+ /**
8672
+ * `next_cursor` from the previous page. Use it unchanged.
8673
+ */
8674
+ cursor?: string;
8675
+ };
8676
+ url: '/ads/conversations';
8677
+ };
8678
+ export type ListAdConversationsErrors = {
8679
+ /**
8680
+ * `invalid_input`: A parameter or body field is invalid; `param` names it when known.
8681
+ */
8682
+ 400: Error;
8683
+ /**
8684
+ * `unauthorized`: The `Authorization` header is missing, malformed, expired or revoked.
8685
+ */
8686
+ 401: Error;
8687
+ /**
8688
+ * `insufficient_scope`: The key lacks the scope this operation requires.
8689
+ */
8690
+ 403: Error;
8691
+ /**
8692
+ * `rate_limited`: More than 120 requests this minute with this key; see `Retry-After`.
8693
+ */
8694
+ 429: Error;
8695
+ /**
8696
+ * `internal_error`: Ricky failed. Retry a read. Before retrying a write, read the resource: the same `Idempotency-Key` answers `request_processing`.
8697
+ */
8698
+ 500: Error;
8699
+ };
8700
+ export type ListAdConversationsError = ListAdConversationsErrors[keyof ListAdConversationsErrors];
8701
+ export type ListAdConversationsResponses = {
8702
+ /**
8703
+ * Success.
8704
+ */
8705
+ 200: {
8706
+ data: Array<AdConversation>;
8707
+ /**
8708
+ * Pass as `cursor` for the next page; null on the last page.
8709
+ */
8710
+ next_cursor: string | null;
8711
+ };
8712
+ };
8713
+ export type ListAdConversationsResponse = ListAdConversationsResponses[keyof ListAdConversationsResponses];
8157
8714
  export type ListAgentsData = {
8158
8715
  body?: never;
8159
8716
  path?: never;