meta-cloud-api 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ declare enum MessageTypesEnum {
36
36
  Button = "button",
37
37
  Order = "order",
38
38
  System = "system",
39
+ Unsupported = "unsupported",
39
40
  Unknown = "unknown",
40
41
  Statuses = "statuses",
41
42
  '*' = "*",
@@ -786,6 +787,17 @@ interface Paging {
786
787
  };
787
788
  next: string;
788
789
  }
790
+ /**
791
+ * Common error detail structure used in Meta API responses
792
+ * Used for individual item errors in bulk operations
793
+ */
794
+ interface MetaErrorDetail {
795
+ message: string;
796
+ code: string;
797
+ error_data?: {
798
+ details: string;
799
+ };
800
+ }
789
801
  declare class RequesterClass {
790
802
  constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
791
803
  sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
@@ -851,6 +863,196 @@ declare class BaseAPI implements BaseClass {
851
863
  protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
852
864
  }
853
865
  //#endregion
866
+ //#region src/api/blockUsers/types/blockUsers.d.ts
867
+ /**
868
+ * Block Users API Types
869
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
870
+ */
871
+ /**
872
+ * User object for blocking/unblocking operations
873
+ */
874
+ type BlockUserObject = {
875
+ user: string;
876
+ };
877
+ /**
878
+ * Blocked user information in response
879
+ */
880
+ type BlockedUserInfo = {
881
+ input: string;
882
+ wa_id: string;
883
+ };
884
+ /**
885
+ * Failed user information with error details
886
+ * Uses common MetaErrorDetail type for consistency across APIs
887
+ */
888
+ type FailedUserInfo = BlockedUserInfo & {
889
+ errors?: MetaErrorDetail[];
890
+ };
891
+ /**
892
+ * Request body for blocking users
893
+ */
894
+ type BlockUsersRequest = {
895
+ messaging_product: 'whatsapp';
896
+ block_users: BlockUserObject[];
897
+ };
898
+ /**
899
+ * Request body for unblocking users
900
+ */
901
+ type UnblockUsersRequest = {
902
+ messaging_product: 'whatsapp';
903
+ block_users: BlockUserObject[];
904
+ };
905
+ /**
906
+ * Response for block/unblock operations
907
+ */
908
+ type BlockUsersResponse = {
909
+ messaging_product: 'whatsapp';
910
+ block_users: {
911
+ added_users?: BlockedUserInfo[];
912
+ failed_users?: FailedUserInfo[];
913
+ };
914
+ };
915
+ /**
916
+ * Pagination cursors for list operations
917
+ */
918
+ type PagingCursors = {
919
+ after?: string;
920
+ before?: string;
921
+ };
922
+ /**
923
+ * Pagination information
924
+ */
925
+ type PagingInfo = {
926
+ cursors?: PagingCursors;
927
+ previous?: string;
928
+ next?: string;
929
+ };
930
+ /**
931
+ * List blocked users response
932
+ */
933
+ type ListBlockedUsersResponse = {
934
+ data: Array<{
935
+ block_users: BlockedUserInfo[];
936
+ }>;
937
+ paging?: PagingInfo;
938
+ };
939
+ /**
940
+ * Query parameters for listing blocked users
941
+ */
942
+ type ListBlockedUsersParams = {
943
+ limit?: number;
944
+ after?: string;
945
+ before?: string;
946
+ };
947
+ /**
948
+ * Block Users API Interface
949
+ */
950
+ interface BlockUsersClass {
951
+ /**
952
+ * Block one or more WhatsApp users
953
+ * @param users - Array of phone numbers or WhatsApp IDs to block
954
+ * @returns Response with successfully blocked and failed users
955
+ * @throws Error if users have not messaged in last 24 hours
956
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
957
+ */
958
+ block(users: string[]): Promise<BlockUsersResponse>;
959
+ /**
960
+ * Unblock one or more WhatsApp users
961
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
962
+ * @returns Response with successfully unblocked and failed users
963
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
964
+ */
965
+ unblock(users: string[]): Promise<BlockUsersResponse>;
966
+ /**
967
+ * Get list of blocked WhatsApp users with pagination
968
+ * @param params - Optional pagination parameters
969
+ * @returns List of blocked users with pagination info
970
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
971
+ */
972
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
973
+ }
974
+ //#endregion
975
+ //#region src/api/blockUsers/BlockUsersApi.d.ts
976
+ /**
977
+ * Block Users API
978
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
979
+ *
980
+ * Limitations:
981
+ * - Can only block users that have messaged your business in the last 24 hours
982
+ * - 64k blocklist limit
983
+ */
984
+ declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
985
+ private readonly endpoint;
986
+ constructor(config: WabaConfigType, client: RequesterClass);
987
+ /**
988
+ * Build request body for block/unblock operations
989
+ */
990
+ private buildBlockUsersBody;
991
+ /**
992
+ * Block one or more WhatsApp users
993
+ * @param users - Array of phone numbers or WhatsApp IDs to block
994
+ * @returns Response with successfully blocked and failed users
995
+ * @throws Error if users have not messaged in last 24 hours
996
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * // Block single user
1001
+ * const result = await client.blockUsers.block(['1234567890']);
1002
+ *
1003
+ * // Block multiple users
1004
+ * const result = await client.blockUsers.block(['1234567890', '0987654321']);
1005
+ *
1006
+ * // Check results
1007
+ * console.log('Blocked:', result.block_users.added_users);
1008
+ * console.log('Failed:', result.block_users.failed_users);
1009
+ * ```
1010
+ */
1011
+ block(users: string[]): Promise<BlockUsersResponse>;
1012
+ /**
1013
+ * Unblock one or more WhatsApp users
1014
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
1015
+ * @returns Response with successfully unblocked and failed users
1016
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
1017
+ *
1018
+ * @example
1019
+ * ```typescript
1020
+ * // Unblock single user
1021
+ * const result = await client.blockUsers.unblock(['1234567890']);
1022
+ *
1023
+ * // Unblock multiple users
1024
+ * const result = await client.blockUsers.unblock(['1234567890', '0987654321']);
1025
+ *
1026
+ * // Check results
1027
+ * console.log('Unblocked:', result.block_users.added_users);
1028
+ * console.log('Failed:', result.block_users.failed_users);
1029
+ * ```
1030
+ */
1031
+ unblock(users: string[]): Promise<BlockUsersResponse>;
1032
+ /**
1033
+ * Get list of blocked WhatsApp users with pagination
1034
+ * @param params - Optional pagination parameters
1035
+ * @returns List of blocked users with pagination info
1036
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
1037
+ *
1038
+ * @example
1039
+ * ```typescript
1040
+ * // Get first 10 blocked users
1041
+ * const result = await client.blockUsers.listBlockedUsers({ limit: 10 });
1042
+ *
1043
+ * // Pagination with cursor
1044
+ * const nextPage = await client.blockUsers.listBlockedUsers({
1045
+ * limit: 10,
1046
+ * after: result.paging?.cursors?.after
1047
+ * });
1048
+ *
1049
+ * // Get all blocked users
1050
+ * const allBlocked = await client.blockUsers.listBlockedUsers();
1051
+ * ```
1052
+ */
1053
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
1054
+ }
1055
+ //#endregion
854
1056
  //#region src/api/encryption/types/publicKey.d.ts
855
1057
  type EncryptionPublicKeyResponse = ResponseData<{
856
1058
  business_public_key: string;
@@ -872,513 +1074,348 @@ declare class EncryptionApi extends BaseAPI implements EncryptionClass {
872
1074
  }
873
1075
  //#endregion
874
1076
  //#region src/core/webhook/types.d.ts
1077
+ /**
1078
+ * WhatsApp contact information
1079
+ */
875
1080
  interface WebhookContact {
876
- /**
877
- * WhatsApp ID of the contact. Business can respond to this contact using this ID.
878
- */
879
1081
  wa_id: string;
880
- /**
881
- * Additional unique, alphanumeric identifier for a WhatsApp user
882
- */
883
- user_id?: string;
884
- /**
885
- * Profile of Whatsapp user
886
- */
887
1082
  profile: {
888
- /**
889
- * The display name of the contact
890
- */
891
1083
  name: string;
892
1084
  };
1085
+ identity_key_hash?: string;
893
1086
  }
894
1087
  /**
895
- * Base message interface with common properties
1088
+ * Metadata included in all webhooks
896
1089
  */
897
- interface BaseMessage {
898
- id: string;
1090
+ interface WebhookMetadata {
1091
+ display_phone_number: string;
1092
+ phone_number_id: string;
1093
+ }
1094
+ /**
1095
+ * Error object structure
1096
+ */
1097
+ interface WebhookError {
1098
+ code: number;
1099
+ title: string;
1100
+ message: string;
1101
+ error_data?: {
1102
+ details: string;
1103
+ };
1104
+ href?: string;
1105
+ }
1106
+ /**
1107
+ * Click to WhatsApp ad referral information
1108
+ */
1109
+ interface ReferralInfo {
1110
+ source_url: string;
1111
+ source_id: string;
1112
+ source_type: 'ad';
1113
+ body?: string;
1114
+ headline?: string;
1115
+ media_type?: 'image' | 'video';
1116
+ image_url?: string;
1117
+ video_url?: string;
1118
+ thumbnail_url?: string;
1119
+ ctwa_clid?: string;
1120
+ welcome_message?: {
1121
+ text: string;
1122
+ };
1123
+ }
1124
+ /**
1125
+ * Context for forwarded messages
1126
+ */
1127
+ interface ForwardedContext {
1128
+ forwarded?: true;
1129
+ frequently_forwarded?: true;
1130
+ }
1131
+ /**
1132
+ * Context for product inquiry messages
1133
+ */
1134
+ interface ProductContext {
899
1135
  from: string;
900
- timestamp: string;
901
- type: MessageTypesEnum;
902
- /**
903
- * Context object, included when a user replies or interacts
904
- */
905
- context?: {
906
- /**
907
- * ID of the message
908
- */
909
- id?: string;
910
- /**
911
- * ID of the sender
912
- */
913
- from?: string;
914
- /**
915
- * ID of the message being replied to or interacted with
916
- */
917
- message_id: string;
918
- /**
919
- * ID of the forwarded message, if applicable
920
- */
921
- forwarded?: boolean;
922
- /**
923
- * Frequently forwarded status
924
- */
925
- frequently_forwarded?: boolean;
926
- /**
927
- * Original message information if the message was referred
928
- */
929
- referred_product?: {
930
- /**
931
- * Catalog ID
932
- */
933
- catalog_id: string;
934
- /**
935
- * Product ID
936
- */
937
- product_retailer_id: string;
938
- };
1136
+ id: string;
1137
+ referred_product: {
1138
+ catalog_id: string;
1139
+ product_retailer_id: string;
939
1140
  };
940
- /**
941
- * Errors array, if the message had errors
942
- */
943
- errors?: Array<{
944
- /**
945
- * Error code
946
- */
947
- code: number;
948
- /**
949
- * Error title
950
- */
951
- title: string;
952
- /**
953
- * Error message
954
- */
955
- message: string;
956
- /**
957
- * Error details object
958
- */
959
- error_data?: {
960
- /**
961
- * Describes the error details
962
- */
963
- details: string;
964
- };
965
- }>;
966
1141
  }
967
1142
  /**
968
- * Text message interface
1143
+ * Context for interactive/button replies
1144
+ */
1145
+ interface ReplyContext {
1146
+ from: string;
1147
+ id: string;
1148
+ }
1149
+ /**
1150
+ * Base message properties common to all message types
969
1151
  */
1152
+ interface BaseMessage {
1153
+ from: string;
1154
+ id: string;
1155
+ timestamp: string;
1156
+ }
970
1157
  interface TextMessage extends BaseMessage {
971
1158
  type: MessageTypesEnum.Text;
972
1159
  text: {
973
- /**
974
- * The text content of the message
975
- */
976
1160
  body: string;
977
- preview_url?: boolean;
978
1161
  };
1162
+ context?: ForwardedContext | ProductContext;
1163
+ referral?: ReferralInfo;
979
1164
  }
980
- /**
981
- * Image message interface
982
- */
983
1165
  interface ImageMessage extends BaseMessage {
984
1166
  type: MessageTypesEnum.Image;
985
1167
  image: {
986
- /**
987
- * The image caption (if provided)
988
- */
989
1168
  caption?: string;
990
- /**
991
- * The SHA256 hash of the image
992
- */
993
- sha256?: string;
994
- /**
995
- * The ID for the image
996
- */
997
- id: string;
998
- /**
999
- * The MIME type of the image
1000
- */
1001
1169
  mime_type: string;
1170
+ sha256: string;
1171
+ id: string;
1172
+ url: string;
1002
1173
  };
1174
+ context?: ForwardedContext;
1175
+ referral?: ReferralInfo;
1003
1176
  }
1004
- /**
1005
- * Video message interface
1006
- */
1007
1177
  interface VideoMessage extends BaseMessage {
1008
1178
  type: MessageTypesEnum.Video;
1009
1179
  video: {
1010
- /**
1011
- * The video caption (if provided)
1012
- */
1013
1180
  caption?: string;
1014
- /**
1015
- * The SHA256 hash of the video
1016
- */
1017
- sha256?: string;
1018
- /**
1019
- * The ID for the video
1020
- */
1021
- id: string;
1022
- /**
1023
- * The MIME type of the video
1024
- */
1025
1181
  mime_type: string;
1182
+ sha256: string;
1183
+ id: string;
1184
+ url: string;
1026
1185
  };
1186
+ context?: ForwardedContext;
1187
+ referral?: ReferralInfo;
1027
1188
  }
1028
- /**
1029
- * Audio message interface
1030
- */
1031
1189
  interface AudioMessage extends BaseMessage {
1032
1190
  type: MessageTypesEnum.Audio;
1033
1191
  audio: {
1034
- /**
1035
- * The ID for the audio file
1036
- */
1037
- id: string;
1038
- /**
1039
- * The MIME type of the audio file
1040
- */
1041
1192
  mime_type: string;
1042
- /**
1043
- * Whether the audio is a voice message
1044
- */
1045
- voice?: boolean;
1193
+ sha256: string;
1194
+ id: string;
1195
+ url: string;
1196
+ voice: boolean;
1046
1197
  };
1198
+ referral?: ReferralInfo;
1047
1199
  }
1048
- /**
1049
- * Document message interface
1050
- */
1051
1200
  interface DocumentMessage extends BaseMessage {
1052
1201
  type: MessageTypesEnum.Document;
1053
1202
  document: {
1054
- /**
1055
- * The document caption (if provided)
1056
- */
1057
1203
  caption?: string;
1058
- /**
1059
- * The document filename
1060
- */
1061
1204
  filename: string;
1062
- /**
1063
- * The SHA256 hash of the document
1064
- */
1065
- sha256?: string;
1066
- /**
1067
- * The ID for the document
1068
- */
1069
- id: string;
1070
- /**
1071
- * The MIME type of the document
1072
- */
1073
1205
  mime_type: string;
1206
+ sha256: string;
1207
+ id: string;
1208
+ url: string;
1074
1209
  };
1210
+ referral?: ReferralInfo;
1075
1211
  }
1076
- /**
1077
- * Sticker message interface
1078
- */
1079
1212
  interface StickerMessage extends BaseMessage {
1080
1213
  type: MessageTypesEnum.Sticker;
1081
1214
  sticker: {
1082
- /**
1083
- * The ID for the sticker
1084
- */
1215
+ mime_type: string;
1216
+ sha256: string;
1085
1217
  id: string;
1086
- /**
1087
- * Whether this is an animated sticker
1088
- */
1218
+ url: string;
1089
1219
  animated: boolean;
1090
- /**
1091
- * The MIME type of the sticker
1092
- */
1093
- mime_type: string;
1094
1220
  };
1221
+ referral?: ReferralInfo;
1095
1222
  }
1096
- /**
1097
- * Reaction message interface
1098
- */
1099
- interface ReactionMessage extends BaseMessage {
1100
- type: MessageTypesEnum.Reaction;
1101
- reaction: {
1102
- /**
1103
- * The ID of the message being reacted to
1104
- */
1105
- message_id: string;
1106
- /**
1107
- * Emoji used for the reaction
1108
- */
1109
- emoji: string;
1223
+ interface InteractiveListReplyMessage extends BaseMessage {
1224
+ type: MessageTypesEnum.Interactive;
1225
+ context: ReplyContext;
1226
+ interactive: {
1227
+ type: 'list_reply';
1228
+ list_reply: {
1229
+ id: string;
1230
+ title: string;
1231
+ description?: string;
1232
+ };
1110
1233
  };
1111
1234
  }
1112
- /**
1113
- * Contacts message interface
1114
- */
1235
+ interface InteractiveButtonReplyMessage extends BaseMessage {
1236
+ type: MessageTypesEnum.Interactive;
1237
+ context: ReplyContext;
1238
+ interactive: {
1239
+ type: 'button_reply';
1240
+ button_reply: {
1241
+ id: string;
1242
+ title: string;
1243
+ };
1244
+ };
1245
+ }
1246
+ type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage;
1247
+ interface ButtonMessage extends BaseMessage {
1248
+ type: MessageTypesEnum.Button;
1249
+ context: ReplyContext;
1250
+ button: {
1251
+ payload: string;
1252
+ text: string;
1253
+ };
1254
+ }
1255
+ interface LocationMessage extends BaseMessage {
1256
+ type: MessageTypesEnum.Location;
1257
+ location: {
1258
+ latitude: number;
1259
+ longitude: number;
1260
+ name?: string;
1261
+ address?: string;
1262
+ url?: string;
1263
+ };
1264
+ referral?: ReferralInfo;
1265
+ }
1115
1266
  interface ContactsMessage extends BaseMessage {
1116
1267
  type: MessageTypesEnum.Contacts;
1117
1268
  contacts: Array<{
1118
- /**
1119
- * The contact's name
1120
- */
1269
+ addresses?: Array<{
1270
+ city?: string;
1271
+ country?: string;
1272
+ country_code?: string;
1273
+ state?: string;
1274
+ street?: string;
1275
+ type?: string;
1276
+ zip?: string;
1277
+ }>;
1278
+ birthday?: string;
1279
+ emails?: Array<{
1280
+ email: string;
1281
+ type?: string;
1282
+ }>;
1121
1283
  name: {
1122
- /**
1123
- * The formatted name
1124
- */
1125
1284
  formatted_name: string;
1126
- /**
1127
- * The first name
1128
- */
1129
1285
  first_name?: string;
1130
- /**
1131
- * The last name
1132
- */
1133
1286
  last_name?: string;
1134
- /**
1135
- * The middle name
1136
- */
1137
1287
  middle_name?: string;
1138
- /**
1139
- * The suffix
1140
- */
1141
1288
  suffix?: string;
1142
- /**
1143
- * The prefix
1144
- */
1145
1289
  prefix?: string;
1146
1290
  };
1147
- /**
1148
- * The contact's phone numbers
1149
- */
1150
- phones?: Array<{
1151
- phone: string;
1152
- type?: string;
1153
- wa_id?: string;
1154
- }>;
1155
- /**
1156
- * The contact's emails
1157
- */
1158
- emails?: Array<{
1159
- email: string;
1160
- type?: string;
1161
- }>;
1162
- /**
1163
- * The contact's addresses
1164
- */
1165
- addresses?: Array<{
1166
- street?: string;
1167
- city?: string;
1168
- state?: string;
1169
- zip?: string;
1170
- country?: string;
1171
- country_code?: string;
1172
- type?: string;
1173
- }>;
1174
- /**
1175
- * The contact's organizations
1176
- */
1177
1291
  org?: {
1178
1292
  company?: string;
1179
1293
  department?: string;
1180
1294
  title?: string;
1181
1295
  };
1182
- /**
1183
- * The contact's URLs
1184
- */
1296
+ phones?: Array<{
1297
+ phone: string;
1298
+ wa_id?: string;
1299
+ type?: string;
1300
+ }>;
1185
1301
  urls?: Array<{
1186
1302
  url: string;
1187
1303
  type?: string;
1188
1304
  }>;
1189
- /**
1190
- * The contact's birthday (YYYY-MM-DD format)
1191
- */
1192
- birthday?: string;
1193
1305
  }>;
1306
+ referral?: ReferralInfo;
1194
1307
  }
1195
- /**
1196
- * Location message interface
1197
- */
1198
- interface LocationMessage extends BaseMessage {
1199
- type: MessageTypesEnum.Location;
1200
- location: {
1201
- /**
1202
- * Latitude of the location
1203
- */
1204
- latitude: number;
1205
- /**
1206
- * Longitude of the location
1207
- */
1208
- longitude: number;
1209
- /**
1210
- * Name of the location
1211
- */
1212
- name?: string;
1213
- /**
1214
- * Address of the location
1215
- */
1216
- address?: string;
1308
+ interface ReactionMessage extends BaseMessage {
1309
+ type: MessageTypesEnum.Reaction;
1310
+ reaction: {
1311
+ message_id: string;
1312
+ emoji?: string;
1217
1313
  };
1218
1314
  }
1219
- /**
1220
- * Interactive message interface
1221
- */
1222
- interface InteractiveMessage extends BaseMessage {
1223
- type: MessageTypesEnum.Interactive;
1224
- interactive: {
1225
- /**
1226
- * Type of the interactive message
1227
- * Can be: button_reply, list_reply, flow, nfm_reply, etc.
1228
- */
1229
- type: string;
1230
- /**
1231
- * ID for the button that was clicked
1232
- */
1233
- button_reply?: {
1234
- id: string;
1235
- title: string;
1236
- };
1237
- /**
1238
- * ID for the list item that was selected
1239
- */
1240
- list_reply?: {
1241
- id: string;
1242
- title: string;
1243
- description?: string;
1244
- };
1245
- /**
1246
- * NFM (No-Code Flow Message) reply data
1247
- */
1248
- nfm_reply?: {
1249
- /**
1250
- * Response data in JSON format
1251
- */
1252
- response_json: string;
1253
- /**
1254
- * Body text of the reply
1255
- */
1256
- body: string;
1257
- /**
1258
- * Name of the flow
1259
- */
1260
- name: string;
1261
- };
1262
- };
1263
- }
1264
- /**
1265
- * System message interface
1266
- */
1267
- interface SystemMessage extends BaseMessage {
1268
- type: MessageTypesEnum.System;
1269
- system: {
1270
- /**
1271
- * The type of system update
1272
- */
1273
- type: string;
1274
- /**
1275
- * User's identity if the update is a customer identity change
1276
- */
1277
- identity?: string;
1278
- /**
1279
- * Old and new phone numbers if the update is a phone number change
1280
- */
1281
- customer?: {
1282
- /**
1283
- * The previous phone number
1284
- */
1285
- previous_wa_id: string;
1286
- /**
1287
- * The new phone number
1288
- */
1289
- wa_id: string;
1290
- };
1291
- };
1292
- }
1293
- /**
1294
- * Order message interface
1295
- */
1296
1315
  interface OrderMessage extends BaseMessage {
1297
1316
  type: MessageTypesEnum.Order;
1298
1317
  order: {
1299
- /**
1300
- * Catalog ID
1301
- */
1302
1318
  catalog_id: string;
1303
- /**
1304
- * Product items in the order
1305
- */
1319
+ text?: string;
1306
1320
  product_items: Array<{
1307
- /**
1308
- * Product ID
1309
- */
1310
1321
  product_retailer_id: string;
1311
- /**
1312
- * Quantity of the product
1313
- */
1314
1322
  quantity: number;
1315
- /**
1316
- * Item price
1317
- */
1318
1323
  item_price: number;
1319
- /**
1320
- * Currency code
1321
- */
1322
1324
  currency: string;
1323
1325
  }>;
1324
- /**
1325
- * Text message included with the order
1326
- */
1327
- text?: string;
1328
1326
  };
1329
1327
  }
1328
+ interface SystemMessage extends BaseMessage {
1329
+ type: MessageTypesEnum.System;
1330
+ system: {
1331
+ body: string;
1332
+ wa_id: string;
1333
+ type: 'user_changed_number';
1334
+ };
1335
+ }
1336
+ interface UnsupportedMessage extends BaseMessage {
1337
+ type: MessageTypesEnum.Unsupported;
1338
+ errors: Array<WebhookError>;
1339
+ }
1340
+ type GroupMessage = {
1341
+ group_id: string;
1342
+ } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
1343
+ type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1344
+ interface StatusWebhook {
1345
+ id: string;
1346
+ status: 'sent' | 'delivered' | 'read' | 'failed';
1347
+ timestamp: string;
1348
+ recipient_id: string;
1349
+ recipient_type?: 'group';
1350
+ recipient_participant_id?: string;
1351
+ recipient_identity_key_hash?: string;
1352
+ biz_opaque_callback_data?: string;
1353
+ conversation?: {
1354
+ id: string;
1355
+ expiration_timestamp?: string;
1356
+ origin: {
1357
+ type: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1358
+ };
1359
+ };
1360
+ pricing?: {
1361
+ billable: boolean;
1362
+ pricing_model: 'CBP' | 'PMP';
1363
+ type: 'regular' | 'free_customer_service' | 'free_entry_point';
1364
+ category: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1365
+ };
1366
+ errors?: Array<WebhookError>;
1367
+ }
1330
1368
  /**
1331
- * Button message interface
1369
+ * Webhook value for incoming messages
1332
1370
  */
1333
- interface ButtonMessage extends BaseMessage {
1334
- type: MessageTypesEnum.Button;
1335
- button: {
1336
- /**
1337
- * The payload for the button
1338
- */
1339
- payload: string;
1340
- /**
1341
- * Button text
1342
- */
1343
- text: string;
1344
- };
1371
+ interface MessageWebhookValue {
1372
+ messaging_product: 'whatsapp';
1373
+ metadata: WebhookMetadata;
1374
+ contacts: Array<WebhookContact>;
1375
+ messages: Array<WhatsAppMessage>;
1345
1376
  }
1346
1377
  /**
1378
+ * Webhook value for status updates
1379
+ */
1380
+ interface StatusWebhookValue {
1381
+ messaging_product: 'whatsapp';
1382
+ metadata: WebhookMetadata;
1383
+ statuses: Array<StatusWebhook>;
1384
+ }
1385
+ /**
1386
+ * Webhook value for errors (no contacts or messages)
1387
+ */
1388
+ interface ErrorWebhookValue {
1389
+ messaging_product: 'whatsapp';
1390
+ metadata: WebhookMetadata;
1391
+ errors: Array<WebhookError>;
1392
+ }
1393
+ /**
1394
+ * Union type for all webhook value types
1395
+ */
1396
+ type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
1397
+ interface WebhookPayload {
1398
+ object: 'whatsapp_business_account';
1399
+ entry: Array<{
1400
+ id: string;
1401
+ changes: Array<{
1402
+ value: WebhookValue;
1403
+ field: 'messages';
1404
+ }>;
1405
+ }>;
1406
+ }
1407
+ /**
1408
+ * @deprecated Use specific message types instead
1347
1409
  * Represents a message received through the webhook
1348
- * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
1349
1410
  */
1350
1411
  interface WebhookMessage {
1351
- /**
1352
- * The WhatsApp Business Account ID
1353
- */
1354
1412
  wabaId: string;
1355
- /**
1356
- * The message ID
1357
- */
1358
1413
  id: string;
1359
- /**
1360
- * The sender's phone number
1361
- */
1362
1414
  from: string;
1363
- /**
1364
- * The timestamp of the message
1365
- */
1366
1415
  timestamp: string;
1367
- /**
1368
- * The type of message (text, image, etc.)
1369
- */
1370
1416
  type: MessageTypesEnum;
1371
- /**
1372
- * The phone number ID that received the message
1373
- */
1374
1417
  phoneNumberId: string;
1375
- /**
1376
- * The display phone number that received the message
1377
- */
1378
1418
  displayPhoneNumber: string;
1379
- /**
1380
- * The profile name of the sender
1381
- */
1382
1419
  profileName: string;
1383
1420
  text?: TextMessage['text'];
1384
1421
  image?: ImageMessage['image'];
@@ -1393,129 +1430,15 @@ interface WebhookMessage {
1393
1430
  order?: OrderMessage['order'];
1394
1431
  system?: SystemMessage['system'];
1395
1432
  reaction?: ReactionMessage['reaction'];
1396
- statuses?: {
1397
- /**
1398
- * Arbitrary string included in sent message
1399
- */
1400
- biz_opaque_callback_data?: string;
1401
- /**
1402
- * Information about the conversation
1403
- */
1404
- conversation?: {
1405
- /**
1406
- * Represents the ID of the conversation the given status notification belongs to
1407
- */
1408
- id: string;
1409
- /**
1410
- * Describes conversation category
1411
- */
1412
- origin: {
1413
- /**
1414
- * Indicates conversation category. This can also be referred to as a conversation entry point
1415
- * - authentication: Conversation opened by business sending template categorized as AUTHENTICATION
1416
- * - marketing: Conversation opened by business sending template categorized as MARKETING
1417
- * - utility: Conversation opened by business sending template categorized as UTILITY
1418
- * - service: Conversation opened by business replying to customer within service window
1419
- * - referral_conversion: Free entry point conversation
1420
- */
1421
- type: 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1422
- };
1423
- /**
1424
- * Date when the conversation expires. Only present for messages with status 'sent'
1425
- */
1426
- expiration_timestamp?: string;
1427
- };
1428
- /**
1429
- * Array of error objects describing the error
1430
- */
1431
- errors?: Array<{
1432
- /**
1433
- * Error code
1434
- */
1435
- code: number;
1436
- /**
1437
- * Error code title
1438
- */
1439
- title: string;
1440
- /**
1441
- * Error code message
1442
- */
1443
- message: string;
1444
- /**
1445
- * Error details object
1446
- */
1447
- error_data?: {
1448
- /**
1449
- * Describes the error details
1450
- */
1451
- details: string;
1452
- };
1453
- }>;
1454
- /**
1455
- * The ID for the message that the business sent to a customer
1456
- */
1457
- id: string;
1458
- /**
1459
- * Pricing information for the message/conversation
1460
- */
1461
- pricing?: {
1462
- /**
1463
- * Indicates if the given message or conversation is billable
1464
- * @deprecated This field is deprecated. Visit the WhatsApp Changelog for more information.
1465
- */
1466
- billable?: boolean;
1467
- /**
1468
- * Indicates the conversation category:
1469
- * - authentication: Authentication conversation
1470
- * - authentication_international: Authentication-international conversation
1471
- * - marketing: Marketing conversation
1472
- * - utility: Utility conversation
1473
- * - service: Service conversation
1474
- * - referral_conversion: Free entry point conversation
1475
- */
1476
- category: 'authentication' | 'authentication_international' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1477
- /**
1478
- * Type of pricing model used by the business. Current supported value is CBP
1479
- */
1480
- pricing_model: 'CBP';
1481
- };
1482
- /**
1483
- * The customer's WhatsApp ID. Business can respond to customer using this ID.
1484
- * This ID may not match the customer's phone number.
1485
- */
1486
- recipient_id: string;
1487
- /**
1488
- * Status of the message:
1489
- * - delivered: Message has been delivered
1490
- * - read: Message has been read by the customer
1491
- * - sent: Message has been sent to the customer
1492
- */
1493
- status: 'delivered' | 'read' | 'sent';
1494
- /**
1495
- * Unix timestamp for the status message
1496
- */
1497
- timestamp: string;
1498
- };
1499
- /**
1500
- * The original message data as received from the webhook
1501
- */
1433
+ statuses?: StatusWebhook;
1502
1434
  originalData: any;
1503
1435
  }
1504
1436
  /**
1505
1437
  * Webhook event received from WhatsApp
1506
1438
  */
1507
1439
  interface WebhookEvent {
1508
- /**
1509
- * The field type of the event
1510
- */
1511
1440
  field: string;
1512
- /**
1513
- * The event data
1514
- */
1515
1441
  value: any;
1516
- /**
1517
- * The timestamp when the event was received
1518
- */
1519
1442
  timestamp: number;
1520
1443
  }
1521
1444
  /**
@@ -1525,6 +1448,7 @@ declare enum MessageStatus {
1525
1448
  DELIVERED = "delivered",
1526
1449
  READ = "read",
1527
1450
  SENT = "sent",
1451
+ FAILED = "failed",
1528
1452
  }
1529
1453
  //#endregion
1530
1454
  //#region src/types/logger.d.ts
@@ -1820,11 +1744,49 @@ type VerifyCodeRequest = {
1820
1744
  type TwoStepVerificationParams = {
1821
1745
  pin: string;
1822
1746
  };
1747
+ /**
1748
+ * Conversational Components - Commands
1749
+ */
1750
+ type ConversationalCommand = {
1751
+ command_name: string;
1752
+ command_description: string;
1753
+ };
1754
+ /**
1755
+ * Conversational Components - Ice Breakers (Prompts)
1756
+ */
1757
+ type ConversationalPrompt = string;
1758
+ /**
1759
+ * Request payload for configuring conversational automation
1760
+ */
1761
+ type ConversationalAutomationRequest = {
1762
+ enable_welcome_message?: boolean;
1763
+ commands?: ConversationalCommand[];
1764
+ prompts?: ConversationalPrompt[];
1765
+ };
1766
+ /**
1767
+ * Response from conversational automation GET endpoint
1768
+ */
1769
+ type ConversationalAutomationResponse = {
1770
+ enable_welcome_message?: boolean;
1771
+ commands?: ConversationalCommand[];
1772
+ prompts?: ConversationalPrompt[];
1773
+ id: string;
1774
+ };
1775
+ /**
1776
+ * Response from throughput GET endpoint
1777
+ */
1778
+ type ThroughputResponse = {
1779
+ throughput: Throughput;
1780
+ id: string;
1781
+ };
1823
1782
  interface PhoneNumberClass {
1824
1783
  getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>;
1825
1784
  getPhoneNumbers(): Promise<PhoneNumbersResponse>;
1826
1785
  requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
1827
1786
  verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>;
1787
+ setConversationalAutomation(params: ConversationalAutomationRequest): Promise<ResponseSuccess>;
1788
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
1789
+ getThroughput(): Promise<ThroughputResponse>;
1828
1790
  }
1829
1791
  //#endregion
1830
1792
  //#region src/api/template/types/common.d.ts
@@ -3305,784 +3267,249 @@ declare class FlowApi extends BaseAPI implements FlowClass {
3305
3267
  * @param flowId - The flow ID
3306
3268
  * @returns Promise with the success status
3307
3269
  */
3308
- publishFlow(flowId: string): Promise<ResponseSuccess>;
3309
- /**
3310
- * Deprecate Flow
3311
- *
3312
- * @param flowId - The flow ID
3313
- * @returns Promise with the success status
3314
- */
3315
- deprecateFlow(flowId: string): Promise<ResponseSuccess>;
3316
- /**
3317
- * Migrate Flows between WABAs
3318
- *
3319
- * @param destinationWabaId - The destination WABA ID
3320
- * @param data - The migration data including source_waba_id and optional source_flow_names
3321
- * @returns Promise with migration results (successes and failures)
3322
- */
3323
- migrateFlows(destinationWabaId: string, data: {
3324
- source_waba_id: string;
3325
- source_flow_names?: string[];
3326
- }): Promise<FlowMigrationResponse>;
3327
- }
3328
- //#endregion
3329
- //#region src/api/media/MediaApi.d.ts
3330
- /**
3331
- * API for managing WhatsApp Media.
3332
- *
3333
- * This API allows you to:
3334
- * - Get media information by ID
3335
- * - Upload media files
3336
- * - Delete media files
3337
- * - Download media files from URLs
3338
- */
3339
- declare class MediaApi extends BaseAPI implements MediaClass {
3340
- private readonly endpoint;
3341
- constructor(config: WabaConfigType, client: RequesterClass);
3342
- /**
3343
- * Retrieve media information by media ID.
3344
- *
3345
- * @param mediaId The media ID to retrieve information for
3346
- * @param phone_number_id Optional phone number ID (defaults to configured one)
3347
- * @returns Media information including URL, mime type, file size, etc.
3348
- *
3349
- * @example
3350
- * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');
3351
- */
3352
- getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
3353
- /**
3354
- * Upload a media file to WhatsApp.
3355
- *
3356
- * @param file The file to upload
3357
- * @param messagingProduct The messaging product (default: 'whatsapp')
3358
- * @returns Upload response containing the media ID
3359
- *
3360
- * @example
3361
- * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
3362
- * const result = await whatsappClient.media.uploadMedia(file);
3363
- */
3364
- uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
3365
- /**
3366
- * Delete a media file.
3367
- *
3368
- * @param mediaId The media ID to delete
3369
- * @param phone_number_id Optional phone number ID (defaults to configured one)
3370
- * @returns Response indicating success or failure
3371
- *
3372
- * @example
3373
- * await whatsappClient.media.deleteMedia('media_id_123');
3374
- */
3375
- deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
3376
- /**
3377
- * Download media from a URL.
3378
- *
3379
- * @param mediaUrl The URL to download media from
3380
- * @returns Blob containing the media data
3381
- *
3382
- * @example
3383
- * const blob = await whatsappClient.media.downloadMedia('https://...');
3384
- */
3385
- downloadMedia(mediaUrl: string): Promise<Blob>;
3386
- }
3387
- //#endregion
3388
- //#region src/api/messages/MessageApi.d.ts
3389
- /**
3390
- * Maps each message type to its appropriate payload type
3391
- */
3392
- type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
3393
- message_id: string;
3394
- emoji: string;
3395
- } : never;
3396
- declare class MessagesApi extends BaseAPI implements MessagesClass {
3397
- private readonly commonMethod;
3398
- private readonly commonEndpoint;
3399
- constructor(config: WabaConfigType, client: RequesterClass);
3400
- /**
3401
- * Builds the request body for WhatsApp API messages
3402
- * @param type The type of message to send
3403
- * @param payload The message payload object
3404
- * @param to The recipient's phone number
3405
- * @param replyMessageId Optional message ID to reply to
3406
- * @returns The formatted request body
3407
- */
3408
- bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
3409
- /**
3410
- * Sends a request to the WhatsApp API
3411
- * @param body The request body to send
3412
- * @returns Promise with the API response
3413
- */
3414
- private send;
3415
- /**
3416
- * Sends an audio message via WhatsApp
3417
- * @param params The audio message parameter object
3418
- * @returns Promise with the message response
3419
- */
3420
- audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
3421
- /**
3422
- * Sends a contact card via WhatsApp
3423
- * @param params The contact message parameter object
3424
- * @returns Promise with the message response
3425
- */
3426
- contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
3427
- /**
3428
- * Sends a document via WhatsApp
3429
- * @param params The document message parameter object
3430
- * @returns Promise with the message response
3431
- */
3432
- document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
3433
- /**
3434
- * Sends an image via WhatsApp
3435
- * @param params The image message parameter object
3436
- * @returns Promise with the message response
3437
- */
3438
- image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
3439
- /**
3440
- * Sends an interactive message via WhatsApp
3441
- * @param params The interactive message parameter object
3442
- * @returns Promise with the message response
3443
- */
3444
- interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
3445
- /**
3446
- * Sends a location via WhatsApp
3447
- * @param params The location message parameter object
3448
- * @returns Promise with the message response
3449
- */
3450
- location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
3451
- /**
3452
- * Sends a sticker via WhatsApp
3453
- * @param params The sticker message parameter object
3454
- * @returns Promise with the message response
3455
- */
3456
- sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
3457
- /**
3458
- * Sends a template message via WhatsApp
3459
- * @param params The template message parameter object
3460
- * @returns Promise with the message response
3461
- */
3462
- template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
3463
- /**
3464
- * Sends a text message via WhatsApp
3465
- * @param params The text message parameter object
3466
- * @returns Promise with the message response
3467
- */
3468
- text(params: TextMessageParams): Promise<MessagesResponse>;
3469
- /**
3470
- * Sends a video message via WhatsApp
3471
- * @param params The video message parameter object
3472
- * @returns Promise with the message response
3473
- */
3474
- video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
3475
- /**
3476
- * Updates message status (mark as read, etc.)
3477
- * @param params The status update parameters
3478
- * @returns Promise with the API response
3479
- */
3480
- status(params: StatusParams): Promise<MessagesResponse>;
3481
- /**
3482
- * Marks a message as read
3483
- * @param params Object containing messageId
3484
- * @returns Promise with the API response
3485
- */
3486
- markAsRead(params: {
3487
- messageId: string;
3488
- }): Promise<MessagesResponse>;
3489
- /**
3490
- * Shows typing indicator
3491
- * @param params Object containing messageId
3492
- * @returns Promise with the API response
3493
- */
3494
- showTypingIndicator(params: {
3495
- messageId: string;
3496
- }): Promise<MessagesResponse>;
3497
- /**
3498
- * Sends a list interactive message
3499
- * @param params The list interactive message parameters
3500
- * @returns Promise with the message response
3501
- */
3502
- interactiveList(params: MessageRequestParams<InteractiveObject & {
3503
- type: InteractiveTypesEnum.List;
3504
- }>): Promise<MessagesResponse>;
3505
- /**
3506
- * Sends a CTA URL interactive message
3507
- * @param params The CTA URL interactive message parameters
3508
- * @returns Promise with the message response
3509
- */
3510
- interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
3511
- type: InteractiveTypesEnum.CtaUrl;
3512
- }>): Promise<MessagesResponse>;
3513
- /**
3514
- * Sends a location request interactive message
3515
- * @param params The location request interactive message parameters
3516
- * @returns Promise with the message response
3517
- */
3518
- interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
3519
- type: InteractiveTypesEnum.LocationRequest;
3520
- }>): Promise<MessagesResponse>;
3521
- /**
3522
- * Sends an address message interactive message
3523
- * @param params The address message interactive message parameters
3524
- * @returns Promise with the message response
3525
- */
3526
- interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
3527
- type: InteractiveTypesEnum.AddressMessage;
3528
- }>): Promise<MessagesResponse>;
3529
- /**
3530
- * Sends a reply buttons interactive message
3531
- * @param params The reply buttons interactive message parameters
3532
- * @returns Promise with the message response
3533
- */
3534
- interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
3535
- type: InteractiveTypesEnum.Button;
3536
- }>): Promise<MessagesResponse>;
3537
- /**
3538
- * Sends a flow interactive message
3539
- * @param params The flow interactive message parameters
3540
- * @returns Promise with the message response
3541
- */
3542
- interactiveFlow(params: MessageRequestParams<InteractiveObject & {
3543
- type: InteractiveTypesEnum.Flow;
3544
- }>): Promise<MessagesResponse>;
3545
- /**
3546
- * Sends a reaction to a message
3547
- * @param params The reaction parameters
3548
- * @returns Promise with the message response
3549
- */
3550
- reaction(params: ReactionParams): Promise<MessagesResponse>;
3551
- }
3552
- //#endregion
3553
- //#region src/api/messages/builders/ContactMessageBuilder.d.ts
3554
- /**
3555
- * Builder class for creating contact messages with a fluent API
3556
- */
3557
- declare class ContactMessageBuilder {
3558
- private contact;
3559
- /**
3560
- * Set the contact name (required)
3561
- */
3562
- setName(name: NameObject): this;
3563
- /**
3564
- * Set simple name with first name only
3565
- */
3566
- setSimpleName(firstName: string, lastName?: string): this;
3567
- /**
3568
- * Set full name details
3569
- */
3570
- setFullName(firstName: string, lastName?: string, middleName?: string, suffix?: string, prefix?: string): this;
3571
- /**
3572
- * Add phone numbers
3573
- */
3574
- addPhone(phone: string, type?: string, waId?: string): this;
3575
- /**
3576
- * Add email addresses
3577
- */
3578
- addEmail(email: string, type?: string): this;
3579
- /**
3580
- * Add address
3581
- */
3582
- addAddress(address: AddressesObject): this;
3583
- /**
3584
- * Add simple address
3585
- */
3586
- addSimpleAddress(street: string, city: string, country: string, type?: string): this;
3587
- /**
3588
- * Set organization details
3589
- */
3590
- setOrganization(company: string, department?: string, title?: string): this;
3591
- /**
3592
- * Add URL
3593
- */
3594
- addUrl(url: string, type?: string): this;
3595
- /**
3596
- * Set birthday (format: YYYY-MM-DD)
3597
- */
3598
- setBirthday(year: number, month: number, day: number): this;
3599
- /**
3600
- * Build the final contact object
3601
- */
3602
- build(): ContactObject;
3603
- /**
3604
- * Reset the builder for reuse
3605
- */
3606
- reset(): this;
3607
- }
3608
- /**
3609
- * Factory class for common contact patterns
3610
- */
3611
- declare class ContactMessageFactory {
3612
- /**
3613
- * Create a simple contact with name and phone
3614
- */
3615
- static createSimpleContact(firstName: string, phone: string): ContactObject;
3616
- /**
3617
- * Create a business contact
3618
- */
3619
- static createBusinessContact(firstName: string, lastName: string, company: string, title: string, phone: string, email: string): ContactObject;
3620
- /**
3621
- * Create a personal contact with full details
3622
- */
3623
- static createPersonalContact(firstName: string, lastName: string, mobilePhone: string, email?: string, birthday?: {
3624
- year: number;
3625
- month: number;
3626
- day: number;
3627
- }): ContactObject;
3628
- }
3629
- //#endregion
3630
- //#region src/api/messages/builders/InteractiveMessageBuilder.d.ts
3631
- /**
3632
- * Builder class for creating interactive messages with a fluent API
3633
- */
3634
- declare class InteractiveMessageBuilder {
3635
- private message;
3636
- /**
3637
- * Set the interactive message type
3638
- */
3639
- setType(type: InteractiveTypesEnum): this;
3640
- /**
3641
- * Set the body text of the message
3642
- */
3643
- setBody(text: string): this;
3644
- /**
3645
- * Set the footer text of the message
3646
- */
3647
- setFooter(text: string): this;
3648
- /**
3649
- * Set a text header
3650
- */
3651
- setTextHeader(text: string): this;
3652
- /**
3653
- * Set an image header
3654
- */
3655
- setImageHeader(imageUrl: string): this;
3656
- /**
3657
- * Add reply buttons (for button type messages)
3658
- */
3659
- addReplyButtons(buttons: Array<{
3660
- id: string;
3661
- title: string;
3662
- }>): this;
3663
- /**
3664
- * Add list sections (for list type messages)
3665
- * Note: This creates a single section with multiple rows
3666
- */
3667
- addListSections(sections: Array<{
3668
- title?: string;
3669
- rows: Array<{
3670
- id: string;
3671
- title: string;
3672
- description?: string;
3673
- }>;
3674
- }>): this;
3675
- /**
3676
- * Set the button text for list messages
3677
- */
3678
- setListButtonText(buttonText: string): this;
3679
- /**
3680
- * Set CTA URL action
3681
- */
3682
- setCTAUrl(displayText: string, url: string): this;
3683
- /**
3684
- * Build the final interactive object
3685
- */
3686
- build(): InteractiveObject;
3687
- /**
3688
- * Reset the builder for reuse
3689
- */
3690
- reset(): this;
3691
- }
3692
- /**
3693
- * Convenience factory functions for common interactive message types
3694
- */
3695
- declare class InteractiveMessageFactory {
3696
- /**
3697
- * Create a button message with reply buttons
3698
- */
3699
- static createButtonMessage(bodyText: string, buttons: Array<{
3700
- id: string;
3701
- title: string;
3702
- }>, options?: {
3703
- headerText?: string;
3704
- footerText?: string;
3705
- }): InteractiveObject;
3706
- /**
3707
- * Create a list message with sections
3708
- */
3709
- static createListMessage(bodyText: string, buttonText: string, sections: Array<{
3710
- title?: string;
3711
- rows: Array<{
3712
- id: string;
3713
- title: string;
3714
- description?: string;
3715
- }>;
3716
- }>, options?: {
3717
- headerText?: string;
3718
- footerText?: string;
3719
- }): InteractiveObject;
3720
- /**
3721
- * Create a CTA URL message
3722
- */
3723
- static createCTAUrlMessage(bodyText: string, displayText: string, url: string, options?: {
3724
- headerText?: string;
3725
- footerText?: string;
3726
- }): InteractiveObject;
3727
- }
3728
- //#endregion
3729
- //#region src/api/messages/builders/LocationMessageBuilder.d.ts
3730
- /**
3731
- * Builder class for creating location messages with a fluent API
3732
- */
3733
- declare class LocationMessageBuilder {
3734
- private location;
3735
- /**
3736
- * Set the latitude coordinate
3737
- */
3738
- setLatitude(latitude: number): this;
3739
- /**
3740
- * Set the longitude coordinate
3741
- */
3742
- setLongitude(longitude: number): this;
3743
- /**
3744
- * Set coordinates using latitude and longitude
3745
- */
3746
- setCoordinates(latitude: number, longitude: number): this;
3747
- /**
3748
- * Set the location name
3749
- */
3750
- setName(name: string): this;
3751
- /**
3752
- * Set the location address
3753
- */
3754
- setAddress(address: string): this;
3755
- /**
3756
- * Build the final location object
3757
- */
3758
- build(): LocationObject;
3759
- /**
3760
- * Reset the builder for reuse
3761
- */
3762
- reset(): this;
3763
- }
3764
- /**
3765
- * Factory class for common location patterns
3766
- */
3767
- declare class LocationMessageFactory {
3768
- /**
3769
- * Create a simple location with just coordinates
3770
- */
3771
- static createSimpleLocation(latitude: number, longitude: number): LocationObject;
3772
- /**
3773
- * Create a location with name and address
3774
- */
3775
- static createNamedLocation(latitude: number, longitude: number, name: string, address: string): LocationObject;
3776
- /**
3777
- * Create a business location
3778
- */
3779
- static createBusinessLocation(latitude: number, longitude: number, businessName: string, fullAddress: string): LocationObject;
3780
- }
3781
- //#endregion
3782
- //#region src/api/messages/builders/MediaMessageBuilder.d.ts
3783
- /**
3784
- * Base builder for media messages
3785
- */
3786
- declare abstract class BaseMediaBuilder<T> {
3787
- protected media: Partial<T>;
3788
- /**
3789
- * Set media ID (for uploaded media)
3790
- */
3791
- setId(id: string): this;
3792
- /**
3793
- * Set media URL
3794
- */
3795
- setLink(url: string): this;
3796
- /**
3797
- * Set media caption
3798
- */
3799
- setCaption(caption: string): this;
3800
- /**
3801
- * Build the media object
3802
- */
3803
- build(): T;
3804
- /**
3805
- * Reset the builder
3806
- */
3807
- reset(): this;
3808
- }
3809
- /**
3810
- * Builder for image messages
3811
- */
3812
- declare class ImageMessageBuilder extends BaseMediaBuilder<ImageMediaObject> {}
3813
- /**
3814
- * Builder for video messages
3815
- */
3816
- declare class VideoMessageBuilder extends BaseMediaBuilder<VideoMediaObject> {}
3817
- /**
3818
- * Builder for audio messages
3819
- */
3820
- declare class AudioMessageBuilder extends BaseMediaBuilder<AudioMediaObject> {
3821
- setCaption(caption: string): this;
3822
- }
3823
- /**
3824
- * Builder for document messages
3825
- */
3826
- declare class DocumentMessageBuilder extends BaseMediaBuilder<DocumentMediaObject> {
3827
- /**
3828
- * Set document filename
3829
- */
3830
- setFilename(filename: string): this;
3831
- }
3832
- /**
3833
- * Builder for sticker messages
3834
- */
3835
- declare class StickerMessageBuilder extends BaseMediaBuilder<StickerMediaObject> {
3836
- setCaption(caption: string): this;
3837
- }
3838
- /**
3839
- * Factory class for common media patterns
3840
- */
3841
- declare class MediaMessageFactory {
3842
- /**
3843
- * Create an image with caption
3844
- */
3845
- static createImageWithCaption(linkOrId: string, caption: string, isId?: boolean): ImageMediaObject;
3846
- /**
3847
- * Create a video with caption
3848
- */
3849
- static createVideoWithCaption(linkOrId: string, caption: string, isId?: boolean): VideoMediaObject;
3850
- /**
3851
- * Create a document with filename
3852
- */
3853
- static createDocument(linkOrId: string, filename: string, caption?: string, isId?: boolean): DocumentMediaObject;
3854
- /**
3855
- * Create an audio message
3856
- */
3857
- static createAudio(linkOrId: string, isId?: boolean): AudioMediaObject;
3858
- /**
3859
- * Create a sticker message
3860
- */
3861
- static createSticker(linkOrId: string, isId?: boolean): StickerMediaObject;
3862
- }
3863
- //#endregion
3864
- //#region src/api/messages/builders/ReactionMessageBuilder.d.ts
3865
- /**
3866
- * Builder class for creating reaction messages with a fluent API
3867
- */
3868
- declare class ReactionMessageBuilder {
3869
- private reaction;
3870
- /**
3871
- * Set the message ID to react to
3872
- */
3873
- setMessageId(messageId: string): this;
3874
- /**
3875
- * Set the emoji for the reaction
3876
- */
3877
- setEmoji(emoji: string): this;
3878
- /**
3879
- * Remove a reaction (by sending empty emoji)
3880
- */
3881
- removeReaction(): this;
3270
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
3882
3271
  /**
3883
- * Build the final reaction object
3272
+ * Deprecate Flow
3273
+ *
3274
+ * @param flowId - The flow ID
3275
+ * @returns Promise with the success status
3884
3276
  */
3885
- build(): {
3886
- message_id: string;
3887
- emoji: string;
3888
- };
3277
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
3889
3278
  /**
3890
- * Reset the builder for reuse
3279
+ * Migrate Flows between WABAs
3280
+ *
3281
+ * @param destinationWabaId - The destination WABA ID
3282
+ * @param data - The migration data including source_waba_id and optional source_flow_names
3283
+ * @returns Promise with migration results (successes and failures)
3891
3284
  */
3892
- reset(): this;
3285
+ migrateFlows(destinationWabaId: string, data: {
3286
+ source_waba_id: string;
3287
+ source_flow_names?: string[];
3288
+ }): Promise<FlowMigrationResponse>;
3893
3289
  }
3290
+ //#endregion
3291
+ //#region src/api/media/MediaApi.d.ts
3894
3292
  /**
3895
- * Factory class for common reaction patterns
3293
+ * API for managing WhatsApp Media.
3294
+ *
3295
+ * This API allows you to:
3296
+ * - Get media information by ID
3297
+ * - Upload media files
3298
+ * - Delete media files
3299
+ * - Download media files from URLs
3896
3300
  */
3897
- declare class ReactionMessageFactory {
3898
- /**
3899
- * Create a like reaction
3900
- */
3901
- static createLike(messageId: string): {
3902
- message_id: string;
3903
- emoji: string;
3904
- };
3905
- /**
3906
- * Create a heart reaction
3907
- */
3908
- static createHeart(messageId: string): {
3909
- message_id: string;
3910
- emoji: string;
3911
- };
3912
- /**
3913
- * Create a laughing reaction
3914
- */
3915
- static createLaugh(messageId: string): {
3916
- message_id: string;
3917
- emoji: string;
3918
- };
3301
+ declare class MediaApi extends BaseAPI implements MediaClass {
3302
+ private readonly endpoint;
3303
+ constructor(config: WabaConfigType, client: RequesterClass);
3919
3304
  /**
3920
- * Create a wow reaction
3305
+ * Retrieve media information by media ID.
3306
+ *
3307
+ * @param mediaId The media ID to retrieve information for
3308
+ * @param phone_number_id Optional phone number ID (defaults to configured one)
3309
+ * @returns Media information including URL, mime type, file size, etc.
3310
+ *
3311
+ * @example
3312
+ * const mediaInfo = await whatsappClient.media.getMediaById('media_id_123');
3921
3313
  */
3922
- static createWow(messageId: string): {
3923
- message_id: string;
3924
- emoji: string;
3925
- };
3314
+ getMediaById(mediaId: string, phone_number_id?: string): Promise<MediaResponse>;
3926
3315
  /**
3927
- * Create a sad reaction
3316
+ * Upload a media file to WhatsApp.
3317
+ *
3318
+ * @param file The file to upload
3319
+ * @param messagingProduct The messaging product (default: 'whatsapp')
3320
+ * @returns Upload response containing the media ID
3321
+ *
3322
+ * @example
3323
+ * const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
3324
+ * const result = await whatsappClient.media.uploadMedia(file);
3928
3325
  */
3929
- static createSad(messageId: string): {
3930
- message_id: string;
3931
- emoji: string;
3932
- };
3326
+ uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
3933
3327
  /**
3934
- * Create an angry reaction
3328
+ * Delete a media file.
3329
+ *
3330
+ * @param mediaId The media ID to delete
3331
+ * @param phone_number_id Optional phone number ID (defaults to configured one)
3332
+ * @returns Response indicating success or failure
3333
+ *
3334
+ * @example
3335
+ * await whatsappClient.media.deleteMedia('media_id_123');
3935
3336
  */
3936
- static createAngry(messageId: string): {
3937
- message_id: string;
3938
- emoji: string;
3939
- };
3337
+ deleteMedia(mediaId: string, phone_number_id?: string): Promise<ResponseSuccess>;
3940
3338
  /**
3941
- * Remove a reaction
3339
+ * Download media from a URL.
3340
+ *
3341
+ * @param mediaUrl The URL to download media from
3342
+ * @returns Blob containing the media data
3343
+ *
3344
+ * @example
3345
+ * const blob = await whatsappClient.media.downloadMedia('https://...');
3942
3346
  */
3943
- static removeReaction(messageId: string): {
3944
- message_id: string;
3945
- emoji: string;
3946
- };
3347
+ downloadMedia(mediaUrl: string): Promise<Blob>;
3947
3348
  }
3948
3349
  //#endregion
3949
- //#region src/api/messages/builders/TemplateMessageBuilder.d.ts
3950
- type CurrencyParameterHelper = {
3951
- type: ParametersTypesEnum.Currency;
3952
- currency: {
3953
- fallback_value: string;
3954
- code: CurrencyCodesEnum;
3955
- amount_1000: number;
3956
- };
3957
- };
3958
- type DateTimeParameterHelper = {
3959
- type: ParametersTypesEnum.DateTime;
3960
- date_time: {
3961
- fallback_value: string;
3962
- timestamp: number;
3963
- };
3964
- };
3965
- type ParameterObject = CurrencyParameterHelper | DateTimeParameterHelper;
3350
+ //#region src/api/messages/MessageApi.d.ts
3966
3351
  /**
3967
- * Builder class for creating template messages with a fluent API
3352
+ * Maps each message type to its appropriate payload type
3968
3353
  */
3969
- declare class TemplateMessageBuilder {
3970
- private template;
3354
+ type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
3355
+ message_id: string;
3356
+ emoji: string;
3357
+ } : never;
3358
+ declare class MessagesApi extends BaseAPI implements MessagesClass {
3359
+ private readonly commonMethod;
3360
+ private readonly commonEndpoint;
3361
+ constructor(config: WabaConfigType, client: RequesterClass);
3362
+ /**
3363
+ * Builds the request body for WhatsApp API messages
3364
+ * @param type The type of message to send
3365
+ * @param payload The message payload object
3366
+ * @param to The recipient's phone number
3367
+ * @param replyMessageId Optional message ID to reply to
3368
+ * @returns The formatted request body
3369
+ */
3370
+ bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
3971
3371
  /**
3972
- * Set the template name
3372
+ * Sends a request to the WhatsApp API
3373
+ * @param body The request body to send
3374
+ * @returns Promise with the API response
3973
3375
  */
3974
- setName(name: string): this;
3376
+ private send;
3975
3377
  /**
3976
- * Set the template language
3378
+ * Sends an audio message via WhatsApp
3379
+ * @param params The audio message parameter object
3380
+ * @returns Promise with the message response
3977
3381
  */
3978
- setLanguage(code: string): this;
3382
+ audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
3979
3383
  /**
3980
- * Add a header component with text parameters
3384
+ * Sends a contact card via WhatsApp
3385
+ * @param params The contact message parameter object
3386
+ * @returns Promise with the message response
3981
3387
  */
3982
- addTextHeader(parameters: string[]): this;
3388
+ contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
3983
3389
  /**
3984
- * Add a header component with image
3390
+ * Sends a document via WhatsApp
3391
+ * @param params The document message parameter object
3392
+ * @returns Promise with the message response
3985
3393
  */
3986
- addImageHeader(imageUrl: string): this;
3394
+ document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
3987
3395
  /**
3988
- * Add a body component with text parameters
3396
+ * Sends an image via WhatsApp
3397
+ * @param params The image message parameter object
3398
+ * @returns Promise with the message response
3989
3399
  */
3990
- addBody(parameters: string[]): this;
3400
+ image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
3991
3401
  /**
3992
- * Add a footer component (usually no parameters needed)
3402
+ * Sends an interactive message via WhatsApp
3403
+ * @param params The interactive message parameter object
3404
+ * @returns Promise with the message response
3993
3405
  */
3994
- addFooter(): this;
3406
+ interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
3995
3407
  /**
3996
- * Add button components (for quick replies, URLs, etc.)
3408
+ * Sends a location via WhatsApp
3409
+ * @param params The location message parameter object
3410
+ * @returns Promise with the message response
3997
3411
  */
3998
- addButtons(buttons: Array<{
3999
- index: number;
4000
- type: 'quick_reply' | 'url';
4001
- parameters?: string[];
4002
- }>): this;
3412
+ location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
4003
3413
  /**
4004
- * Add a currency parameter for header/body
3414
+ * Sends a sticker via WhatsApp
3415
+ * @param params The sticker message parameter object
3416
+ * @returns Promise with the message response
4005
3417
  */
4006
- addCurrencyParameter(fallbackValue: string, currencyCode: string, amount: number): CurrencyParameterHelper;
3418
+ sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
4007
3419
  /**
4008
- * Add a date time parameter
3420
+ * Sends a template message via WhatsApp
3421
+ * @param params The template message parameter object
3422
+ * @returns Promise with the message response
4009
3423
  */
4010
- addDateTimeParameter(fallbackValue: string, timestamp: number): DateTimeParameterHelper;
3424
+ template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
4011
3425
  /**
4012
- * Build the final template object
3426
+ * Sends a text message via WhatsApp
3427
+ * @param params The text message parameter object
3428
+ * @returns Promise with the message response
4013
3429
  */
4014
- build(): MessageTemplateObject<ComponentTypesEnum>;
3430
+ text(params: TextMessageParams): Promise<MessagesResponse>;
4015
3431
  /**
4016
- * Reset the builder for reuse
3432
+ * Sends a video message via WhatsApp
3433
+ * @param params The video message parameter object
3434
+ * @returns Promise with the message response
4017
3435
  */
4018
- reset(): this;
4019
- }
4020
- /**
4021
- * Factory class for common template patterns
4022
- */
4023
- declare class TemplateMessageFactory {
3436
+ video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
4024
3437
  /**
4025
- * Create a simple text-only template
3438
+ * Updates message status (mark as read, etc.)
3439
+ * @param params The status update parameters
3440
+ * @returns Promise with the API response
4026
3441
  */
4027
- static createSimpleTextTemplate(name: string, language: string, bodyParameters: string[]): MessageTemplateObject<ComponentTypesEnum>;
3442
+ status(params: StatusParams): Promise<MessagesResponse>;
4028
3443
  /**
4029
- * Create a template with header, body and buttons
3444
+ * Marks a message as read
3445
+ * @param params Object containing messageId
3446
+ * @returns Promise with the API response
4030
3447
  */
4031
- static createCompleteTemplate(name: string, language: string, options: {
4032
- headerParameters?: string[];
4033
- headerImage?: string;
4034
- bodyParameters: string[];
4035
- buttons?: Array<{
4036
- index: number;
4037
- type: 'quick_reply' | 'url';
4038
- parameters?: string[];
4039
- }>;
4040
- }): MessageTemplateObject<ComponentTypesEnum>;
3448
+ markAsRead(params: {
3449
+ messageId: string;
3450
+ }): Promise<MessagesResponse>;
4041
3451
  /**
4042
- * Create an order confirmation template
3452
+ * Shows typing indicator
3453
+ * @param params Object containing messageId
3454
+ * @returns Promise with the API response
4043
3455
  */
4044
- static createOrderConfirmationTemplate(language: string, customerName: string, orderNumber: string, amount: number, currencyCode: string): MessageTemplateObject<ComponentTypesEnum>;
4045
- }
4046
- //#endregion
4047
- //#region src/api/messages/builders/TextMessageBuilder.d.ts
4048
- /**
4049
- * Builder class for creating text messages with a fluent API
4050
- */
4051
- declare class TextMessageBuilder {
4052
- private textMessage;
3456
+ showTypingIndicator(params: {
3457
+ messageId: string;
3458
+ }): Promise<MessagesResponse>;
4053
3459
  /**
4054
- * Set the message body text
3460
+ * Sends a list interactive message
3461
+ * @param params The list interactive message parameters
3462
+ * @returns Promise with the message response
4055
3463
  */
4056
- setBody(text: string): this;
3464
+ interactiveList(params: MessageRequestParams<InteractiveObject & {
3465
+ type: InteractiveTypesEnum.List;
3466
+ }>): Promise<MessagesResponse>;
4057
3467
  /**
4058
- * Enable or disable URL preview
3468
+ * Sends a CTA URL interactive message
3469
+ * @param params The CTA URL interactive message parameters
3470
+ * @returns Promise with the message response
4059
3471
  */
4060
- setPreviewUrl(enable?: boolean): this;
3472
+ interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
3473
+ type: InteractiveTypesEnum.CtaUrl;
3474
+ }>): Promise<MessagesResponse>;
4061
3475
  /**
4062
- * Build the final text object
3476
+ * Sends a location request interactive message
3477
+ * @param params The location request interactive message parameters
3478
+ * @returns Promise with the message response
4063
3479
  */
4064
- build(): TextObject;
3480
+ interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
3481
+ type: InteractiveTypesEnum.LocationRequest;
3482
+ }>): Promise<MessagesResponse>;
4065
3483
  /**
4066
- * Reset the builder for reuse
3484
+ * Sends an address message interactive message
3485
+ * @param params The address message interactive message parameters
3486
+ * @returns Promise with the message response
4067
3487
  */
4068
- reset(): this;
4069
- }
4070
- /**
4071
- * Factory class for common text message patterns
4072
- */
4073
- declare class TextMessageFactory {
3488
+ interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
3489
+ type: InteractiveTypesEnum.AddressMessage;
3490
+ }>): Promise<MessagesResponse>;
4074
3491
  /**
4075
- * Create a simple text message
3492
+ * Sends a reply buttons interactive message
3493
+ * @param params The reply buttons interactive message parameters
3494
+ * @returns Promise with the message response
4076
3495
  */
4077
- static createSimpleText(body: string): TextObject;
3496
+ interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
3497
+ type: InteractiveTypesEnum.Button;
3498
+ }>): Promise<MessagesResponse>;
4078
3499
  /**
4079
- * Create a text message with URL preview
3500
+ * Sends a flow interactive message
3501
+ * @param params The flow interactive message parameters
3502
+ * @returns Promise with the message response
4080
3503
  */
4081
- static createTextWithPreview(body: string): TextObject;
3504
+ interactiveFlow(params: MessageRequestParams<InteractiveObject & {
3505
+ type: InteractiveTypesEnum.Flow;
3506
+ }>): Promise<MessagesResponse>;
4082
3507
  /**
4083
- * Create a notification message
3508
+ * Sends a reaction to a message
3509
+ * @param params The reaction parameters
3510
+ * @returns Promise with the message response
4084
3511
  */
4085
- static createNotification(title: string, message: string): TextObject;
3512
+ reaction(params: ReactionParams): Promise<MessagesResponse>;
4086
3513
  }
4087
3514
  //#endregion
4088
3515
  //#region src/api/phone/PhoneNumberApi.d.ts
@@ -4143,6 +3570,71 @@ declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
4143
3570
  * });
4144
3571
  */
4145
3572
  verifyCode(request: VerifyCodeRequest): Promise<ResponseSuccess>;
3573
+ /**
3574
+ * Configure conversational automation features (Welcome Messages, Ice Breakers, Commands).
3575
+ *
3576
+ * @param request Configuration for conversational components
3577
+ * @returns Response indicating success or failure
3578
+ *
3579
+ * @example
3580
+ * // Enable welcome message
3581
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3582
+ * enable_welcome_message: true
3583
+ * });
3584
+ *
3585
+ * @example
3586
+ * // Configure commands
3587
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3588
+ * commands: [
3589
+ * { command_name: 'tickets', command_description: 'Book flight tickets' },
3590
+ * { command_name: 'hotel', command_description: 'Book hotel' }
3591
+ * ]
3592
+ * });
3593
+ *
3594
+ * @example
3595
+ * // Configure ice breakers (prompts)
3596
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3597
+ * prompts: ['Book a flight', 'Plan a vacation']
3598
+ * });
3599
+ *
3600
+ * @example
3601
+ * // Configure all features
3602
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3603
+ * enable_welcome_message: true,
3604
+ * commands: [
3605
+ * { command_name: 'tickets', command_description: 'Book flight tickets' }
3606
+ * ],
3607
+ * prompts: ['Book a flight']
3608
+ * });
3609
+ */
3610
+ setConversationalAutomation(request: ConversationalAutomationRequest): Promise<ResponseSuccess>;
3611
+ /**
3612
+ * Get the current configuration of conversational automation features.
3613
+ *
3614
+ * @returns Current configuration including welcome message status, commands, and prompts
3615
+ *
3616
+ * @example
3617
+ * const config = await whatsappClient.phoneNumber.getConversationalAutomation();
3618
+ * console.log(config.enable_welcome_message); // true/false
3619
+ * console.log(config.commands); // Array of commands
3620
+ * console.log(config.prompts); // Array of ice breakers
3621
+ */
3622
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
3623
+ /**
3624
+ * Get the current throughput level for the phone number.
3625
+ *
3626
+ * Throughput represents the maximum messages per second (mps) that can be sent/received.
3627
+ * - Default: 80 mps
3628
+ * - Automatic upgrade to 1,000 mps available for eligible numbers
3629
+ * - WhatsApp Business app coexistence numbers: fixed at 5 mps
3630
+ *
3631
+ * @returns Current throughput information including the level (STANDARD, HIGH, or NOT_APPLICABLE)
3632
+ *
3633
+ * @example
3634
+ * const throughput = await whatsappClient.phoneNumber.getThroughput();
3635
+ * console.log(throughput.throughput.level); // 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE'
3636
+ */
3637
+ getThroughput(): Promise<ThroughputResponse>;
4146
3638
  }
4147
3639
  //#endregion
4148
3640
  //#region src/api/profile/BusinessProfileApi.d.ts
@@ -4497,6 +3989,7 @@ declare class WabaApi extends BaseAPI implements WABAClass {
4497
3989
  declare class WhatsApp {
4498
3990
  config: WabaConfigType;
4499
3991
  requester: Readonly<Requester>;
3992
+ blockUsers: BlockUsersApi;
4500
3993
  messages: MessagesApi;
4501
3994
  media: MediaApi;
4502
3995
  phoneNumbers: PhoneNumberApi;
@@ -4540,6 +4033,25 @@ declare function processWebhookMessages(request: Request, whatsapp: WhatsApp, ha
4540
4033
  preProcessHandler?: MessageHandler;
4541
4034
  postProcessHandler?: MessageHandler;
4542
4035
  }): Promise<Response>;
4036
+ /**
4037
+ * Create a standard ping response for WhatsApp Flow health checks
4038
+ * @returns Flow ping response object
4039
+ */
4040
+ declare function createFlowPingResponse(): {
4041
+ version: string;
4042
+ data: {
4043
+ status: string;
4044
+ };
4045
+ };
4046
+ /**
4047
+ * Create a standard error response for WhatsApp Flow error notifications
4048
+ * @returns Acknowledgement response for error notification
4049
+ */
4050
+ declare function createFlowErrorResponse(): {
4051
+ data: {
4052
+ acknowledged: boolean;
4053
+ };
4054
+ };
4543
4055
  /**
4544
4056
  * Handle flow requests
4545
4057
  */
@@ -4616,14 +4128,14 @@ interface ExpressWebhookConfig extends BaseWebhookConfig {
4616
4128
  path?: string;
4617
4129
  }
4618
4130
  declare function expressWebhookHandler(config: ExpressWebhookConfig): {
4619
- GET: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<ExpressResponse>;
4620
- POST: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<ExpressResponse>;
4131
+ GET: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<WebhookResponse>;
4132
+ POST: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<WebhookResponse>;
4621
4133
  webhook: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<any>;
4622
- flow: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<ExpressResponse>;
4134
+ flow: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => Promise<WebhookResponse>;
4623
4135
  processor: WebhookProcessor;
4624
4136
  };
4625
4137
  //#endregion
4626
- //#region src/core/webhook/frameworks/nextjs/nextjs.d.ts
4138
+ //#region src/core/webhook/frameworks/nextjs-page/nextjs-page.d.ts
4627
4139
  interface BaseApiRequest extends BaseRequest {
4628
4140
  method?: string;
4629
4141
  url?: string;
@@ -4639,11 +4151,11 @@ interface BaseApiResponse extends BaseResponse {
4639
4151
  setHeader(name: string, value: string): void;
4640
4152
  }
4641
4153
  interface NextJsWebhookConfig extends BaseWebhookConfig {}
4642
- declare function nextjsWebhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(config: NextJsWebhookConfig): {
4643
- GET: (req: TRequest, res: TResponse) => Promise<any>;
4644
- POST: (req: TRequest, res: TResponse) => Promise<any>;
4154
+ declare function nextjsPagesWebhookHandler<TRequest extends BaseApiRequest, TResponse extends BaseApiResponse>(config: NextJsWebhookConfig): {
4155
+ GET: (req: TRequest, res: TResponse) => Promise<WebhookResponse>;
4156
+ POST: (req: TRequest, res: TResponse) => Promise<WebhookResponse>;
4645
4157
  webhook: (req: TRequest, res: TResponse) => Promise<any>;
4646
- flow: (req: TRequest, res: TResponse) => Promise<any>;
4158
+ flow: (req: TRequest, res: TResponse) => Promise<WebhookResponse>;
4647
4159
  processor: WebhookProcessor;
4648
4160
  };
4649
4161
  //#endregion
@@ -4671,5 +4183,5 @@ declare function nextjsAppWebhookHandler(config: NextJsAppWebhookConfig): {
4671
4183
  //#region src/core/webhook/utils/generateXHub256Sig.d.ts
4672
4184
  declare const generateXHub256Sig: (body: string, appSecret: string) => string;
4673
4185
  //#endregion
4674
- export { AccountMode, AudioMediaObject, AudioMediaTypesEnum, AudioMessageBuilder, AuthenticationTemplateOptions, BaseClass, BodyOptions, BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, BusinessVerticalEnum, ButtonOptions, ButtonPositionEnum, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, CategoryEnum, CodeVerificationStatus, ComponentTypes, ComponentTypesEnum, ContactMessageBuilder, ContactMessageFactory, ContactObject, ConversationTypesEnum, CopyCodeButton, CouponTemplateOptions, CreateFlowResponse, CreateQrCodeRequest, CreateUploadSessionParams, CurrencyCodesEnum, CurrencyParameter, CurrencyParameterHelper, Cursors, DataLocalizationRegionEnum, DateTimeParameter, DateTimeParameterHelper, DocumentMediaObject, DocumentMediaTypesEnum, DocumentMessageBuilder, EncryptionApi, EncryptionClass, EncryptionPublicKeyResponse, ExpressRequest, ExpressResponse, ExpressWebhookConfig, Flow, FlowActionEnum, FlowApi, FlowAsset, FlowAssetsResponse, FlowButton, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHandler, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, FooterOptions, GeneralHeaderInterface, GeneralMessageBody, GeneralRequestBody, GetUploadHandleParams, HeaderOptions, HealthStatus, HealthStatusEntity, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaObject, ImageMediaTypesEnum, ImageMessageBuilder, InteractiveMessageBuilder, InteractiveMessageFactory, InteractiveObject, InteractiveTypesEnum, LanguagesEnum, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, LocationMessageBuilder, LocationMessageFactory, LocationObject, LocationParameter, LoggerInterface, MPMButton, MPMTemplateOptions, MediaApi, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, MediaMessageFactory, MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageHandler, MessageRequestBody, MessageRequestParams, MessageStatus, MessageTemplateObject, MessageTypesEnum, MessagesClass, MessagesResponse, MessagingLimitTier, MetaError, NextFunction, NextJsAppWebhookConfig, NextJsWebhookConfig, OTPButton, OTPTemplateOptions, Pagination, PaginationCursors, Paging, ParameterObject, ParametersTypesEnum, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, ReactionMessageBuilder, ReactionMessageFactory, ReactionParams, ReferralSourceTypesEnum, RegistrationApi, RegistrationClass, RegistrationRequest, RequestCodeMethodsEnum, RequestVerificationCodeRequest, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, SPMButton, SPMTemplateOptions, StatusEnum, StatusParams, StickerMediaObject, StickerMediaTypesEnum, StickerMessageBuilder, SubTypeEnum, SystemChangeTypesEnum, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateMessageBuilder, TemplateMessageFactory, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatusEnum, TextMessageBuilder, TextMessageFactory, TextMessageParams, TextObject, TextParameter, Throughput, ThroughputLevel, TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationParams, TwoStepVerificationRequest, URLButton, UpdateBusinessProfileRequest, UpdateFlowResponse, UpdateQrCodeRequest, UpdateWabaSubscription, UploadBusinessProfileResponse, UploadHandle, UploadMediaParams, UploadMediaResponse, UploadSession, UploadSessionResponse, ValidateFlowJsonResponse, VerifyCodeRequest, VideoMediaObject, VideoMediaTypesEnum, VideoMessageBuilder, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, WabaConfigType, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions, WebhookContact, WebhookEvent, WebhookMessage, WebhookProcessor, WebhookResponse, WebhookTypesEnum, WhatsApp, WhatsAppConfig, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, expressWebhookHandler, generateXHub256Sig, nextjsAppWebhookHandler, nextjsWebhookHandler, processFlowRequest, processWebhookMessages };
4186
+ export { AccountMode, AudioMediaObject, AudioMediaTypesEnum, AudioMessage, AuthenticationTemplateOptions, BaseClass, BlockUserObject, BlockUsersApi, BlockUsersClass, BlockUsersRequest, BlockUsersResponse, BlockedUserInfo, BodyOptions, BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, BusinessVerticalEnum, ButtonMessage, ButtonOptions, ButtonPositionEnum, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, CategoryEnum, CodeVerificationStatus, ComponentTypes, ComponentTypesEnum, ContactObject, ContactsMessage, ConversationTypesEnum, CopyCodeButton, CouponTemplateOptions, CreateFlowResponse, CreateQrCodeRequest, CreateUploadSessionParams, CurrencyCodesEnum, CurrencyParameter, Cursors, DataLocalizationRegionEnum, DateTimeParameter, DocumentMediaObject, DocumentMediaTypesEnum, DocumentMessage, EncryptionApi, EncryptionClass, EncryptionPublicKeyResponse, ErrorWebhookValue, ExpressRequest, ExpressResponse, ExpressWebhookConfig, FailedUserInfo, Flow, FlowActionEnum, FlowApi, FlowAsset, FlowAssetsResponse, FlowButton, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHandler, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, FooterOptions, GeneralHeaderInterface, GeneralMessageBody, GeneralRequestBody, GetUploadHandleParams, GroupMessage, HeaderOptions, HealthStatus, HealthStatusEntity, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaObject, ImageMediaTypesEnum, ImageMessage, InteractiveButtonReplyMessage, InteractiveListReplyMessage, InteractiveMessage, InteractiveObject, InteractiveTypesEnum, LanguagesEnum, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, ListBlockedUsersParams, ListBlockedUsersResponse, LocationMessage, LocationObject, LocationParameter, LoggerInterface, MPMButton, MPMTemplateOptions, MediaApi, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageHandler, MessageRequestBody, MessageRequestParams, MessageStatus, MessageTemplateObject, MessageTypesEnum, MessageWebhookValue, MessagesClass, MessagesResponse, MessagingLimitTier, MetaError, MetaErrorDetail, NextFunction, NextJsAppWebhookConfig, NextJsWebhookConfig, OTPButton, OTPTemplateOptions, OrderMessage, Pagination, PaginationCursors, Paging, PagingCursors, PagingInfo, ParametersTypesEnum, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, ReactionMessage, ReactionParams, ReferralSourceTypesEnum, RegistrationApi, RegistrationClass, RegistrationRequest, RequestCodeMethodsEnum, RequestVerificationCodeRequest, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, SPMButton, SPMTemplateOptions, StatusEnum, StatusParams, StatusWebhook, StatusWebhookValue, StickerMediaObject, StickerMediaTypesEnum, StickerMessage, SubTypeEnum, SystemChangeTypesEnum, SystemMessage, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatusEnum, TextMessage, TextMessageParams, TextObject, TextParameter, Throughput, ThroughputLevel, TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationParams, TwoStepVerificationRequest, URLButton, UnblockUsersRequest, UnsupportedMessage, UpdateBusinessProfileRequest, UpdateFlowResponse, UpdateQrCodeRequest, UpdateWabaSubscription, UploadBusinessProfileResponse, UploadHandle, UploadMediaParams, UploadMediaResponse, UploadSession, UploadSessionResponse, ValidateFlowJsonResponse, VerifyCodeRequest, VideoMediaObject, VideoMediaTypesEnum, VideoMessage, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, WabaConfigType, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions, WebhookContact, WebhookEvent, WebhookMessage, WebhookPayload, WebhookProcessor, WebhookResponse, WebhookTypesEnum, WebhookValue, WhatsApp, WhatsAppConfig, WhatsAppMessage, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createFlowErrorResponse, createFlowPingResponse, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, expressWebhookHandler, generateXHub256Sig, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, processFlowRequest, processWebhookMessages };
4675
4187
  //# sourceMappingURL=index.d.ts.map