bhoriwal 1.1.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +148 -10
  2. package/index.js +22 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,155 @@
1
- # bhoriwal
1
+ Bhoriwal
2
2
 
3
- Send WhatsApp text messages using WhatsApp Cloud API.
3
+ A Node.js WhatsApp SDK built on the official WhatsApp Cloud API.
4
+ Send text, media, templates, bulk messages, reactions, and more — easily.
4
5
 
5
- ## Installation
6
+ ES Module
7
+ ✅ Official Meta API
8
+ ✅ SDK-style (Bhoriwal.sendText())
9
+
10
+ 🚀 Installation
6
11
  npm install bhoriwal
7
12
 
8
- ## Usage
9
- ```js
10
- const { sendWhatsAppMessage } = require("bhoriwal");
11
13
 
12
- sendWhatsAppMessage({
13
- phoneNumberId: "PHONE_NUMBER_ID",
14
- accessToken: "ACCESS_TOKEN",
14
+ ⚠️ This package is ESM-only
15
+ Your project must use "type": "module"
16
+
17
+ 🔐 Prerequisites
18
+
19
+ You must have:
20
+
21
+ WhatsApp Cloud API access
22
+
23
+ Phone Number ID
24
+
25
+ Permanent Access Token
26
+
27
+ Set environment variables:
28
+
29
+ WA_PHONE_NUMBER_ID=xxxxxxxxxxxx
30
+ WA_ACCESS_TOKEN=EAAGxxxxxxxx
31
+ WA_BUSINESS_ACCOUNT_ID=xxxxxxxx
32
+
33
+ 📦 Import
34
+ import Bhoriwal from "bhoriwal";
35
+
36
+ ✉️ Send Text Message
37
+ await Bhoriwal.sendText({
38
+ phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
39
+ accessToken: process.env.WA_ACCESS_TOKEN,
40
+ to: "919999999999",
41
+ message: "Hello from Bhoriwal 🚀"
42
+ });
43
+
44
+ 📞 Check Phone Number (Reachability)
45
+ await Bhoriwal.checkPhoneNumber({
46
+ phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
47
+ accessToken: process.env.WA_ACCESS_TOKEN,
48
+ to: "919999999999"
49
+ });
50
+
51
+ 🖼️ Send Media (Image / Video / Audio / Document)
52
+ await Bhoriwal.sendMedia({
53
+ phoneNumberId,
54
+ accessToken,
15
55
  to: "919999999999",
16
- message: "Hello World"
56
+ type: "image", // image | video | audio | document
57
+ link: "https://example.com/file.jpg",
58
+ caption: "Optional caption"
59
+ });
60
+
61
+
62
+ Examples:
63
+
64
+ type: "video"
65
+ type: "audio"
66
+ type: "document"
67
+
68
+ 📝 Create Message Template
69
+ await Bhoriwal.createTemplate({
70
+ accessToken: process.env.WA_ACCESS_TOKEN,
71
+ businessAccountId: process.env.WA_BUSINESS_ACCOUNT_ID,
72
+ name: "order_update",
73
+ language: "en_US",
74
+ body: "Your order {{1}} is shipped"
75
+ });
76
+
77
+ 🗑️ Delete Message Template
78
+ await Bhoriwal.deleteTemplate({
79
+ accessToken: process.env.WA_ACCESS_TOKEN,
80
+ businessAccountId: process.env.WA_BUSINESS_ACCOUNT_ID,
81
+ name: "order_update"
82
+ });
83
+
84
+ 📤 Send Bulk Template Messages
85
+ await Bhoriwal.sendBulkTemplateMessages({
86
+ phoneNumberId,
87
+ accessToken,
88
+ templateName: "order_update",
89
+ language: "en_US",
90
+ toList: [
91
+ "919999999999",
92
+ "918888888888"
93
+ ]
17
94
  });
95
+
96
+ 👁️ Mark Message as Read
97
+ await Bhoriwal.markAsRead({
98
+ phoneNumberId,
99
+ accessToken,
100
+ messageId: "wamid.HBgM..."
101
+ });
102
+
103
+ 😀 React on a Message
104
+ await Bhoriwal.reactOnMessage({
105
+ phoneNumberId,
106
+ accessToken,
107
+ messageId: "wamid.HBgM...",
108
+ emoji: "👍"
109
+ });
110
+
111
+ 🚫 Block User
112
+ await Bhoriwal.blockUser({
113
+ phoneNumberId,
114
+ accessToken,
115
+ to: "919999999999"
116
+ });
117
+
118
+ ✅ Unblock User
119
+ await Bhoriwal.unblockUser({
120
+ phoneNumberId,
121
+ accessToken,
122
+ to: "919999999999"
123
+ });
124
+
125
+ 🧠 Design Philosophy
126
+
127
+ SDK-style API (Bhoriwal.sendText)
128
+
129
+ No direct Meta API handling in user code
130
+
131
+ Object-based parameters (future-proof)
132
+
133
+ Easy upgrades without breaking code
134
+
135
+ ⚠️ Important Notes
136
+
137
+ ❌ Do NOT use unofficial WhatsApp APIs
138
+
139
+ ✅ This package uses official WhatsApp Cloud API
140
+
141
+ 🚫 WhatsApp may block numbers if spam rules are violated
142
+
143
+ 📌 Versioning
144
+
145
+ This package follows Semantic Versioning:
146
+
147
+ patch → bug fixes
148
+
149
+ minor → new features
150
+
151
+ major → breaking changes
152
+
153
+ 📜 License
154
+
155
+ MIT © Bhoriwal
package/index.js CHANGED
@@ -1,9 +1,23 @@
1
- export * from "./src/sendText.js";
2
- export * from "./src/checkPhone.js";
3
- export * from "./src/template.js";
4
- export * from "./src/bulkTemplate.js";
5
- export * from "./src/media.js";
6
- export * from "./src/read.js";
7
- export * from "./src/reactions.js";
8
- export * from "./src/block.js";
1
+ import { sendTextMessage } from "./src/sendText.js";
2
+ import { checkPhoneNumber } from "./src/checkPhone.js";
3
+ import { createTemplate, deleteTemplate } from "./src/template.js";
4
+ import { sendBulkTemplateMessages } from "./src/bulkTemplate.js";
5
+ import { sendMedia } from "./src/media.js";
6
+ import { markAsRead } from "./src/read.js";
7
+ import { reactOnMessage } from "./src/reactions.js";
8
+ import { blockUser, unblockUser } from "./src/block.js";
9
9
 
10
+ const Bhoriwal = {
11
+ sendText: sendTextMessage,
12
+ checkPhoneNumber,
13
+ createTemplate,
14
+ deleteTemplate,
15
+ sendBulkTemplateMessages,
16
+ sendMedia,
17
+ markAsRead,
18
+ reactOnMessage,
19
+ blockUser,
20
+ unblockUser
21
+ };
22
+
23
+ export default Bhoriwal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhoriwal",
3
- "version": "1.1.1",
3
+ "version": "2.0.1",
4
4
  "description": "Send WhatsApp text messages easily",
5
5
  "type": "module",
6
6
  "main": "index.js",