@queenanya/baileys 9.5.1 → 9.5.3-beta.2

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.
Files changed (158) hide show
  1. package/README.md +614 -0
  2. package/lib/Defaults/index.d.ts +5 -0
  3. package/lib/Defaults/index.d.ts.map +1 -1
  4. package/lib/Defaults/index.js +32 -3
  5. package/lib/Defaults/index.js.map +1 -1
  6. package/lib/Socket/business.d.ts +35 -2
  7. package/lib/Socket/business.d.ts.map +1 -1
  8. package/lib/Socket/chats.d.ts +3 -1
  9. package/lib/Socket/chats.d.ts.map +1 -1
  10. package/lib/Socket/chats.js +49 -4
  11. package/lib/Socket/chats.js.map +1 -1
  12. package/lib/Socket/communities.d.ts +35 -2
  13. package/lib/Socket/communities.d.ts.map +1 -1
  14. package/lib/Socket/groups.d.ts +1 -0
  15. package/lib/Socket/groups.d.ts.map +1 -1
  16. package/lib/Socket/index.d.ts +35 -2
  17. package/lib/Socket/index.d.ts.map +1 -1
  18. package/lib/Socket/messages-recv.d.ts +36 -3
  19. package/lib/Socket/messages-recv.d.ts.map +1 -1
  20. package/lib/Socket/messages-recv.js +61 -44
  21. package/lib/Socket/messages-recv.js.map +1 -1
  22. package/lib/Socket/messages-send.d.ts +11 -5
  23. package/lib/Socket/messages-send.d.ts.map +1 -1
  24. package/lib/Socket/messages-send.js +110 -78
  25. package/lib/Socket/messages-send.js.map +1 -1
  26. package/lib/Socket/newsletter.d.ts +1 -0
  27. package/lib/Socket/newsletter.d.ts.map +1 -1
  28. package/lib/Socket/newsletter.js +2 -2
  29. package/lib/Socket/newsletter.js.map +1 -1
  30. package/lib/Socket/socket.d.ts.map +1 -1
  31. package/lib/Socket/socket.js +77 -11
  32. package/lib/Socket/socket.js.map +1 -1
  33. package/lib/Types/Call.d.ts +8 -0
  34. package/lib/Types/Call.d.ts.map +1 -1
  35. package/lib/Types/Events.d.ts +2 -0
  36. package/lib/Types/Events.d.ts.map +1 -1
  37. package/lib/Types/Message.d.ts +161 -12
  38. package/lib/Types/Message.d.ts.map +1 -1
  39. package/lib/Types/index.d.ts +9 -0
  40. package/lib/Types/index.d.ts.map +1 -1
  41. package/lib/Types/index.js.map +1 -1
  42. package/lib/Utils/browser-utils.d.ts +13 -0
  43. package/lib/Utils/browser-utils.d.ts.map +1 -1
  44. package/lib/Utils/browser-utils.js +90 -10
  45. package/lib/Utils/browser-utils.js.map +1 -1
  46. package/lib/Utils/event-buffer.js +8 -1
  47. package/lib/Utils/event-buffer.js.map +1 -1
  48. package/lib/Utils/history.d.ts +2 -0
  49. package/lib/Utils/history.d.ts.map +1 -1
  50. package/lib/Utils/history.js +2 -1
  51. package/lib/Utils/history.js.map +1 -1
  52. package/lib/Utils/index.d.ts +2 -0
  53. package/lib/Utils/index.d.ts.map +1 -1
  54. package/lib/Utils/index.js +2 -0
  55. package/lib/Utils/index.js.map +1 -1
  56. package/lib/Utils/interactive-message.d.ts +201 -0
  57. package/lib/Utils/interactive-message.d.ts.map +1 -0
  58. package/lib/Utils/interactive-message.js +256 -0
  59. package/lib/Utils/interactive-message.js.map +1 -0
  60. package/lib/Utils/messages-media.d.ts +16 -2
  61. package/lib/Utils/messages-media.d.ts.map +1 -1
  62. package/lib/Utils/messages-media.js +19 -10
  63. package/lib/Utils/messages-media.js.map +1 -1
  64. package/lib/Utils/messages.d.ts.map +1 -1
  65. package/lib/Utils/messages.js +408 -11
  66. package/lib/Utils/messages.js.map +1 -1
  67. package/lib/Utils/offline-node-processor.d.ts +17 -0
  68. package/lib/Utils/offline-node-processor.d.ts.map +1 -0
  69. package/lib/Utils/offline-node-processor.js +40 -0
  70. package/lib/Utils/offline-node-processor.js.map +1 -0
  71. package/lib/Utils/stanza-ack.d.ts +11 -0
  72. package/lib/Utils/stanza-ack.d.ts.map +1 -0
  73. package/lib/Utils/stanza-ack.js +38 -0
  74. package/lib/Utils/stanza-ack.js.map +1 -0
  75. package/lib/Utils/use-mongo-file-auth-state.d.ts +16 -0
  76. package/lib/Utils/use-mongo-file-auth-state.d.ts.map +1 -0
  77. package/lib/Utils/use-mongo-file-auth-state.js +60 -0
  78. package/lib/Utils/use-mongo-file-auth-state.js.map +1 -0
  79. package/lib/Utils/validate-connection.d.ts.map +1 -1
  80. package/lib/Utils/validate-connection.js +15 -2
  81. package/lib/Utils/validate-connection.js.map +1 -1
  82. package/lib/WABinary/generic-utils.d.ts +9 -0
  83. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  84. package/lib/WABinary/generic-utils.js +23 -0
  85. package/lib/WABinary/generic-utils.js.map +1 -1
  86. package/lib/WABinary/jid-utils.d.ts +3 -0
  87. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  88. package/lib/WABinary/jid-utils.js +4 -0
  89. package/lib/WABinary/jid-utils.js.map +1 -1
  90. package/lib/addons/anti-delete.d.ts +72 -0
  91. package/lib/addons/anti-delete.d.ts.map +1 -0
  92. package/lib/addons/anti-delete.js +165 -0
  93. package/lib/addons/anti-delete.js.map +1 -0
  94. package/lib/addons/auto-reply.d.ts +67 -0
  95. package/lib/addons/auto-reply.d.ts.map +1 -0
  96. package/lib/addons/auto-reply.js +145 -0
  97. package/lib/addons/auto-reply.js.map +1 -0
  98. package/lib/addons/chat-control.d.ts +57 -0
  99. package/lib/addons/chat-control.d.ts.map +1 -0
  100. package/lib/addons/chat-control.js +128 -0
  101. package/lib/addons/chat-control.js.map +1 -0
  102. package/lib/addons/from-chats.d.ts +30 -0
  103. package/lib/addons/from-chats.d.ts.map +1 -0
  104. package/lib/addons/from-chats.js +38 -0
  105. package/lib/addons/from-chats.js.map +1 -0
  106. package/lib/addons/from-messages-recv.d.ts +59 -0
  107. package/lib/addons/from-messages-recv.d.ts.map +1 -0
  108. package/lib/addons/from-messages-recv.js +326 -0
  109. package/lib/addons/from-messages-recv.js.map +1 -0
  110. package/lib/addons/from-messages-send.d.ts +50 -0
  111. package/lib/addons/from-messages-send.d.ts.map +1 -0
  112. package/lib/addons/from-messages-send.js +148 -0
  113. package/lib/addons/from-messages-send.js.map +1 -0
  114. package/lib/addons/from-messages.d.ts +52 -0
  115. package/lib/addons/from-messages.d.ts.map +1 -0
  116. package/lib/addons/from-messages.js +305 -0
  117. package/lib/addons/from-messages.js.map +1 -0
  118. package/lib/addons/index.d.ts +28 -0
  119. package/lib/addons/index.d.ts.map +1 -0
  120. package/lib/addons/index.js +44 -0
  121. package/lib/addons/index.js.map +1 -0
  122. package/lib/addons/interactive-message.d.ts +201 -0
  123. package/lib/addons/interactive-message.d.ts.map +1 -0
  124. package/lib/addons/interactive-message.js +256 -0
  125. package/lib/addons/interactive-message.js.map +1 -0
  126. package/lib/addons/jid-plotting.d.ts +53 -0
  127. package/lib/addons/jid-plotting.d.ts.map +1 -0
  128. package/lib/addons/jid-plotting.js +150 -0
  129. package/lib/addons/jid-plotting.js.map +1 -0
  130. package/lib/addons/message-search.d.ts +38 -0
  131. package/lib/addons/message-search.d.ts.map +1 -0
  132. package/lib/addons/message-search.js +171 -0
  133. package/lib/addons/message-search.js.map +1 -0
  134. package/lib/addons/message-utils.d.ts +14 -0
  135. package/lib/addons/message-utils.d.ts.map +1 -0
  136. package/lib/addons/message-utils.js +174 -0
  137. package/lib/addons/message-utils.js.map +1 -0
  138. package/lib/addons/scheduling.d.ts +40 -0
  139. package/lib/addons/scheduling.d.ts.map +1 -0
  140. package/lib/addons/scheduling.js +110 -0
  141. package/lib/addons/scheduling.js.map +1 -0
  142. package/lib/addons/status-posting.d.ts +120 -0
  143. package/lib/addons/status-posting.d.ts.map +1 -0
  144. package/lib/addons/status-posting.js +94 -0
  145. package/lib/addons/status-posting.js.map +1 -0
  146. package/lib/addons/templates.d.ts +72 -0
  147. package/lib/addons/templates.d.ts.map +1 -0
  148. package/lib/addons/templates.js +145 -0
  149. package/lib/addons/templates.js.map +1 -0
  150. package/lib/addons/vcard.d.ts +57 -0
  151. package/lib/addons/vcard.d.ts.map +1 -0
  152. package/lib/addons/vcard.js +88 -0
  153. package/lib/addons/vcard.js.map +1 -0
  154. package/lib/index.d.ts +1 -0
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +1 -0
  157. package/lib/index.js.map +1 -1
  158. package/package.json +3 -2
package/README.md CHANGED
@@ -2,8 +2,25 @@
2
2
 
3
3
  <div align='center'>Baileys is a WebSockets-based TypeScript library for interacting with the WhatsApp Web API.</div>
4
4
 
5
+ > [!CAUTION]
6
+ > NOTICE OF BREAKING CHANGE.
7
+ >
8
+ > As of 7.0.0, multiple breaking changes were introduced into the library.
9
+ >
10
+ > Please check out https://whiskey.so/migrate-latest for more information.
11
+
12
+ # Important Note
13
+
14
+ This is a temporary README.md, the new guide is in development and will this file will be replaced with .github/README.md (already a default on GitHub).
15
+
5
16
  New guide link: https://baileys.wiki
6
17
 
18
+ # Get Support
19
+
20
+ If you'd like business to enterprise-level support from Rajeh, the current maintainer of Baileys, you can book a video chat. Book a 1 hour time slot by contacting him on Discord or pre-ordering [here](https://purpshell.dev/book). The earlier you pre-order the better, as his time slots usually fill up very quickly. He offers immense value per hour and will answer all your questions before the time runs out.
21
+
22
+ If you are a business, we encourage you to contribute back to the high development costs of the project and to feed the maintainers who dump tens of hours a week on this. You can do so by booking meetings or sponsoring below. All support, even in bona fide / contribution hours, is welcome by businesses of all sizes. This is not condoning or endorsing businesses to use the library. See the Disclaimer below.
23
+
7
24
  # Sponsor
8
25
 
9
26
  If you'd like to financially support this project, you can do so by supporting the current maintainer [here](https://purpshell.dev/sponsor).
@@ -163,6 +180,31 @@ import makeWASocket from '@whiskeysockets/baileys'
163
180
  - [Broadcast Lists & Stories](#broadcast-lists--stories)
164
181
  - [Send Broadcast & Stories](#send-broadcast--stories)
165
182
  - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
183
+ - [iOS & Android Support](#ios--android-support)
184
+ - [Anti-Delete System](#anti-delete-system)
185
+ - [Auto-Reply System](#auto-reply-system)
186
+ - [Message Scheduler](#message-scheduler)
187
+ - [Interactive Messages](#interactive-messages)
188
+ - [Buttons Message](#buttons-message)
189
+ - [Template Buttons Message](#template-buttons-message)
190
+ - [Interactive Buttons Message](#interactive-buttons-message)
191
+ - [List Message](#list-message)
192
+ - [Product List Message](#product-list-message)
193
+ - [Shop Message](#shop-message)
194
+ - [Collection Message](#collection-message)
195
+ - [Cards / Carousel Message](#cards--carousel-message)
196
+ - [Album Message](#album-message)
197
+ - [Status Mentions](#status-mentions)
198
+ - [Call Functions](#call-functions)
199
+ - [Reject Call](#reject-call-1)
200
+ - [Initiate Call](#initiate-call)
201
+ - [Accept / Terminate Call](#accept--terminate-call)
202
+ - [Single File Auth State](#single-file-auth-state)
203
+ - [Contact Cards (vCard)](#contact-cards-vcard)
204
+ - [JID Utilities](#jid-utilities)
205
+ - [Message Search](#message-search)
206
+ - [Templates](#templates)
207
+ - [Chat Control](#chat-control)
166
208
  - [Writing Custom Functionality](#writing-custom-functionality)
167
209
  - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
168
210
  - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
@@ -1366,6 +1408,578 @@ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => {})
1366
1408
  sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => {})
1367
1409
  ```
1368
1410
 
1411
+ # iOS & Android Support
1412
+
1413
+ By default this patched version uses an iOS browser identity (same as addons). You can switch to Android if needed:
1414
+
1415
+ ```ts
1416
+ import makeWASocket, { Browsers } from 'baileys'
1417
+
1418
+ // iOS (default — no change needed)
1419
+ const sock = makeWASocket({})
1420
+
1421
+ // Explicit iOS
1422
+ const sock = makeWASocket({
1423
+ browser: Browsers.iOS('Chrome')
1424
+ })
1425
+
1426
+ // Android
1427
+ const sock = makeWASocket({
1428
+ browser: Browsers.android('Chrome')
1429
+ })
1430
+ ```
1431
+
1432
+ ---
1433
+
1434
+ # Anti-Delete System
1435
+
1436
+ Stores incoming messages in memory and recovers them when a sender deletes them.
1437
+
1438
+ ```ts
1439
+ import { MessageStore, createMessageStoreHandler, createAntiDeleteHandler, isDeleteMessage } from 'baileys'
1440
+
1441
+ const store = new MessageStore({
1442
+ maxMessagesPerChat: 1000, // max messages per chat (default: 1000)
1443
+ ttl: 24 * 60 * 60 * 1000, // keep for 24h (default)
1444
+ cleanupInterval: 60 * 60 * 1000 // cleanup every 1h (default)
1445
+ })
1446
+
1447
+ // Store every incoming message
1448
+ sock.ev.on('messages.upsert', createMessageStoreHandler(store))
1449
+
1450
+ // Detect and recover deleted messages
1451
+ sock.ev.on('messages.update', updates => {
1452
+ const deleted = createAntiDeleteHandler(store)(updates)
1453
+ for (const info of deleted) {
1454
+ console.log('Message was deleted:', info.originalMessage)
1455
+ console.log('Deleted by:', info.deletedBy)
1456
+ console.log('Deleted at:', new Date(info.deletedAt))
1457
+ }
1458
+ })
1459
+
1460
+ // Manual lookup
1461
+ const original = store.getOriginalMessage(key)
1462
+
1463
+ // Stats
1464
+ console.log(store.getStats())
1465
+ // { totalChats: 5, totalMessages: 120, totalDeleted: 3 }
1466
+
1467
+ // Stop cleanup timer when done
1468
+ store.stopCleanup()
1469
+ ```
1470
+
1471
+ ---
1472
+
1473
+ # Auto-Reply System
1474
+
1475
+ Rule-based automatic reply system with cooldowns, typing simulation, and JID filtering.
1476
+
1477
+ ```ts
1478
+ import { createAutoReply } from 'baileys'
1479
+
1480
+ const autoReply = createAutoReply(
1481
+ (jid, content, options) => sock.sendMessage(jid, content, options),
1482
+ (jid, presence) => sock.sendPresenceUpdate(presence as any, jid),
1483
+ {
1484
+ globalCooldown: 1000, // ms between any reply to same JID
1485
+ simulateTyping: true, // show typing indicator before reply
1486
+ typingDuration: 1500, // ms to show typing
1487
+ multiMatch: false // stop at first matching rule
1488
+ }
1489
+ )
1490
+
1491
+ // Add a keyword rule
1492
+ autoReply.addRule({
1493
+ keywords: ['hello', 'hi'],
1494
+ response: { text: 'Hello! How can I help?' },
1495
+ cooldown: 5000, // 5s cooldown per JID
1496
+ priority: 10,
1497
+ quoted: true // quote the original message
1498
+ })
1499
+
1500
+ // Add an exact match rule
1501
+ autoReply.addRule({
1502
+ exactMatch: '!ping',
1503
+ response: { text: 'pong 🏓' },
1504
+ privateOnly: true // only in private chats
1505
+ })
1506
+
1507
+ // Add a regex rule
1508
+ autoReply.addRule({
1509
+ pattern: /order\s*#?(\d+)/i,
1510
+ response: async (msg, match) => ({ text: `Looking up order ${match[1]}...` }),
1511
+ groupsOnly: true,
1512
+ allowedJids: ['1234567890@g.us']
1513
+ })
1514
+
1515
+ // Process every incoming message
1516
+ sock.ev.on('messages.upsert', async ({ messages }) => {
1517
+ for (const msg of messages) {
1518
+ if (!msg.key.fromMe) await autoReply.processMessage(msg)
1519
+ }
1520
+ })
1521
+
1522
+ // Manage rules
1523
+ const rule = autoReply.addRule({ keywords: ['bye'], response: { text: 'Goodbye!' } })
1524
+ autoReply.setRuleActive(rule.id, false) // disable
1525
+ autoReply.removeRule(rule.id) // remove
1526
+ autoReply.clearRules() // remove all
1527
+ ```
1528
+
1529
+ ---
1530
+
1531
+ # Message Scheduler
1532
+
1533
+ Schedule messages to be sent at a future time.
1534
+
1535
+ ```ts
1536
+ import { createMessageScheduler } from 'baileys'
1537
+
1538
+ const scheduler = createMessageScheduler((jid, content) => sock.sendMessage(jid, content), {
1539
+ maxQueue: 1000,
1540
+ checkInterval: 1000, // check every 1s
1541
+ onSent: (scheduled, msg) => console.log('Sent:', scheduled.id),
1542
+ onFailed: (scheduled, err) => console.error('Failed:', err.message)
1543
+ })
1544
+
1545
+ // Schedule at a specific time
1546
+ const item = scheduler.schedule(
1547
+ '1234567890@s.whatsapp.net',
1548
+ { text: 'Good morning! ☀️' },
1549
+ new Date('2025-06-01T08:00:00')
1550
+ )
1551
+
1552
+ // Schedule after a delay (ms)
1553
+ scheduler.scheduleDelay('1234567890@s.whatsapp.net', { text: 'Reminder after 10 minutes' }, 10 * 60 * 1000)
1554
+
1555
+ // Cancel a scheduled message
1556
+ scheduler.cancel(item.id)
1557
+
1558
+ // Cancel all messages to a JID
1559
+ scheduler.cancelForJid('1234567890@s.whatsapp.net')
1560
+
1561
+ // List pending
1562
+ const pending = scheduler.getPending()
1563
+ console.log(`${pending.length} messages scheduled`)
1564
+
1565
+ // Stop the scheduler
1566
+ scheduler.stop()
1567
+ ```
1568
+
1569
+ ---
1570
+
1571
+ # Interactive Messages
1572
+
1573
+ ## Buttons Message
1574
+
1575
+ ```ts
1576
+ await sock.sendMessage(jid, {
1577
+ text: 'Choose an option:',
1578
+ buttons: [
1579
+ { buttonId: 'btn1', buttonText: { displayText: 'Option 1' } },
1580
+ { buttonId: 'btn2', buttonText: { displayText: 'Option 2' } },
1581
+ { buttonId: 'btn3', buttonText: { displayText: 'Option 3' } }
1582
+ ],
1583
+ footer: 'footer text'
1584
+ })
1585
+ ```
1586
+
1587
+ ## Template Buttons Message
1588
+
1589
+ ```ts
1590
+ import { proto } from 'baileys'
1591
+
1592
+ await sock.sendMessage(jid, {
1593
+ text: 'Template message',
1594
+ templateButtons: [
1595
+ { quickReplyButton: { displayText: 'Quick Reply', id: 'qr1' } },
1596
+ { urlButton: { displayText: 'Visit Website', url: 'https://example.com' } },
1597
+ { callButton: { displayText: 'Call Us', phoneNumber: '+1234567890' } }
1598
+ ],
1599
+ footer: 'footer text'
1600
+ })
1601
+ ```
1602
+
1603
+ ## Interactive Buttons Message
1604
+
1605
+ Works on both iOS and Android:
1606
+
1607
+ ```ts
1608
+ await sock.sendMessage(jid, {
1609
+ text: 'Pick one:',
1610
+ interactiveButtons: [
1611
+ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Yes', id: 'yes' }) },
1612
+ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'No', id: 'no' }) }
1613
+ ],
1614
+ footer: 'footer text'
1615
+ })
1616
+
1617
+ // With image header
1618
+ await sock.sendMessage(jid, {
1619
+ image: { url: 'https://example.com/image.jpg' },
1620
+ caption: 'Check this out',
1621
+ interactiveButtons: [
1622
+ { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Buy Now', id: 'buy' }) }
1623
+ ]
1624
+ })
1625
+ ```
1626
+
1627
+ ## List Message
1628
+
1629
+ ```ts
1630
+ await sock.sendMessage(jid, {
1631
+ text: 'Here are your options',
1632
+ sections: [
1633
+ {
1634
+ title: 'Section 1',
1635
+ rows: [
1636
+ { title: 'Option 1', rowId: 'opt1', description: 'Description 1' },
1637
+ { title: 'Option 2', rowId: 'opt2', description: 'Description 2' }
1638
+ ]
1639
+ },
1640
+ {
1641
+ title: 'Section 2',
1642
+ rows: [{ title: 'Option 3', rowId: 'opt3' }]
1643
+ }
1644
+ ],
1645
+ buttonText: 'Tap to choose',
1646
+ title: 'Menu',
1647
+ footer: 'footer text'
1648
+ })
1649
+ ```
1650
+
1651
+ ## Product List Message
1652
+
1653
+ ```ts
1654
+ await sock.sendMessage(jid, {
1655
+ text: 'Our products',
1656
+ productList: [
1657
+ {
1658
+ title: 'Featured',
1659
+ products: [{ productId: 'prod_001' }, { productId: 'prod_002' }]
1660
+ }
1661
+ ],
1662
+ title: 'Shop',
1663
+ buttonText: 'View',
1664
+ footer: 'Tap to browse',
1665
+ businessOwnerJid: '1234567890@s.whatsapp.net',
1666
+ thumbnail: { url: 'https://example.com/thumb.jpg' }
1667
+ })
1668
+ ```
1669
+
1670
+ ## Shop Message
1671
+
1672
+ ```ts
1673
+ await sock.sendMessage(jid, {
1674
+ text: 'Welcome to our store',
1675
+ shop: { surface: 1, id: 'store_id' },
1676
+ title: 'Our Store',
1677
+ footer: 'Browse products'
1678
+ })
1679
+ ```
1680
+
1681
+ ## Collection Message
1682
+
1683
+ ```ts
1684
+ await sock.sendMessage(jid, {
1685
+ text: 'Check our collection',
1686
+ collection: {
1687
+ bizJid: '1234567890@s.whatsapp.net',
1688
+ id: 'collection_id',
1689
+ messageVersion: 1
1690
+ },
1691
+ title: 'New Collection',
1692
+ footer: 'Limited time'
1693
+ })
1694
+ ```
1695
+
1696
+ ## Cards / Carousel Message
1697
+
1698
+ ```ts
1699
+ await sock.sendMessage(jid, {
1700
+ text: 'Check out our products',
1701
+ cards: [
1702
+ {
1703
+ image: { url: 'https://example.com/product1.jpg' },
1704
+ title: 'Product 1',
1705
+ body: 'Great product at a great price',
1706
+ footer: '$19.99',
1707
+ buttons: [{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Buy', id: 'buy_1' }) }]
1708
+ },
1709
+ {
1710
+ video: { url: 'https://example.com/product2.mp4' },
1711
+ title: 'Product 2',
1712
+ body: 'Watch the demo',
1713
+ footer: '$29.99',
1714
+ buttons: [{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Buy', id: 'buy_2' }) }]
1715
+ }
1716
+ ],
1717
+ footer: 'Swipe to see more'
1718
+ })
1719
+ ```
1720
+
1721
+ ## Album Message
1722
+
1723
+ Sends multiple images/videos as a grouped album:
1724
+
1725
+ ```ts
1726
+ await sock.sendMessage(jid, {
1727
+ album: [
1728
+ { image: { url: 'https://example.com/img1.jpg' }, caption: 'Photo 1' },
1729
+ { image: { url: 'https://example.com/img2.jpg' }, caption: 'Photo 2' },
1730
+ { video: { url: 'https://example.com/clip.mp4' }, caption: 'Video clip' }
1731
+ ]
1732
+ })
1733
+ ```
1734
+
1735
+ ---
1736
+
1737
+ # Status Mentions
1738
+
1739
+ Send a status and notify specific contacts/groups that they were mentioned:
1740
+
1741
+ ```ts
1742
+ // Mention individuals
1743
+ await sock.sendStatusMentions({ text: 'Check this out!', backgroundColor: '#25D366' }, [
1744
+ '1234567890@s.whatsapp.net',
1745
+ '0987654321@s.whatsapp.net'
1746
+ ])
1747
+
1748
+ // Mention all members of a group
1749
+ await sock.sendStatusMentions({ image: { url: 'https://example.com/photo.jpg' }, caption: 'New update!' }, [
1750
+ '1234567890@g.us'
1751
+ ])
1752
+ ```
1753
+
1754
+ ---
1755
+
1756
+ # Call Functions
1757
+
1758
+ ## Reject Call
1759
+
1760
+ ```ts
1761
+ sock.ev.on('call', async calls => {
1762
+ for (const call of calls) {
1763
+ if (call.status === 'offer') {
1764
+ await sock.rejectCall(call.id, call.from)
1765
+ }
1766
+ }
1767
+ })
1768
+ ```
1769
+
1770
+ ## Initiate Call
1771
+
1772
+ ```ts
1773
+ // Audio call
1774
+ const result = await sock.initiateCall('1234567890@s.whatsapp.net')
1775
+ console.log('Call ID:', result.callId)
1776
+
1777
+ // Video call
1778
+ const result = await sock.initiateCall('1234567890@s.whatsapp.net', { isVideo: true })
1779
+ ```
1780
+
1781
+ ## Accept / Terminate Call
1782
+
1783
+ ```ts
1784
+ // Accept an incoming call
1785
+ await sock.acceptCall(call.id, call.from, call.isVideo)
1786
+
1787
+ // Hang up / terminate
1788
+ await sock.terminateCall(call.id, call.from)
1789
+
1790
+ // Cancel an outgoing call
1791
+ await sock.cancelCall(callId, toJid)
1792
+
1793
+ // Mute/unmute during a call
1794
+ await sock.muteCall(call.id, call.from, toJid, true) // mute
1795
+ await sock.muteCall(call.id, call.from, toJid, false) // unmute
1796
+ ```
1797
+
1798
+ ---
1799
+
1800
+ # Single File Auth State
1801
+
1802
+ Alternative to `useMultiFileAuthState` — stores everything in a single JSON file:
1803
+
1804
+ ```ts
1805
+ import { useSingleFileAuthState } from 'baileys'
1806
+
1807
+ const { state, saveCreds } = await useSingleFileAuthState('./auth.json')
1808
+
1809
+ const sock = makeWASocket({ auth: state })
1810
+ sock.ev.on('creds.update', saveCreds)
1811
+ ```
1812
+
1813
+ ---
1814
+
1815
+ # Contact Cards (vCard)
1816
+
1817
+ Generate and send vCard contact messages:
1818
+
1819
+ ```ts
1820
+ import { generateVCard, createContactCard, createContactCards, quickContact } from 'baileys'
1821
+
1822
+ // Single contact
1823
+ await sock.sendMessage(
1824
+ jid,
1825
+ createContactCard({
1826
+ fullName: 'John Doe',
1827
+ phones: [{ number: '+1234567890', type: 'CELL' }],
1828
+ emails: [{ email: 'john@example.com', type: 'WORK' }],
1829
+ organization: 'Acme Corp'
1830
+ })
1831
+ )
1832
+
1833
+ // Multiple contacts
1834
+ await sock.sendMessage(
1835
+ jid,
1836
+ createContactCards([
1837
+ { fullName: 'Alice', phones: [{ number: '+1111111111' }] },
1838
+ { fullName: 'Bob', phones: [{ number: '+2222222222' }] }
1839
+ ])
1840
+ )
1841
+
1842
+ // Quick shorthand
1843
+ await sock.sendMessage(jid, createContactCard(quickContact('Jane Smith', '+9876543210', { organization: 'ACME' })))
1844
+
1845
+ // Generate raw vCard string
1846
+ const vcard = generateVCard({
1847
+ fullName: 'John Doe',
1848
+ phones: [{ number: '+1234567890' }]
1849
+ })
1850
+ console.log(vcard)
1851
+ ```
1852
+
1853
+ ---
1854
+
1855
+ # JID Utilities
1856
+
1857
+ ```ts
1858
+ import { parseJid, plotJid, isSelf, getSenderPn, normalizePhoneToJid } from 'baileys'
1859
+
1860
+ // Parse a JID into its components
1861
+ const info = parseJid('1234567890@s.whatsapp.net')
1862
+ // { user, server, device, isLid, isPn, isGroup, isNewsletter, normalizedUser }
1863
+
1864
+ // Check if a JID is the connected account
1865
+ const senderInfo = getSenderPn(sock.authState.creds)
1866
+ console.log(isSelf('1234567890@s.whatsapp.net', senderInfo)) // true/false
1867
+
1868
+ // Convert phone number to JID
1869
+ const jid = normalizePhoneToJid('+1234567890')
1870
+ // → '1234567890@s.whatsapp.net'
1871
+
1872
+ // Plot a JID to its canonical form (resolves LID ↔ PN)
1873
+ const plotted = plotJid('1234567890@s.whatsapp.net')
1874
+ // { original, primary, info, pn?, lid? }
1875
+ ```
1876
+
1877
+ ---
1878
+
1879
+ # Message Search
1880
+
1881
+ Search through a collection of messages:
1882
+
1883
+ ```ts
1884
+ import { MessageSearchManager } from 'baileys'
1885
+
1886
+ const search = new MessageSearchManager()
1887
+
1888
+ // Feed messages into the index
1889
+ sock.ev.on('messages.upsert', ({ messages }) => {
1890
+ search.addMessages(messages)
1891
+ })
1892
+
1893
+ // Full-text search
1894
+ const results = search.search('hello world', {
1895
+ jid: '1234567890@s.whatsapp.net', // optional: limit to one chat
1896
+ fromMe: false,
1897
+ messageTypes: ['text'],
1898
+ limit: 20
1899
+ })
1900
+
1901
+ // Regex search
1902
+ const results = search.searchRegex(/order\s*#\d+/i)
1903
+
1904
+ // Get all messages in a chat
1905
+ const chatMessages = search.getByJid('1234567890@s.whatsapp.net')
1906
+
1907
+ // Get by type
1908
+ const images = search.getByType('image')
1909
+ ```
1910
+
1911
+ ---
1912
+
1913
+ # Templates
1914
+
1915
+ Create reusable message templates with variable substitution:
1916
+
1917
+ ```ts
1918
+ import { createTemplateManager, renderTemplate } from 'baileys'
1919
+
1920
+ // Create manager (comes with preset templates)
1921
+ const manager = createTemplateManager()
1922
+
1923
+ // Use a preset
1924
+ const msg = manager.render('welcome', { name: 'John', companyName: 'Acme' })
1925
+ await sock.sendMessage(jid, { text: msg })
1926
+
1927
+ // Create a custom template
1928
+ const tpl = manager.create({
1929
+ name: 'Appointment',
1930
+ content: 'Hi {{name}}, your appointment is on {{date}} at {{time:TBD}}.',
1931
+ category: 'reminder'
1932
+ })
1933
+
1934
+ // Render it
1935
+ const text = manager.render(tpl.id, { name: 'Alice', date: 'Monday', time: '3 PM' })
1936
+ await sock.sendMessage(jid, { text })
1937
+
1938
+ // One-off render without manager
1939
+ const text2 = renderTemplate('Hello {{name}}!', { name: 'Bob' })
1940
+
1941
+ // Available presets: 'welcome', 'order_confirmation', 'reminder', 'support_ticket', 'birthday'
1942
+ ```
1943
+
1944
+ ---
1945
+
1946
+ # Chat Control
1947
+
1948
+ ## Typing Indicator
1949
+
1950
+ ```ts
1951
+ import { createTypingIndicator } from 'baileys'
1952
+
1953
+ const typing = createTypingIndicator((jid, presence) => sock.sendPresenceUpdate(presence as any, jid))
1954
+
1955
+ await typing.startTyping(jid, { duration: 3000 }) // auto-stop after 3s
1956
+ await typing.startRecording(jid) // voice note indicator
1957
+ await typing.stopTyping(jid)
1958
+ await typing.stopAll()
1959
+
1960
+ // Simulate typing then send
1961
+ await typing.simulateTyping(jid, 2000, async () => {
1962
+ return sock.sendMessage(jid, { text: 'Hello!' })
1963
+ })
1964
+ ```
1965
+
1966
+ ## Read Receipt Control
1967
+
1968
+ ```ts
1969
+ import { createReadReceiptController } from 'baileys'
1970
+
1971
+ const readCtrl = createReadReceiptController(
1972
+ (jid, participant, ids) => sock.readMessages([{ remoteJid: jid, id: ids[0]!, participant }]),
1973
+ { enabled: true, readDelay: 500, excludeJids: ['1234567890@s.whatsapp.net'] }
1974
+ )
1975
+
1976
+ readCtrl.disable() // stop auto read receipts
1977
+ readCtrl.enable()
1978
+ await readCtrl.markRead(jid, participant, [messageId])
1979
+ ```
1980
+
1981
+ ---
1982
+
1369
1983
  # License
1370
1984
 
1371
1985
  Copyright (c) 2025 Rajeh Taher/WhiskeySockets
@@ -32,6 +32,9 @@ export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
32
32
  export declare const MEDIA_PATH_MAP: {
33
33
  [T in MediaType]?: string;
34
34
  };
35
+ export declare const NEWSLETTER_MEDIA_PATH_MAP: {
36
+ [T in MediaType]?: string;
37
+ };
35
38
  export declare const MEDIA_HKDF_KEY_MAPPING: {
36
39
  audio: string;
37
40
  document: string;
@@ -41,6 +44,8 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
41
44
  product: string;
42
45
  ptt: string;
43
46
  sticker: string;
47
+ 'sticker-pack': string;
48
+ 'thumbnail-sticker-pack': string;
44
49
  video: string;
45
50
  'thumbnail-document': string;
46
51
  'thumbnail-image': string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Defaults/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE9C,OAAO,KAAK,EAAuB,YAAY,EAAa,MAAM,UAAU,CAAA;AAM5E,eAAO,MAAM,kBAAkB,UAAkB,CAAA;AAEjD,eAAO,MAAM,cAAc,6BAA6B,CAAA;AACxD,eAAO,MAAM,iBAAiB,qCAAqC,CAAA;AACnE,eAAO,MAAM,iBAAiB,qCAA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