@chatwise/node 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +202 -0
- package/README.md +592 -2
- package/dist/cjs/client.d.ts +20 -0
- package/dist/cjs/client.js +32 -0
- package/dist/cjs/core/errors.d.ts +101 -0
- package/dist/cjs/core/errors.js +143 -0
- package/dist/cjs/core/http.d.ts +87 -0
- package/dist/cjs/core/http.js +360 -0
- package/dist/cjs/core/pagination.d.ts +35 -0
- package/dist/cjs/core/pagination.js +101 -0
- package/dist/cjs/generated/types.d.ts +1017 -0
- package/dist/cjs/generated/types.js +3 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/conversations.d.ts +20 -0
- package/dist/cjs/resources/conversations.js +32 -0
- package/dist/cjs/resources/messages.d.ts +104 -0
- package/dist/cjs/resources/messages.js +112 -0
- package/dist/cjs/resources/webhook-deliveries.d.ts +27 -0
- package/dist/cjs/resources/webhook-deliveries.js +42 -0
- package/dist/cjs/resources/webhook-endpoints.d.ts +54 -0
- package/dist/cjs/resources/webhook-endpoints.js +82 -0
- package/dist/cjs/resources/webhook-event-types.d.ts +13 -0
- package/dist/cjs/resources/webhook-event-types.js +22 -0
- package/dist/cjs/resources/whatsapp-templates.d.ts +48 -0
- package/dist/cjs/resources/whatsapp-templates.js +71 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/webhooks.d.ts +74 -0
- package/dist/cjs/webhooks.js +123 -0
- package/dist/esm/client.d.ts +20 -0
- package/dist/esm/client.js +28 -0
- package/dist/esm/core/errors.d.ts +101 -0
- package/dist/esm/core/errors.js +124 -0
- package/dist/esm/core/http.d.ts +87 -0
- package/dist/esm/core/http.js +356 -0
- package/dist/esm/core/pagination.d.ts +35 -0
- package/dist/esm/core/pagination.js +95 -0
- package/dist/esm/generated/types.d.ts +1017 -0
- package/dist/esm/generated/types.js +2 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/resources/conversations.d.ts +20 -0
- package/dist/esm/resources/conversations.js +28 -0
- package/dist/esm/resources/messages.d.ts +104 -0
- package/dist/esm/resources/messages.js +108 -0
- package/dist/esm/resources/webhook-deliveries.d.ts +27 -0
- package/dist/esm/resources/webhook-deliveries.js +38 -0
- package/dist/esm/resources/webhook-endpoints.d.ts +54 -0
- package/dist/esm/resources/webhook-endpoints.js +78 -0
- package/dist/esm/resources/webhook-event-types.d.ts +13 -0
- package/dist/esm/resources/webhook-event-types.js +18 -0
- package/dist/esm/resources/whatsapp-templates.d.ts +48 -0
- package/dist/esm/resources/whatsapp-templates.js +67 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/webhooks.d.ts +74 -0
- package/dist/esm/webhooks.js +118 -0
- package/package.json +79 -4
|
@@ -0,0 +1,1017 @@
|
|
|
1
|
+
/** One of these values, or one the API added after this version was released. */
|
|
2
|
+
export type Open<Known extends string> = Known | (string & {});
|
|
3
|
+
export type Channel = 'WHATSAPP' | 'INSTAGRAM' | 'MESSENGER' | 'WEBSITE_CHAT';
|
|
4
|
+
export type MessageDirection = 'inbound' | 'outbound';
|
|
5
|
+
export type ConversationStatus = 'open' | 'resolved';
|
|
6
|
+
export type WhatsappTemplateCategory = 'UTILITY' | 'MARKETING' | 'AUTHENTICATION';
|
|
7
|
+
export type WebhookEndpointStatus = 'ACTIVE' | 'PAUSED' | 'DISABLED';
|
|
8
|
+
export type WebhookDeliveryStatus = 'PENDING' | 'PROCESSING' | 'RETRY' | 'DELIVERED' | 'FAILED' | 'CANCELLED';
|
|
9
|
+
/**
|
|
10
|
+
* The events an endpoint can subscribe to.
|
|
11
|
+
*
|
|
12
|
+
* - `message.received`
|
|
13
|
+
* - `message.sent`
|
|
14
|
+
* - `message.delivered`
|
|
15
|
+
* - `message.read`
|
|
16
|
+
* - `message.failed`
|
|
17
|
+
* - `comment.received`
|
|
18
|
+
*/
|
|
19
|
+
export type KnownWebhookEventType = 'message.received' | 'message.sent' | 'message.delivered' | 'message.read' | 'message.failed' | 'comment.received';
|
|
20
|
+
/** An event to subscribe to: one this version knows, or a newer one. */
|
|
21
|
+
export type WebhookEventType = Open<KnownWebhookEventType>;
|
|
22
|
+
export interface Conversation {
|
|
23
|
+
/** The conversation's id. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** The channel the conversation is on. */
|
|
26
|
+
channel: Open<Channel>;
|
|
27
|
+
/** Whether the conversation is open or resolved in the inbox. */
|
|
28
|
+
status: Open<ConversationStatus>;
|
|
29
|
+
/** The customer. */
|
|
30
|
+
participant: {
|
|
31
|
+
/** The customer's name. A placeholder, or on Website Chat their email, when Chatwise doesn't know it. */
|
|
32
|
+
name: string | null;
|
|
33
|
+
/** The customer's id on the channel: the WhatsApp number, or an Instagram or Messenger id. Null on Website Chat. */
|
|
34
|
+
channelId: string | null;
|
|
35
|
+
/** The customer's phone number, digits only, on WhatsApp. Null on other channels, and when WhatsApp doesn't show it. */
|
|
36
|
+
phoneNumber: string | null;
|
|
37
|
+
/** The customer's Instagram username, when known. Null on WhatsApp. */
|
|
38
|
+
instagramUsername: string | null;
|
|
39
|
+
};
|
|
40
|
+
/** When the conversation was created in Chatwise. ISO 8601, in UTC. */
|
|
41
|
+
createdAt: string;
|
|
42
|
+
/** When the latest message was sent. Null before the first one. ISO 8601, in UTC. */
|
|
43
|
+
lastMessageAt: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface Message {
|
|
46
|
+
/** The message's id. */
|
|
47
|
+
id: string;
|
|
48
|
+
/** The conversation the message is in. */
|
|
49
|
+
conversationId: string;
|
|
50
|
+
/** The channel the message is on. */
|
|
51
|
+
channel: Open<Channel>;
|
|
52
|
+
/** `inbound` from the customer, `outbound` from the workspace. */
|
|
53
|
+
direction: Open<MessageDirection>;
|
|
54
|
+
/** The message's type, such as `text`, `image`, `audio`, `interactive` or `whatsapp_template`. */
|
|
55
|
+
type: string;
|
|
56
|
+
/** The text or caption. For other types, text that Chatwise makes of the message, such as JSON for a location or contacts. On Messenger, a message without a text has the title and address of what is shared in it, such as a link, also when it has a file. With neither, it has words of Chatwise's such as `Attachment sent in Messenger`. Null for WhatsApp authentication templates, so a one-time code is never returned. */
|
|
57
|
+
text: string | null;
|
|
58
|
+
/** When the message was sent. ISO 8601, in UTC. */
|
|
59
|
+
sentAt: string;
|
|
60
|
+
/** When Chatwise stored the message. ISO 8601, in UTC. */
|
|
61
|
+
ingestedAt: string;
|
|
62
|
+
/** The message this one replies to, if any and still visible. */
|
|
63
|
+
replyToMessageId: string | null;
|
|
64
|
+
/** The message's attachments, at most 10. Always empty on Website Chat, for WhatsApp authentication templates, and for Messenger messages from before Chatwise kept their attachments, in December 2026. */
|
|
65
|
+
attachments: {
|
|
66
|
+
/** The attachment's type, such as `image`, `video`, `audio` or `document`. */
|
|
67
|
+
type: string;
|
|
68
|
+
/** The channel's id for the media, when Chatwise has it: usually on Instagram only. */
|
|
69
|
+
mediaId: string | null;
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
72
|
+
export interface WhatsappTemplate {
|
|
73
|
+
/** The template's id: Meta's, or Chatwise's for an older template without one. Send it as `templateId`. */
|
|
74
|
+
id: string;
|
|
75
|
+
/** The template's name. */
|
|
76
|
+
name: string;
|
|
77
|
+
/** The template's language code, such as `en_US`. */
|
|
78
|
+
language: string;
|
|
79
|
+
/** The template's category. */
|
|
80
|
+
category: Open<WhatsappTemplateCategory> | null;
|
|
81
|
+
/** Meta's review status, such as `APPROVED`, `PENDING`, `REJECTED` or `PAUSED`. */
|
|
82
|
+
status: string | null;
|
|
83
|
+
/** Why Meta rejected it, when it is rejected. */
|
|
84
|
+
rejectionReason: string | null;
|
|
85
|
+
/** Whether the send routes can send it: approved, with a layout they support. */
|
|
86
|
+
sendable: boolean;
|
|
87
|
+
/** How its variables are written. Null without variables. */
|
|
88
|
+
parameterFormat: Open<'NAMED' | 'POSITIONAL'> | null;
|
|
89
|
+
/** Whether sending it needs a one-time code, as the `otp` value in `templateParams`. */
|
|
90
|
+
requiresOtp: boolean;
|
|
91
|
+
/** Settings of an authentication template. Otherwise null. */
|
|
92
|
+
authentication: {
|
|
93
|
+
/** Whether it tells the customer not to share the code. */
|
|
94
|
+
addSecurityRecommendation: boolean | null;
|
|
95
|
+
/** How long it says the code is valid. */
|
|
96
|
+
codeExpirationMinutes: number | null;
|
|
97
|
+
} | null;
|
|
98
|
+
/** What the template contains. */
|
|
99
|
+
components: {
|
|
100
|
+
/** The header, if any. */
|
|
101
|
+
header: {
|
|
102
|
+
/** `TEXT`, `IMAGE`, `VIDEO` or `DOCUMENT`. */
|
|
103
|
+
format: string;
|
|
104
|
+
/** The text of a text header. */
|
|
105
|
+
text: string | null;
|
|
106
|
+
/** The header's variables. */
|
|
107
|
+
variables: string[];
|
|
108
|
+
} | null;
|
|
109
|
+
/** The body. */
|
|
110
|
+
body: {
|
|
111
|
+
/** The body's text. */
|
|
112
|
+
text: string | null;
|
|
113
|
+
/** The body's variables. */
|
|
114
|
+
variables: string[];
|
|
115
|
+
};
|
|
116
|
+
/** The footer's text, if any. */
|
|
117
|
+
footer: string | null;
|
|
118
|
+
/** The buttons. */
|
|
119
|
+
buttons: {
|
|
120
|
+
/** The button's position, from 0. Use it as `index` when sending. */
|
|
121
|
+
index: number;
|
|
122
|
+
/** The button's type, such as `URL`, `QUICK_REPLY`, `PHONE_NUMBER`, `COPY_CODE` or `OTP`. */
|
|
123
|
+
type: string;
|
|
124
|
+
/** The button's label. */
|
|
125
|
+
text: string | null;
|
|
126
|
+
/** The URL of a `URL` button. */
|
|
127
|
+
url: string | null;
|
|
128
|
+
/** The phone number of a `PHONE_NUMBER` button. */
|
|
129
|
+
phoneNumber: string | null;
|
|
130
|
+
/** The variable at the end of a dynamic URL, if any. */
|
|
131
|
+
variable: string | null;
|
|
132
|
+
/** The parameter the button takes when sending, if any. */
|
|
133
|
+
parameterType: Open<'text' | 'payload' | 'coupon_code'> | null;
|
|
134
|
+
/** The kind of one-time code button, on authentication templates. */
|
|
135
|
+
otpType: string | null;
|
|
136
|
+
}[];
|
|
137
|
+
};
|
|
138
|
+
/** Why the send routes can't send it, if they can't because of its layout. */
|
|
139
|
+
unsupportedReason: string | null;
|
|
140
|
+
/** When Chatwise stored the template. ISO 8601, in UTC. */
|
|
141
|
+
createdAt: string;
|
|
142
|
+
/** When the template last changed in Chatwise. ISO 8601, in UTC. */
|
|
143
|
+
updatedAt: string;
|
|
144
|
+
}
|
|
145
|
+
export interface WebhookEndpoint {
|
|
146
|
+
/** The endpoint's id. */
|
|
147
|
+
id: string;
|
|
148
|
+
/** The endpoint's name. */
|
|
149
|
+
name: string;
|
|
150
|
+
/** Where events are sent. */
|
|
151
|
+
url: string;
|
|
152
|
+
/** The events it receives. */
|
|
153
|
+
events: WebhookEventType[];
|
|
154
|
+
/** The accounts it receives events for. Empty means every account. */
|
|
155
|
+
accountIds: string[];
|
|
156
|
+
/** `ACTIVE`, `PAUSED` by the workspace, or `DISABLED` by Chatwise (see `health.disabledReason`). */
|
|
157
|
+
status: Open<WebhookEndpointStatus>;
|
|
158
|
+
/** The payload format it receives, as a date. */
|
|
159
|
+
apiVersion: string;
|
|
160
|
+
/** How its deliveries are going. */
|
|
161
|
+
health: {
|
|
162
|
+
/** When an attempt last succeeded. ISO 8601, in UTC. */
|
|
163
|
+
lastSuccessAt: string | null;
|
|
164
|
+
/** When an attempt last failed. ISO 8601, in UTC. */
|
|
165
|
+
lastFailureAt: string | null;
|
|
166
|
+
/** Failed attempts since the last success. */
|
|
167
|
+
consecutiveFailures: number;
|
|
168
|
+
/** When Chatwise disabled it. ISO 8601, in UTC. */
|
|
169
|
+
disabledAt: string | null;
|
|
170
|
+
/** Why Chatwise disabled it. */
|
|
171
|
+
disabledReason: string | null;
|
|
172
|
+
/** Until when Chatwise sends it nothing, because it is unavailable. Null when it isn't waiting. ISO 8601, in UTC. */
|
|
173
|
+
backoffUntil: string | null;
|
|
174
|
+
};
|
|
175
|
+
/** When it was created. ISO 8601, in UTC. */
|
|
176
|
+
createdAt: string;
|
|
177
|
+
/** When it, or its health, last changed. ISO 8601, in UTC. */
|
|
178
|
+
updatedAt: string;
|
|
179
|
+
}
|
|
180
|
+
export interface WebhookDelivery {
|
|
181
|
+
/** The delivery's id, also sent as the `X-Chatwise-Delivery` header. */
|
|
182
|
+
id: string;
|
|
183
|
+
/** The event's id, also sent as the `webhook-id` header. */
|
|
184
|
+
eventId: string;
|
|
185
|
+
/** The event's name. */
|
|
186
|
+
eventType: WebhookEventType;
|
|
187
|
+
/** When the event happened. ISO 8601, in UTC. */
|
|
188
|
+
occurredAt: string;
|
|
189
|
+
/** `PENDING` (waiting), `PROCESSING` (being sent), `RETRY` (waiting for its next attempt), `DELIVERED`, `FAILED` or `CANCELLED`. */
|
|
190
|
+
status: Open<WebhookDeliveryStatus>;
|
|
191
|
+
/** Attempts so far. Redelivering starts again from 0. */
|
|
192
|
+
attempts: number;
|
|
193
|
+
/** The HTTP status the last attempt got. Null when there was no answer. */
|
|
194
|
+
lastStatusCode: number | null;
|
|
195
|
+
/** Why the last attempt failed, such as `http_500` or `timeout`. `retry_exhausted` once the last of all attempts failed. */
|
|
196
|
+
lastError: string | null;
|
|
197
|
+
/** How long the last attempt took, in milliseconds. */
|
|
198
|
+
lastDurationMs: number | null;
|
|
199
|
+
/** When it is next due to be sent, while it is `PENDING` or `RETRY`. Otherwise null. ISO 8601, in UTC. */
|
|
200
|
+
nextAttemptAt: string | null;
|
|
201
|
+
/** When it was delivered. ISO 8601, in UTC. */
|
|
202
|
+
deliveredAt: string | null;
|
|
203
|
+
/** When the delivery was created. ISO 8601, in UTC. */
|
|
204
|
+
createdAt: string;
|
|
205
|
+
}
|
|
206
|
+
export interface WebhookDeliveryDetails {
|
|
207
|
+
/** The delivery's id, also sent as the `X-Chatwise-Delivery` header. */
|
|
208
|
+
id: string;
|
|
209
|
+
/** The event's id, also sent as the `webhook-id` header. */
|
|
210
|
+
eventId: string;
|
|
211
|
+
/** The event's name. */
|
|
212
|
+
eventType: WebhookEventType;
|
|
213
|
+
/** When the event happened. ISO 8601, in UTC. */
|
|
214
|
+
occurredAt: string;
|
|
215
|
+
/** `PENDING` (waiting), `PROCESSING` (being sent), `RETRY` (waiting for its next attempt), `DELIVERED`, `FAILED` or `CANCELLED`. */
|
|
216
|
+
status: Open<WebhookDeliveryStatus>;
|
|
217
|
+
/** Attempts so far. Redelivering starts again from 0. */
|
|
218
|
+
attempts: number;
|
|
219
|
+
/** The HTTP status the last attempt got. Null when there was no answer. */
|
|
220
|
+
lastStatusCode: number | null;
|
|
221
|
+
/** Why the last attempt failed, such as `http_500` or `timeout`. `retry_exhausted` once the last of all attempts failed. */
|
|
222
|
+
lastError: string | null;
|
|
223
|
+
/** How long the last attempt took, in milliseconds. */
|
|
224
|
+
lastDurationMs: number | null;
|
|
225
|
+
/** When it is next due to be sent, while it is `PENDING` or `RETRY`. Otherwise null. ISO 8601, in UTC. */
|
|
226
|
+
nextAttemptAt: string | null;
|
|
227
|
+
/** When it was delivered. ISO 8601, in UTC. */
|
|
228
|
+
deliveredAt: string | null;
|
|
229
|
+
/** When the delivery was created. ISO 8601, in UTC. */
|
|
230
|
+
createdAt: string;
|
|
231
|
+
/** The endpoint it is for. */
|
|
232
|
+
endpointId: string;
|
|
233
|
+
/** The event's `data`. Null until the event is prepared, and once its message was unsent, deleted or hidden, or its comment hidden or no longer stored. */
|
|
234
|
+
payload: Record<string, unknown> | null;
|
|
235
|
+
/** The attempts that were recorded: all but a success on the first try. After a redelivery the numbers start again and the earlier attempts stay, so sort by `startedAt`. */
|
|
236
|
+
attemptLog: {
|
|
237
|
+
/** The attempt's number, from 1. */
|
|
238
|
+
attemptNumber: number;
|
|
239
|
+
/** When it started. ISO 8601, in UTC. */
|
|
240
|
+
startedAt: string;
|
|
241
|
+
/** How long it took, in milliseconds. */
|
|
242
|
+
durationMs: number | null;
|
|
243
|
+
/** The HTTP status your endpoint answered. */
|
|
244
|
+
statusCode: number | null;
|
|
245
|
+
/** Why it failed. Null when it succeeded. */
|
|
246
|
+
error: string | null;
|
|
247
|
+
}[];
|
|
248
|
+
}
|
|
249
|
+
export interface WhatsappTemplateParam {
|
|
250
|
+
/** The variable's name, its number (`1`, `2`, …), or `otp` for the code of an authentication template. */
|
|
251
|
+
parameter_name: string;
|
|
252
|
+
/** The variable's value. */
|
|
253
|
+
text: string;
|
|
254
|
+
}
|
|
255
|
+
export type WhatsappTemplateComponent = {
|
|
256
|
+
/** `header`, `body` or `button`. */
|
|
257
|
+
type: 'header';
|
|
258
|
+
/** The component's values: one for a header or a button, one or more for a body. */
|
|
259
|
+
parameters: ({
|
|
260
|
+
/** The kind of value. */
|
|
261
|
+
type: 'text';
|
|
262
|
+
/** The text. */
|
|
263
|
+
text: string;
|
|
264
|
+
/** The variable's name, for templates with named variables. Spaces around it are ignored. Can't be blank. */
|
|
265
|
+
parameterName?: string | undefined;
|
|
266
|
+
} | {
|
|
267
|
+
/** The kind of value. */
|
|
268
|
+
type: 'image';
|
|
269
|
+
/** An image, by `link` or Meta media `id`. */
|
|
270
|
+
image: {
|
|
271
|
+
/** The image's public URL. */
|
|
272
|
+
link?: string | undefined;
|
|
273
|
+
/** The image's Meta media id. Spaces around it are ignored. Can't be blank. */
|
|
274
|
+
id?: string | undefined;
|
|
275
|
+
} & ({
|
|
276
|
+
link: string;
|
|
277
|
+
} | {
|
|
278
|
+
id: string;
|
|
279
|
+
});
|
|
280
|
+
} | {
|
|
281
|
+
/** The kind of value. */
|
|
282
|
+
type: 'video';
|
|
283
|
+
/** A video, by `link` or Meta media `id`. */
|
|
284
|
+
video: {
|
|
285
|
+
/** The video's public URL. */
|
|
286
|
+
link?: string | undefined;
|
|
287
|
+
/** The video's Meta media id. Spaces around it are ignored. Can't be blank. */
|
|
288
|
+
id?: string | undefined;
|
|
289
|
+
} & ({
|
|
290
|
+
link: string;
|
|
291
|
+
} | {
|
|
292
|
+
id: string;
|
|
293
|
+
});
|
|
294
|
+
} | {
|
|
295
|
+
/** The kind of value. */
|
|
296
|
+
type: 'document';
|
|
297
|
+
/** A document, by `link` or Meta media `id`. */
|
|
298
|
+
document: {
|
|
299
|
+
/** The document's public URL. */
|
|
300
|
+
link?: string | undefined;
|
|
301
|
+
/** The document's Meta media id. Spaces around it are ignored. Can't be blank. */
|
|
302
|
+
id?: string | undefined;
|
|
303
|
+
/** The file name the customer sees. */
|
|
304
|
+
filename?: string | undefined;
|
|
305
|
+
} & ({
|
|
306
|
+
link: string;
|
|
307
|
+
} | {
|
|
308
|
+
id: string;
|
|
309
|
+
});
|
|
310
|
+
})[];
|
|
311
|
+
} | {
|
|
312
|
+
/** `header`, `body` or `button`. */
|
|
313
|
+
type: 'body';
|
|
314
|
+
/** The component's values: one for a header or a button, one or more for a body. */
|
|
315
|
+
parameters: ({
|
|
316
|
+
/** The kind of value. */
|
|
317
|
+
type: 'text';
|
|
318
|
+
/** The text. */
|
|
319
|
+
text: string;
|
|
320
|
+
/** The variable's name, for templates with named variables. Spaces around it are ignored. Can't be blank. */
|
|
321
|
+
parameterName?: string | undefined;
|
|
322
|
+
} | {
|
|
323
|
+
/** The kind of value. */
|
|
324
|
+
type: 'currency';
|
|
325
|
+
/** The variable's name, for templates with named variables. Spaces around it are ignored. Can't be blank. */
|
|
326
|
+
parameterName?: string | undefined;
|
|
327
|
+
/** An amount of money. */
|
|
328
|
+
currency: {
|
|
329
|
+
/** The amount as text, such as `$12.50`. */
|
|
330
|
+
fallbackValue: string;
|
|
331
|
+
/** The ISO 4217 currency code. Spaces around it are ignored. */
|
|
332
|
+
code: string;
|
|
333
|
+
/** The amount times 1000. */
|
|
334
|
+
amount1000: number;
|
|
335
|
+
};
|
|
336
|
+
} | {
|
|
337
|
+
/** The kind of value. */
|
|
338
|
+
type: 'date_time';
|
|
339
|
+
/** The variable's name, for templates with named variables. Spaces around it are ignored. Can't be blank. */
|
|
340
|
+
parameterName?: string | undefined;
|
|
341
|
+
/** A date or time. */
|
|
342
|
+
dateTime: {
|
|
343
|
+
/** The date or time as text. */
|
|
344
|
+
fallbackValue: string;
|
|
345
|
+
};
|
|
346
|
+
})[];
|
|
347
|
+
} | {
|
|
348
|
+
/** `header`, `body` or `button`. */
|
|
349
|
+
type: 'button';
|
|
350
|
+
/** The button's kind: `url` takes a `text` parameter, `quick_reply` a `payload`, `copy_code` a `coupon_code`. */
|
|
351
|
+
subType: 'url';
|
|
352
|
+
/** The button's position, from 0. */
|
|
353
|
+
index: number;
|
|
354
|
+
/** The component's values: one for a header or a button, one or more for a body. */
|
|
355
|
+
parameters: {
|
|
356
|
+
/** The kind of value. */
|
|
357
|
+
type: 'text';
|
|
358
|
+
/** The text. */
|
|
359
|
+
text: string;
|
|
360
|
+
/** The variable's name, for templates with named variables. Spaces around it are ignored. Can't be blank. */
|
|
361
|
+
parameterName?: string | undefined;
|
|
362
|
+
}[];
|
|
363
|
+
} | {
|
|
364
|
+
/** `header`, `body` or `button`. */
|
|
365
|
+
type: 'button';
|
|
366
|
+
/** The button's kind: `url` takes a `text` parameter, `quick_reply` a `payload`, `copy_code` a `coupon_code`. */
|
|
367
|
+
subType: 'quick_reply';
|
|
368
|
+
/** The button's position, from 0. */
|
|
369
|
+
index: number;
|
|
370
|
+
/** The component's values: one for a header or a button, one or more for a body. */
|
|
371
|
+
parameters: {
|
|
372
|
+
/** The kind of value. */
|
|
373
|
+
type: 'payload';
|
|
374
|
+
/** What a quick reply button sends back. */
|
|
375
|
+
payload: string;
|
|
376
|
+
}[];
|
|
377
|
+
} | {
|
|
378
|
+
/** `header`, `body` or `button`. */
|
|
379
|
+
type: 'button';
|
|
380
|
+
/** The button's kind: `url` takes a `text` parameter, `quick_reply` a `payload`, `copy_code` a `coupon_code`. */
|
|
381
|
+
subType: 'copy_code';
|
|
382
|
+
/** The button's position, from 0. */
|
|
383
|
+
index: number;
|
|
384
|
+
/** The component's values: one for a header or a button, one or more for a body. */
|
|
385
|
+
parameters: {
|
|
386
|
+
/** The kind of value. */
|
|
387
|
+
type: 'coupon_code';
|
|
388
|
+
/** The code a copy code button copies. */
|
|
389
|
+
couponCode: string;
|
|
390
|
+
}[];
|
|
391
|
+
};
|
|
392
|
+
/** A file to send instead of a text. */
|
|
393
|
+
export interface ReplyMedia {
|
|
394
|
+
/** The https address of the file, which must answer without a redirect or a sign-in. */
|
|
395
|
+
url: string;
|
|
396
|
+
/** The name a document is shown with on WhatsApp, up to 120 characters. On Messenger the customer sees the letters A to Z and the digits of it, with some of Chatwise's own after them. Its ending is the document's own. Without it, the one the file's server gives. Word, Excel and PowerPoint files from before 2007 look the same inside, so their name, or the type their server gives, has to say which they are. Can't contain NUL characters or unpaired surrogates. */
|
|
397
|
+
fileName?: string | undefined;
|
|
398
|
+
/** A text shown with the file: on WhatsApp, for an image, a video or a document. At most 1,024 characters. It is refused elsewhere; send the text as a message of its own there. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
399
|
+
caption?: string | undefined;
|
|
400
|
+
}
|
|
401
|
+
/** The filters of "List conversations". */
|
|
402
|
+
export interface ListConversationsParams {
|
|
403
|
+
/**
|
|
404
|
+
* How many to return, from 1 to 100.
|
|
405
|
+
* @defaultValue 50
|
|
406
|
+
*/
|
|
407
|
+
limit?: number | undefined;
|
|
408
|
+
/** The previous page's `pagination.nextCursor`. Repeat the same filters and order with it. */
|
|
409
|
+
cursor?: string | undefined;
|
|
410
|
+
/** Only conversations with a latest message at or after this time. ISO 8601 with a time zone, at most milliseconds. */
|
|
411
|
+
from?: Date | string | undefined;
|
|
412
|
+
/** Only conversations with a latest message before this time, which must be after `from`. ISO 8601 with a time zone, at most milliseconds. */
|
|
413
|
+
to?: Date | string | undefined;
|
|
414
|
+
/** Only conversations on this channel. Without it, every channel, Website Chat included. */
|
|
415
|
+
channel?: 'WHATSAPP' | 'INSTAGRAM' | 'MESSENGER' | undefined;
|
|
416
|
+
/** Only open or only resolved conversations. Leave out for both. */
|
|
417
|
+
status?: ConversationStatus | undefined;
|
|
418
|
+
/** Text in the customer's name, WhatsApp number or Instagram username (with or without `@`), in any case. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
419
|
+
q?: string | undefined;
|
|
420
|
+
}
|
|
421
|
+
/** The filters of "List a conversation's messages". */
|
|
422
|
+
export interface ListConversationMessagesParams {
|
|
423
|
+
/**
|
|
424
|
+
* How many to return, from 1 to 100.
|
|
425
|
+
* @defaultValue 50
|
|
426
|
+
*/
|
|
427
|
+
limit?: number | undefined;
|
|
428
|
+
/** The previous page's `pagination.nextCursor`. Repeat the same filters and order with it. */
|
|
429
|
+
cursor?: string | undefined;
|
|
430
|
+
/** Only messages at or after this time. ISO 8601 with a time zone, at most milliseconds. */
|
|
431
|
+
from?: Date | string | undefined;
|
|
432
|
+
/** Only messages before this time, which must be after `from`. ISO 8601 with a time zone, at most milliseconds. */
|
|
433
|
+
to?: Date | string | undefined;
|
|
434
|
+
/** `inbound` from the customer, `outbound` from the workspace. Leave out for both. */
|
|
435
|
+
direction?: MessageDirection | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* The time to filter and sort by: `sentAt`, or `ingestedAt` for when Chatwise stored the message.
|
|
438
|
+
* @defaultValue 'sentAt'
|
|
439
|
+
*/
|
|
440
|
+
timeField?: 'sentAt' | 'ingestedAt' | undefined;
|
|
441
|
+
/**
|
|
442
|
+
* `desc` for newest first, `asc` for oldest first.
|
|
443
|
+
* @defaultValue 'desc'
|
|
444
|
+
*/
|
|
445
|
+
order?: 'asc' | 'desc' | undefined;
|
|
446
|
+
}
|
|
447
|
+
/** The body of "Reply in a conversation". */
|
|
448
|
+
export interface SendReplyParams {
|
|
449
|
+
/** The message. At most 4,096 characters on WhatsApp, 2,000 on Messenger, and 1,000 bytes of UTF-8 on Instagram. Send either this or `media`. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
450
|
+
text?: string | undefined;
|
|
451
|
+
/** A file to send instead of a text. */
|
|
452
|
+
media?: ReplyMedia | undefined;
|
|
453
|
+
}
|
|
454
|
+
/** What "Reply in a conversation" answers. */
|
|
455
|
+
export interface SendReplyResult {
|
|
456
|
+
/** The message's id. */
|
|
457
|
+
id: string;
|
|
458
|
+
/** The conversation's id. */
|
|
459
|
+
conversationId: string;
|
|
460
|
+
/** The conversation's channel. */
|
|
461
|
+
channel: Open<'WHATSAPP' | 'INSTAGRAM' | 'MESSENGER'>;
|
|
462
|
+
/** What kind of message it is, such as `text`. */
|
|
463
|
+
type: string;
|
|
464
|
+
/** When the channel accepted it. ISO 8601, in UTC. */
|
|
465
|
+
sentAt: string;
|
|
466
|
+
}
|
|
467
|
+
/** What "List a message's files" answers. */
|
|
468
|
+
export interface MessageFile {
|
|
469
|
+
/** The file's id, the same each time you list it. Only when one of several Instagram files is lost before it is copied can another take its id. */
|
|
470
|
+
id: string;
|
|
471
|
+
/** What kind of file it is. */
|
|
472
|
+
type: Open<'image' | 'video' | 'audio' | 'document'>;
|
|
473
|
+
/** `available`, `pending` while Chatwise is still copying it, or `unavailable` when it couldn't be copied, isn't copied after 15 minutes, or is gone. */
|
|
474
|
+
status: Open<'available' | 'pending' | 'unavailable'>;
|
|
475
|
+
/** The name it was sent with, if Chatwise has it. */
|
|
476
|
+
name: string | null;
|
|
477
|
+
/** Its MIME type. Types a browser could run, such as HTML and SVG, are downloaded as `application/octet-stream`. Null unless it is available. */
|
|
478
|
+
mimeType: string | null;
|
|
479
|
+
/** Its size in bytes. Null unless it is available. */
|
|
480
|
+
size: number | null;
|
|
481
|
+
/** Where to download it, without an API key, until `urlExpiresAt`. Null unless it is available. */
|
|
482
|
+
url: string | null;
|
|
483
|
+
/** When the link stops working. ISO 8601, in UTC. Null unless it is available. */
|
|
484
|
+
urlExpiresAt: string | null;
|
|
485
|
+
}
|
|
486
|
+
/** The filters of "List or search messages". */
|
|
487
|
+
export interface ListMessagesParams {
|
|
488
|
+
/**
|
|
489
|
+
* How many to return, from 1 to 100.
|
|
490
|
+
* @defaultValue 50
|
|
491
|
+
*/
|
|
492
|
+
limit?: number | undefined;
|
|
493
|
+
/** The previous page's `pagination.nextCursor`. Repeat the same filters and order with it. */
|
|
494
|
+
cursor?: string | undefined;
|
|
495
|
+
/** Only messages at or after this time. ISO 8601 with a time zone, at most milliseconds. */
|
|
496
|
+
from?: Date | string | undefined;
|
|
497
|
+
/** Only messages before this time, which must be after `from`. ISO 8601 with a time zone, at most milliseconds. */
|
|
498
|
+
to?: Date | string | undefined;
|
|
499
|
+
/** `inbound` from the customer, `outbound` from the workspace. Leave out for both. */
|
|
500
|
+
direction?: MessageDirection | undefined;
|
|
501
|
+
/**
|
|
502
|
+
* The time to filter and sort by: `sentAt`, or `ingestedAt` for when Chatwise stored the message.
|
|
503
|
+
* @defaultValue 'sentAt'
|
|
504
|
+
*/
|
|
505
|
+
timeField?: 'sentAt' | 'ingestedAt' | undefined;
|
|
506
|
+
/**
|
|
507
|
+
* `desc` for newest first, `asc` for oldest first.
|
|
508
|
+
* @defaultValue 'desc'
|
|
509
|
+
*/
|
|
510
|
+
order?: 'asc' | 'desc' | undefined;
|
|
511
|
+
/** Text the message contains, in any case. Every character counts as itself: there are no wildcards. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
512
|
+
q?: string | undefined;
|
|
513
|
+
/** Only messages in this conversation. */
|
|
514
|
+
conversationId?: string | undefined;
|
|
515
|
+
/** Only messages on this channel. Without it, every channel, Website Chat included. */
|
|
516
|
+
channel?: 'WHATSAPP' | 'INSTAGRAM' | 'MESSENGER' | undefined;
|
|
517
|
+
}
|
|
518
|
+
/** The body of "Send a template by id". */
|
|
519
|
+
export interface SendMessageParams {
|
|
520
|
+
/** The customer's phone number with its country code. */
|
|
521
|
+
to: string;
|
|
522
|
+
/** The template's `id`. Needed to send. */
|
|
523
|
+
templateId?: string | undefined;
|
|
524
|
+
/** Values for the body's variables. A template with a variable or media in its header, a dynamic URL button or a copy code button takes `templateComponents` instead. Keys other than `parameter_name` and `text` are ignored. */
|
|
525
|
+
templateParams?: WhatsappTemplateParam[] | undefined;
|
|
526
|
+
/** The language code to send it in, such as `en_US`. Without it, the template's own. Spaces around it are ignored. */
|
|
527
|
+
templateLanguage?: string | undefined;
|
|
528
|
+
/** Values for the header, body and buttons, up to 12 components. Used instead of `templateParams`, except for authentication templates. At most one header and one body, and no two buttons with the same `subType` and `index`. */
|
|
529
|
+
templateComponents?: (WhatsappTemplateComponent)[] | undefined;
|
|
530
|
+
/** Use `WHATSAPP`. */
|
|
531
|
+
channel: 'WHATSAPP' | 'INSTAGRAM';
|
|
532
|
+
/** The connected WhatsApp number to send from, digits only. Without it: the number on the template's WhatsApp Business Account the customer last wrote to, else the oldest number there. */
|
|
533
|
+
from?: string | undefined;
|
|
534
|
+
}
|
|
535
|
+
/** What "Send a template by id" answers. */
|
|
536
|
+
export interface SendMessageResult {
|
|
537
|
+
/** A confirmation. */
|
|
538
|
+
message: string;
|
|
539
|
+
/** The WhatsApp number it was sent from. Absent when nothing was sent. */
|
|
540
|
+
from?: string;
|
|
541
|
+
}
|
|
542
|
+
/** The body of "Send a template by name". */
|
|
543
|
+
export interface SendWhatsappTemplateParams {
|
|
544
|
+
/** The customer's phone number with its country code, digits only, at least 8. */
|
|
545
|
+
phoneNumber: string;
|
|
546
|
+
/** The template's exact name. */
|
|
547
|
+
templateName: string;
|
|
548
|
+
/** Values for the body's variables. A template with a variable or media in its header, a dynamic URL button or a copy code button takes `templateComponents` instead. Keys other than `parameter_name` and `text` are ignored. */
|
|
549
|
+
templateParams?: WhatsappTemplateParam[] | undefined;
|
|
550
|
+
/** The translation to send, such as `en_US`. Without it, the oldest approved template with this name, in its own language. If Chatwise doesn't have the translation, it asks WhatsApp to send the oldest one in this language. Spaces around it are ignored. */
|
|
551
|
+
templateLanguage?: string | undefined;
|
|
552
|
+
/** Values for the header, body and buttons, up to 12 components. Used instead of `templateParams`, except for authentication templates. At most one header and one body, and no two buttons with the same `subType` and `index`. */
|
|
553
|
+
templateComponents?: (WhatsappTemplateComponent)[] | undefined;
|
|
554
|
+
/** The connected WhatsApp number to send from, digits only. Without it: the number on the template's WhatsApp Business Account the customer last wrote to, else the oldest number there. */
|
|
555
|
+
from?: string | undefined;
|
|
556
|
+
}
|
|
557
|
+
/** What "Send a template by name" answers. */
|
|
558
|
+
export interface SendWhatsappTemplateResult {
|
|
559
|
+
/** A confirmation. */
|
|
560
|
+
message: string;
|
|
561
|
+
/** The WhatsApp number it was sent from. */
|
|
562
|
+
from: string;
|
|
563
|
+
}
|
|
564
|
+
/** The filters of "List WhatsApp templates". */
|
|
565
|
+
export interface ListWhatsappTemplatesParams {
|
|
566
|
+
/**
|
|
567
|
+
* How many to return, from 1 to 100.
|
|
568
|
+
* @defaultValue 50
|
|
569
|
+
*/
|
|
570
|
+
limit?: number | undefined;
|
|
571
|
+
/** The previous page's `pagination.nextCursor`. Repeat the same filters and order with it. */
|
|
572
|
+
cursor?: string | undefined;
|
|
573
|
+
/** Text in the template's name, in any case. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
574
|
+
q?: string | undefined;
|
|
575
|
+
/** The exact name, in any case. Finds every translation of a template. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
576
|
+
name?: string | undefined;
|
|
577
|
+
/** The language code, such as `en_US`. Spaces around it are ignored. */
|
|
578
|
+
language?: string | undefined;
|
|
579
|
+
/** Only templates in this category. */
|
|
580
|
+
category?: WhatsappTemplateCategory | undefined;
|
|
581
|
+
/** Meta's review status, such as `APPROVED` or `PENDING`, in any case. Spaces around it are ignored. */
|
|
582
|
+
status?: string | undefined;
|
|
583
|
+
/** `true` for templates the send routes can send, `false` for the others. Leave out for both. */
|
|
584
|
+
sendable?: boolean | undefined;
|
|
585
|
+
}
|
|
586
|
+
/** The body of "Create a WhatsApp template". */
|
|
587
|
+
export type CreateWhatsappTemplateParams = {
|
|
588
|
+
/** Lowercase letters, digits and underscores, up to 100 characters. Spaces around it are ignored. */
|
|
589
|
+
name: string;
|
|
590
|
+
/** The language code, such as `en_US`. Each translation is a template of its own. Spaces around it are ignored. */
|
|
591
|
+
language: string;
|
|
592
|
+
/** `UTILITY`, `MARKETING` or `AUTHENTICATION`. */
|
|
593
|
+
category: 'UTILITY' | 'MARKETING';
|
|
594
|
+
/**
|
|
595
|
+
* How variables are written: `NAMED` (`{{order_number}}`) or `POSITIONAL` (`{{1}}`).
|
|
596
|
+
* @defaultValue 'NAMED'
|
|
597
|
+
*/
|
|
598
|
+
parameterFormat?: 'NAMED' | 'POSITIONAL' | undefined;
|
|
599
|
+
/** What the template contains. */
|
|
600
|
+
components: {
|
|
601
|
+
/** A text header, or a media header with a sample. */
|
|
602
|
+
header?: {
|
|
603
|
+
/** The header's kind. */
|
|
604
|
+
format: 'TEXT';
|
|
605
|
+
/** The text, with at most one variable, which can't be at its start or end. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
606
|
+
text: string;
|
|
607
|
+
/** A sample value for the variable, by its name or number. */
|
|
608
|
+
examples?: Record<string, string> | undefined;
|
|
609
|
+
} | {
|
|
610
|
+
/** The header's kind. */
|
|
611
|
+
format: 'IMAGE' | 'VIDEO' | 'DOCUMENT';
|
|
612
|
+
/** Meta's handle for a sample file. This API can't create one. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
613
|
+
exampleMediaHandle: string;
|
|
614
|
+
} | undefined;
|
|
615
|
+
/** The message. */
|
|
616
|
+
body: {
|
|
617
|
+
/** The text. Variables must be inside it, not at its start or end. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
618
|
+
text: string;
|
|
619
|
+
/** A sample value for each variable, by its name or number. */
|
|
620
|
+
examples?: Record<string, string> | undefined;
|
|
621
|
+
};
|
|
622
|
+
/** Fixed text below the body. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
623
|
+
footer?: string | undefined;
|
|
624
|
+
/** Up to 10 buttons. */
|
|
625
|
+
buttons?: ({
|
|
626
|
+
/** The button's kind. */
|
|
627
|
+
type: 'QUICK_REPLY';
|
|
628
|
+
/** The button's label. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
629
|
+
text: string;
|
|
630
|
+
} | {
|
|
631
|
+
/** The button's kind. */
|
|
632
|
+
type: 'PHONE_NUMBER';
|
|
633
|
+
/** The button's label. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
634
|
+
text: string;
|
|
635
|
+
/** The number to call: 8 to 15 digits, with or without a `+`. */
|
|
636
|
+
phoneNumber: string;
|
|
637
|
+
} | {
|
|
638
|
+
/** The button's kind. */
|
|
639
|
+
type: 'URL';
|
|
640
|
+
/** The button's label. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
641
|
+
text: string;
|
|
642
|
+
/** The page to open. It may end with one variable. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
643
|
+
url: string;
|
|
644
|
+
/** A complete sample URL, when the URL has a variable. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates. */
|
|
645
|
+
exampleUrl?: string | undefined;
|
|
646
|
+
})[] | undefined;
|
|
647
|
+
};
|
|
648
|
+
} | {
|
|
649
|
+
/** Lowercase letters, digits and underscores, up to 100 characters. Spaces around it are ignored. */
|
|
650
|
+
name: string;
|
|
651
|
+
/** The language code, such as `en_US`. Each translation is a template of its own. Spaces around it are ignored. */
|
|
652
|
+
language: string;
|
|
653
|
+
/** `UTILITY`, `MARKETING` or `AUTHENTICATION`. */
|
|
654
|
+
category: 'AUTHENTICATION';
|
|
655
|
+
/** Settings of an authentication template. Its text and copy code button are WhatsApp's own. */
|
|
656
|
+
authentication: {
|
|
657
|
+
/** How long the code is valid, from 1 to 90. */
|
|
658
|
+
codeExpirationMinutes: number;
|
|
659
|
+
/**
|
|
660
|
+
* Whether to tell the customer not to share the code.
|
|
661
|
+
* @defaultValue false
|
|
662
|
+
*/
|
|
663
|
+
addSecurityRecommendation?: boolean | undefined;
|
|
664
|
+
/**
|
|
665
|
+
* The copy button's label. Spaces around it are ignored. Can't be blank, or contain NUL characters or unpaired surrogates.
|
|
666
|
+
* @defaultValue 'Copy Code'
|
|
667
|
+
*/
|
|
668
|
+
buttonText?: string | undefined;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
/** The body of "Create a webhook endpoint". */
|
|
672
|
+
export interface CreateWebhookEndpointParams {
|
|
673
|
+
/** A name for the endpoint, 1 to 80 characters. Spaces around it are ignored. Can't be blank, or contain control characters or unpaired surrogates. */
|
|
674
|
+
name: string;
|
|
675
|
+
/** Where to send events: a public `https://` URL on port 443, without a username, password or `#fragment`. Spaces around it are ignored. */
|
|
676
|
+
url: string;
|
|
677
|
+
/** The events to receive. `message.*` events also need the `messages:read` scope. */
|
|
678
|
+
events: WebhookEventType[];
|
|
679
|
+
/** Only send events for these accounts. Leave out, or send an empty list, for every account. */
|
|
680
|
+
accountIds?: string[] | undefined;
|
|
681
|
+
}
|
|
682
|
+
/** What "Create a webhook endpoint" answers. */
|
|
683
|
+
export interface WebhookEndpointWithSecret {
|
|
684
|
+
/** The endpoint's id. */
|
|
685
|
+
id: string;
|
|
686
|
+
/** The endpoint's name. */
|
|
687
|
+
name: string;
|
|
688
|
+
/** Where events are sent. */
|
|
689
|
+
url: string;
|
|
690
|
+
/** The events it receives. */
|
|
691
|
+
events: WebhookEventType[];
|
|
692
|
+
/** The accounts it receives events for. Empty means every account. */
|
|
693
|
+
accountIds: string[];
|
|
694
|
+
/** `ACTIVE`, `PAUSED` by the workspace, or `DISABLED` by Chatwise (see `health.disabledReason`). */
|
|
695
|
+
status: Open<WebhookEndpointStatus>;
|
|
696
|
+
/** The payload format it receives, as a date. */
|
|
697
|
+
apiVersion: string;
|
|
698
|
+
/** How its deliveries are going. */
|
|
699
|
+
health: {
|
|
700
|
+
/** When an attempt last succeeded. ISO 8601, in UTC. */
|
|
701
|
+
lastSuccessAt: string | null;
|
|
702
|
+
/** When an attempt last failed. ISO 8601, in UTC. */
|
|
703
|
+
lastFailureAt: string | null;
|
|
704
|
+
/** Failed attempts since the last success. */
|
|
705
|
+
consecutiveFailures: number;
|
|
706
|
+
/** When Chatwise disabled it. ISO 8601, in UTC. */
|
|
707
|
+
disabledAt: string | null;
|
|
708
|
+
/** Why Chatwise disabled it. */
|
|
709
|
+
disabledReason: string | null;
|
|
710
|
+
/** Until when Chatwise sends it nothing, because it is unavailable. Null when it isn't waiting. ISO 8601, in UTC. */
|
|
711
|
+
backoffUntil: string | null;
|
|
712
|
+
};
|
|
713
|
+
/** When it was created. ISO 8601, in UTC. */
|
|
714
|
+
createdAt: string;
|
|
715
|
+
/** When it, or its health, last changed. ISO 8601, in UTC. */
|
|
716
|
+
updatedAt: string;
|
|
717
|
+
/** The secret that signs its deliveries: `whsec_` and 32 random bytes in base64. Shown only here; store it safely. */
|
|
718
|
+
signingSecret: string;
|
|
719
|
+
}
|
|
720
|
+
/** The body of "Update a webhook endpoint". */
|
|
721
|
+
export interface UpdateWebhookEndpointParams {
|
|
722
|
+
/** A name for the endpoint, 1 to 80 characters. Spaces around it are ignored. Can't be blank, or contain control characters or unpaired surrogates. */
|
|
723
|
+
name?: string | undefined;
|
|
724
|
+
/** Where to send events: a public `https://` URL on port 443, without a username, password or `#fragment`. Spaces around it are ignored. */
|
|
725
|
+
url?: string | undefined;
|
|
726
|
+
/** The events to receive. `message.*` events also need the `messages:read` scope. */
|
|
727
|
+
events?: WebhookEventType[] | undefined;
|
|
728
|
+
/** The accounts to send events for, instead of the ones it has. An empty list means every account. Leave out to keep them. */
|
|
729
|
+
accountIds?: string[] | undefined;
|
|
730
|
+
/** `PAUSED` to stop deliveries, `ACTIVE` to resume them. */
|
|
731
|
+
status?: 'ACTIVE' | 'PAUSED' | undefined;
|
|
732
|
+
}
|
|
733
|
+
/** What "Delete a webhook endpoint" answers. */
|
|
734
|
+
export interface DeleteWebhookEndpointResult {
|
|
735
|
+
/** The deleted endpoint's id. */
|
|
736
|
+
id: string;
|
|
737
|
+
deleted: true;
|
|
738
|
+
}
|
|
739
|
+
/** What "Send a test event" answers. */
|
|
740
|
+
export interface TestWebhookEndpointResult {
|
|
741
|
+
/** Whether your endpoint answered with a 2xx status. */
|
|
742
|
+
delivered: boolean;
|
|
743
|
+
/** The HTTP status it answered, if it did. */
|
|
744
|
+
statusCode: number | null;
|
|
745
|
+
/** How long it took, in milliseconds. */
|
|
746
|
+
durationMs: number;
|
|
747
|
+
/** Why it failed, such as `http_500` or `timeout`. */
|
|
748
|
+
error: string | null;
|
|
749
|
+
}
|
|
750
|
+
/** What "Rotate the signing secret" answers. */
|
|
751
|
+
export interface RotateWebhookSecretResult {
|
|
752
|
+
/** The secret that signs its deliveries: `whsec_` and 32 random bytes in base64. Shown only here; store it safely. */
|
|
753
|
+
signingSecret: string;
|
|
754
|
+
/** Until when deliveries are signed with the previous secret too. ISO 8601, in UTC. */
|
|
755
|
+
previousSecretExpiresAt: string;
|
|
756
|
+
}
|
|
757
|
+
/** The filters of "List deliveries". */
|
|
758
|
+
export interface ListWebhookDeliveriesParams {
|
|
759
|
+
/**
|
|
760
|
+
* How many to return, from 1 to 100.
|
|
761
|
+
* @defaultValue 50
|
|
762
|
+
*/
|
|
763
|
+
limit?: number | undefined;
|
|
764
|
+
/** The previous page's `pagination.nextCursor`. Repeat the same filters and order with it. */
|
|
765
|
+
cursor?: string | undefined;
|
|
766
|
+
/** Only deliveries with this status. */
|
|
767
|
+
status?: WebhookDeliveryStatus | undefined;
|
|
768
|
+
/** Only deliveries of this event. */
|
|
769
|
+
eventType?: WebhookEventType | undefined;
|
|
770
|
+
}
|
|
771
|
+
/** What "List event types" answers. */
|
|
772
|
+
export interface WebhookEventTypeInfo {
|
|
773
|
+
/** The event's name. */
|
|
774
|
+
type: WebhookEventType;
|
|
775
|
+
/** When it happens. */
|
|
776
|
+
description: string;
|
|
777
|
+
/** The channels it covers. */
|
|
778
|
+
channels: Open<Channel>[];
|
|
779
|
+
}
|
|
780
|
+
/** The `data` of `message.received`, `message.sent`, `message.delivered`, `message.read`. */
|
|
781
|
+
export interface MessageEventData {
|
|
782
|
+
/** The message, as the API returns it. */
|
|
783
|
+
message: Message;
|
|
784
|
+
/** Its conversation, as the API returns it. */
|
|
785
|
+
conversation: Conversation;
|
|
786
|
+
/** The account the conversation is on, such as a WhatsApp number or an Instagram account. */
|
|
787
|
+
account: {
|
|
788
|
+
/** The account's id. The same as in `accountIds`. */
|
|
789
|
+
id: string;
|
|
790
|
+
/** The account's channel. */
|
|
791
|
+
channel: Open<Channel>;
|
|
792
|
+
} | null;
|
|
793
|
+
}
|
|
794
|
+
/** The `data` of `message.failed`. */
|
|
795
|
+
export interface MessageFailedEventData {
|
|
796
|
+
/** The message, as the API returns it. */
|
|
797
|
+
message: Message;
|
|
798
|
+
/** Its conversation, as the API returns it. */
|
|
799
|
+
conversation: Conversation;
|
|
800
|
+
/** The account the conversation is on, such as a WhatsApp number or an Instagram account. */
|
|
801
|
+
account: {
|
|
802
|
+
/** The account's id. The same as in `accountIds`. */
|
|
803
|
+
id: string;
|
|
804
|
+
/** The account's channel. */
|
|
805
|
+
channel: Open<Channel>;
|
|
806
|
+
} | null;
|
|
807
|
+
/** Why it couldn't be delivered, as the channel reported it. Null when it gave no reason. */
|
|
808
|
+
error: {
|
|
809
|
+
/** The channel's error code, such as `131026` on WhatsApp. */
|
|
810
|
+
code: string | null;
|
|
811
|
+
/** What the channel calls the error. */
|
|
812
|
+
title: string | null;
|
|
813
|
+
/** What the channel says about it. */
|
|
814
|
+
details: string | null;
|
|
815
|
+
} | null;
|
|
816
|
+
}
|
|
817
|
+
/** The `data` of `comment.received`. */
|
|
818
|
+
export interface CommentReceivedEventData {
|
|
819
|
+
/** The comment. */
|
|
820
|
+
comment: {
|
|
821
|
+
/** The comment's id on Instagram. */
|
|
822
|
+
id: string;
|
|
823
|
+
/** The comment. Empty for one without text, such as a GIF. */
|
|
824
|
+
text: string;
|
|
825
|
+
/** The comment this one replies to. Null for a comment on the post itself. */
|
|
826
|
+
parentCommentId: string | null;
|
|
827
|
+
/** Who wrote it. */
|
|
828
|
+
author: {
|
|
829
|
+
/** The commenter's id on Instagram. */
|
|
830
|
+
id: string;
|
|
831
|
+
/** The commenter's username, when Instagram gives it. */
|
|
832
|
+
username: string | null;
|
|
833
|
+
};
|
|
834
|
+
/** When it was written, or when it reached Chatwise if Instagram doesn't say. ISO 8601, in UTC. */
|
|
835
|
+
createdAt: string;
|
|
836
|
+
};
|
|
837
|
+
/** The post it is on. */
|
|
838
|
+
post: {
|
|
839
|
+
/** The post's id on Instagram. */
|
|
840
|
+
id: string;
|
|
841
|
+
/** `IMAGE`, `VIDEO` or `CAROUSEL_ALBUM`. */
|
|
842
|
+
type: string;
|
|
843
|
+
/** The post's caption, if any. */
|
|
844
|
+
caption: string | null;
|
|
845
|
+
};
|
|
846
|
+
/** The Instagram account whose post it is. */
|
|
847
|
+
account: {
|
|
848
|
+
/** The account's id. The same as in `accountIds`. */
|
|
849
|
+
id: string;
|
|
850
|
+
/** Always `INSTAGRAM`. */
|
|
851
|
+
channel: 'INSTAGRAM';
|
|
852
|
+
} | null;
|
|
853
|
+
}
|
|
854
|
+
/** The `data` of `webhook.test`. */
|
|
855
|
+
export interface WebhookTestEventData {
|
|
856
|
+
/** The endpoint the test was sent to. */
|
|
857
|
+
endpointId: string;
|
|
858
|
+
/** A fixed sentence. */
|
|
859
|
+
message: string;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* A customer sent a message.
|
|
863
|
+
*
|
|
864
|
+
* Sent when a live message from a customer is saved, on any connected WhatsApp number, Instagram account, Messenger Page or Website Chat site.
|
|
865
|
+
*
|
|
866
|
+
* Not sent for reactions, edits, system messages or imported history, or when the message was deleted or hidden before the event was prepared.
|
|
867
|
+
*
|
|
868
|
+
* `data` is the message and conversation as they were when the event was prepared, after the message was saved. Every retry and redelivery sends the same.
|
|
869
|
+
*/
|
|
870
|
+
export interface MessageReceivedEvent {
|
|
871
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
872
|
+
id: string;
|
|
873
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
874
|
+
type: 'message.received';
|
|
875
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
876
|
+
timestamp: string;
|
|
877
|
+
/** The payload format, as a date. */
|
|
878
|
+
apiVersion: string;
|
|
879
|
+
/** The workspace the event happened in. */
|
|
880
|
+
workspaceId: string;
|
|
881
|
+
/** What happened. */
|
|
882
|
+
data: MessageEventData;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* The workspace sent a message: from the dashboard, the mobile app, the API, MCP, a flow, Comment to DM, Website Chat's AI agent, or the native WhatsApp Business, Instagram or Messenger app.
|
|
886
|
+
*
|
|
887
|
+
* Sent when a message from the workspace is saved: after the channel accepted it, or when the channel reports a message sent in its own app. On WhatsApp that needs a number that is also used in the WhatsApp Business app.
|
|
888
|
+
*
|
|
889
|
+
* It says the channel accepted the message, not that it arrived: see message.delivered and message.failed. A send the channel refuses makes no event.
|
|
890
|
+
*
|
|
891
|
+
* Not sent for reactions, edits, system messages or imported history, or when the message was deleted or hidden before the event was prepared. `text` is null for WhatsApp authentication templates.
|
|
892
|
+
*/
|
|
893
|
+
export interface MessageSentEvent {
|
|
894
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
895
|
+
id: string;
|
|
896
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
897
|
+
type: 'message.sent';
|
|
898
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
899
|
+
timestamp: string;
|
|
900
|
+
/** The payload format, as a date. */
|
|
901
|
+
apiVersion: string;
|
|
902
|
+
/** The workspace the event happened in. */
|
|
903
|
+
workspaceId: string;
|
|
904
|
+
/** What happened. */
|
|
905
|
+
data: MessageEventData;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* The channel reported an outgoing message was delivered.
|
|
909
|
+
*
|
|
910
|
+
* Sent once for each message the workspace sent, when the channel first reports it. `timestamp` is when that happened. The statuses of a message can arrive in any order, and some never do.
|
|
911
|
+
*
|
|
912
|
+
* Some channels report everything up to a point at once. Each message it covers makes an event, if it was sent in the 7 days before.
|
|
913
|
+
*/
|
|
914
|
+
export interface MessageDeliveredEvent {
|
|
915
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
916
|
+
id: string;
|
|
917
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
918
|
+
type: 'message.delivered';
|
|
919
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
920
|
+
timestamp: string;
|
|
921
|
+
/** The payload format, as a date. */
|
|
922
|
+
apiVersion: string;
|
|
923
|
+
/** The workspace the event happened in. */
|
|
924
|
+
workspaceId: string;
|
|
925
|
+
/** What happened. */
|
|
926
|
+
data: MessageEventData;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* The channel reported the customer read an outgoing message.
|
|
930
|
+
*
|
|
931
|
+
* Sent once for each message the workspace sent, when the channel first reports it. `timestamp` is when that happened. The statuses of a message can arrive in any order, and some never do.
|
|
932
|
+
*
|
|
933
|
+
* Some channels report everything up to a point at once. Each message it covers makes an event, if it was sent in the 7 days before.
|
|
934
|
+
*
|
|
935
|
+
* Channels report a message read only when the customer's settings allow it. On WhatsApp, read receipts can be off.
|
|
936
|
+
*/
|
|
937
|
+
export interface MessageReadEvent {
|
|
938
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
939
|
+
id: string;
|
|
940
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
941
|
+
type: 'message.read';
|
|
942
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
943
|
+
timestamp: string;
|
|
944
|
+
/** The payload format, as a date. */
|
|
945
|
+
apiVersion: string;
|
|
946
|
+
/** The workspace the event happened in. */
|
|
947
|
+
workspaceId: string;
|
|
948
|
+
/** What happened. */
|
|
949
|
+
data: MessageEventData;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* The channel reported an outgoing message could not be delivered.
|
|
953
|
+
*
|
|
954
|
+
* Sent once for each message the workspace sent, when the channel first reports it. `timestamp` is when that happened. The statuses of a message can arrive in any order, and some never do.
|
|
955
|
+
*
|
|
956
|
+
* `error` is what WhatsApp reported. Its codes are in [Meta's documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes).
|
|
957
|
+
*
|
|
958
|
+
* A send the channel refuses outright makes no event: the request that sent it fails instead.
|
|
959
|
+
*/
|
|
960
|
+
export interface MessageFailedEvent {
|
|
961
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
962
|
+
id: string;
|
|
963
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
964
|
+
type: 'message.failed';
|
|
965
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
966
|
+
timestamp: string;
|
|
967
|
+
/** The payload format, as a date. */
|
|
968
|
+
apiVersion: string;
|
|
969
|
+
/** The workspace the event happened in. */
|
|
970
|
+
workspaceId: string;
|
|
971
|
+
/** What happened. */
|
|
972
|
+
data: MessageFailedEventData;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Someone commented on a post of a connected Instagram account.
|
|
976
|
+
*
|
|
977
|
+
* Sent for each comment, and each reply to a comment, on a connected Instagram account's posts and reels. Not for what the account itself writes, nor for imported comments.
|
|
978
|
+
*
|
|
979
|
+
* Not sent when the comment was hidden before the event was prepared. An edit makes no event, unless the comment was first stored in the 10 minutes before. Chatwise isn't told of deletions.
|
|
980
|
+
*/
|
|
981
|
+
export interface CommentReceivedEvent {
|
|
982
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
983
|
+
id: string;
|
|
984
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
985
|
+
type: 'comment.received';
|
|
986
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
987
|
+
timestamp: string;
|
|
988
|
+
/** The payload format, as a date. */
|
|
989
|
+
apiVersion: string;
|
|
990
|
+
/** The workspace the event happened in. */
|
|
991
|
+
workspaceId: string;
|
|
992
|
+
/** What happened. */
|
|
993
|
+
data: CommentReceivedEventData;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* You sent a test event, from the dashboard or with the API.
|
|
997
|
+
*
|
|
998
|
+
* Sent when someone sends a test from the dashboard or calls Send a test event, also to a paused endpoint. Endpoints don't subscribe to it.
|
|
999
|
+
*
|
|
1000
|
+
* It is signed like every event. It is sent once: it isn't retried, and it isn't in the delivery log. Its `X-Chatwise-Delivery` header is always `wd_test`.
|
|
1001
|
+
*/
|
|
1002
|
+
export interface WebhookTestEvent {
|
|
1003
|
+
/** The event's id, the same on every retry and redelivery. Also the `webhook-id` header. */
|
|
1004
|
+
id: string;
|
|
1005
|
+
/** The event's name. Also the `X-Chatwise-Event` header. */
|
|
1006
|
+
type: 'webhook.test';
|
|
1007
|
+
/** When the event happened. The same on every retry. ISO 8601, in UTC. */
|
|
1008
|
+
timestamp: string;
|
|
1009
|
+
/** The payload format, as a date. */
|
|
1010
|
+
apiVersion: string;
|
|
1011
|
+
/** The workspace the event happened in. */
|
|
1012
|
+
workspaceId: string;
|
|
1013
|
+
/** What happened. */
|
|
1014
|
+
data: WebhookTestEventData;
|
|
1015
|
+
}
|
|
1016
|
+
/** Every event this version knows. */
|
|
1017
|
+
export type KnownWebhookEvent = MessageReceivedEvent | MessageSentEvent | MessageDeliveredEvent | MessageReadEvent | MessageFailedEvent | CommentReceivedEvent | WebhookTestEvent;
|