botcast-sdk 1.0.3 → 1.0.6

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # botcast-sdk
2
2
 
3
- Node.js and TypeScript client for [Botcast](https://botcast.site), a multi-instance WhatsApp REST API gateway.
3
+ Official Node.js and TypeScript SDK for [Botcast](https://botcast.site) — a high-performance, multi-instance API gateway supporting both **WhatsApp** and **Telegram MTProto** (`teleproto`).
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/botcast-sdk.svg?color=blue)](https://www.npmjs.com/package/botcast-sdk)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/botcast-sdk.svg)](https://www.npmjs.com/package/botcast-sdk)
@@ -11,14 +11,17 @@ Node.js and TypeScript client for [Botcast](https://botcast.site), a multi-insta
11
11
 
12
12
  ## Features
13
13
 
14
- - Zero runtime dependencies: built on native `fetch`.
15
- - Full TypeScript types for every request payload, response model, and error class.
16
- - Dual device pairing: scan a QR code string or request an 8-digit phone PIN to link without a camera.
17
- - 42 WhatsApp REST endpoints: text messages with mentions, OTPs, images, videos, audio, voice notes (PTT), documents, stickers, locations, contact vCards, and interactive polls.
18
- - Message controls: edit, delete for everyone, mark as read, reactions, pin messages, and forward.
19
- - Group management: create groups, manage participants, update subjects and descriptions, configure settings, and handle join requests.
20
- - Safety controls: configure daily caps on sent messages and new contacts.
21
- - Built-in webhook router: parse and handle inbound messages and connection events in Express, Fastify, Next.js, or raw Node HTTP.
14
+ - **Multi-Platform Support**: Connect and control both **WhatsApp** and **Telegram MTProto** instances with a single unified SDK.
15
+ - **Zero Runtime Dependencies**: Built directly on native `fetch` and modern standard web APIs.
16
+ - **Strict TypeScript Types**: Fully typed request parameters, response models, error classes, and event payloads.
17
+ - **Dual Authentication**:
18
+ - **WhatsApp**: Scan QR code string or request an 8-digit PIN code without a camera.
19
+ - **Telegram**: Scan QR code via *Telegram > Settings > Devices > Link Desktop Device* or authenticate via phone verification code with optional Cloud 2FA password.
20
+ - **Unified Messaging**: Send text messages, automated OTP codes, images, videos, audio, voice notes (PTT), documents, stickers, locations, contact cards, and interactive polls.
21
+ - **Message Operations**: Edit sent messages, delete for everyone (revoke), mark as read, reactions, pin messages, and forward.
22
+ - **Chat & History Management**: Query dialogs, contact lists, and message history for both platforms.
23
+ - **Group Administration**: Create groups, manage participants, configure permission modes, and share invite links (WhatsApp).
24
+ - **Real-Time Webhooks**: Built-in router and middleware for processing inbound messages and connection events across Express, Fastify, Next.js, or raw Node HTTP.
22
25
 
23
26
  ---
24
27
 
@@ -36,30 +39,60 @@ bun add botcast-sdk
36
39
 
37
40
  ---
38
41
 
39
- ## Quick start
42
+ ## Quick Start
43
+
44
+ ### 1. Admin & Fleet Management (Create, Manage & Renew Instances)
45
+
46
+ Use `BotcastAdminClient` with your Master Partner API Key (`bcast_live_...`) to programmatically create and manage customer instances:
47
+
48
+ ```typescript
49
+ import { BotcastAdminClient } from 'botcast-sdk';
50
+
51
+ const admin = new BotcastAdminClient({
52
+ baseUrl: 'https://botcast.site',
53
+ apiKey: process.env.BOTCAST_API_KEY!, // Master API Key
54
+ });
55
+
56
+ // List all instances
57
+ const { instances } = await admin.listInstances();
58
+
59
+ // Create a new WhatsApp or Telegram instance for a customer
60
+ const { instance } = await admin.createInstance({
61
+ name: 'Customer Store 1',
62
+ platform: 'whatsapp',
63
+ type: 'paid',
64
+ plan_months: 12,
65
+ });
66
+
67
+ // Renew subscription
68
+ await admin.renewInstance(instance.id, { months: 12 });
69
+ ```
70
+
71
+ ---
72
+
73
+ ### 2. WhatsApp Client
40
74
 
41
75
  ```typescript
42
76
  import { BotcastClient } from 'botcast-sdk';
43
77
 
44
- const client = new BotcastClient({
78
+ const whatsappBot = new BotcastClient({
45
79
  baseUrl: 'https://botcast.site', // or your self-hosted server URL
80
+ platform: 'whatsapp', // 'whatsapp' (default) or 'telegram'
46
81
  instanceId: 'your_instance_id',
47
82
  instanceToken: 'your_instance_token',
48
83
  });
49
84
 
50
85
  async function main() {
51
- // 1. Check instance connectivity
52
- const status = await client.getStatus();
53
- console.log(`Connected phone: ${status.phoneNumber || 'Not linked'}`);
86
+ // Check connectivity
87
+ const status = await whatsappBot.getStatus();
88
+ console.log(`WhatsApp state: ${status.status} (${status.phoneNumber || 'Unpaired'})`);
54
89
 
55
- // 2. Send a text message with user mentions
56
- const result = await client.messages.sendText('201012345678', 'Hello @201012345678!', {
57
- mentions: ['201012345678'],
58
- });
59
- console.log('Message ID:', result.messageId);
90
+ // Send a text message
91
+ const res = await whatsappBot.messages.sendText('201012345678', 'Hello from WhatsApp via Botcast SDK!');
92
+ console.log('Message sent! ID:', res.messageId);
60
93
 
61
- // 3. Send a secure 6-digit OTP code
62
- const otp = await client.messages.sendOTP('201012345678', {
94
+ // Send a secure 6-digit OTP code
95
+ const otp = await whatsappBot.messages.sendOTP('201012345678', {
63
96
  appName: 'My App',
64
97
  expiryMinutes: 5,
65
98
  });
@@ -69,12 +102,54 @@ async function main() {
69
102
  main().catch(console.error);
70
103
  ```
71
104
 
105
+ ---
106
+
107
+ ### 2. Telegram MTProto Client
108
+
109
+ ```typescript
110
+ import { BotcastClient } from 'botcast-sdk';
111
+
112
+ const telegramBot = new BotcastClient({
113
+ baseUrl: 'https://botcast.site',
114
+ platform: 'telegram',
115
+ instanceId: 'your_telegram_instance_id',
116
+ instanceToken: 'your_telegram_instance_token',
117
+ });
118
+
119
+ async function main() {
120
+ // Check connectivity
121
+ const status = await telegramBot.getStatus();
122
+ console.log(`Telegram state: ${status.status}`);
123
+
124
+ // Send a text message to a phone number or @username
125
+ const res = await telegramBot.messages.sendText('+1234567890', 'Hello from Telegram MTProto!');
126
+ console.log('Message ID:', res.messageId);
127
+
128
+ // Send a photo
129
+ await telegramBot.messages.sendImage('+1234567890', {
130
+ url: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800',
131
+ caption: 'Welcome flyer',
132
+ });
133
+
134
+ // Send OTP
135
+ const otp = await telegramBot.messages.sendOTP('+1234567890', {
136
+ appName: 'Security Portal',
137
+ });
138
+ console.log('Telegram OTP sent:', otp.codeSent);
139
+ }
140
+
141
+ main().catch(console.error);
142
+ ```
143
+
144
+ ---
145
+
72
146
  ### CommonJS (require)
73
147
 
74
148
  ```javascript
75
149
  const { BotcastClient } = require('botcast-sdk');
76
150
 
77
151
  const client = new BotcastClient({
152
+ platform: 'telegram', // or 'whatsapp'
78
153
  instanceId: 'your_instance_id',
79
154
  instanceToken: 'your_instance_token',
80
155
  });
@@ -82,108 +157,86 @@ const client = new BotcastClient({
82
157
 
83
158
  ---
84
159
 
85
- ## API reference
160
+ ## API Reference
86
161
 
87
- ### 1. Device pairing and lifecycle (`client.instances`)
162
+ ### 1. Device Pairing and Lifecycle (`client.instances`)
88
163
 
89
164
  ```typescript
90
165
  // 1. Get live status
91
166
  const status = await client.instances.getStatus();
92
- console.log('Socket state:', status.status); // 'connected' | 'pairing' | 'disconnected'
167
+ console.log('State:', status.status); // 'connected' | 'qr_ready' | 'stopped' | 'connecting'
93
168
 
94
169
  // 2. Option A: Get QR code string for camera scanning
170
+ // (WhatsApp: Linked Devices | Telegram: Settings > Devices > Link Desktop Device)
95
171
  const qr = await client.getQR(); // or client.instances.getQR()
96
- console.log('Scan QR:', qr.qr);
97
-
98
- // 3. Option B: Request 8-digit phone PIN code (link without scanning)
99
- const pair = await client.pairWithCode('201012345678'); // or client.instances.pairWithCode(...)
100
- console.log('Enter this PIN on WhatsApp notification:', pair.code); // e.g. "8492-0193"
172
+ console.log('QR DataURL:', qr.qr);
101
173
 
102
- // 4. Start, stop, or log out
103
- await client.instances.start(); // Boots socket connection
104
- await client.instances.stop(); // Suspends socket session
105
- await client.instances.logout(); // Unlinks device and deletes session
174
+ // 3. Option B: Request Phone Pairing / Login Code
175
+ // (WhatsApp sends 8-digit PIN | Telegram sends verification code into app)
176
+ const pair = await client.pairWithCode('+1234567890');
177
+ console.log('Code request status:', pair);
106
178
 
107
- // 5. Verify phone number on WhatsApp
108
- const check = await client.checkNumber('201012345678');
109
- console.log('Exists on WhatsApp:', check.exists, 'JID:', check.jid);
179
+ // 4. Complete Telegram Phone Login (with optional 2FA cloud password)
180
+ await client.instances.verifyCode('+1234567890', '12345', 'myCloudPassword2fa');
110
181
 
111
- // 6. Set presence state
112
- await client.instances.setPresence({
113
- presence: 'composing', // 'available' | 'unavailable' | 'composing' | 'recording' | 'paused'
114
- recipient: '201012345678',
115
- });
116
-
117
- // 7. Manage sandbox allowed numbers (developer tier)
118
- const allowed = await client.instances.getAllowedNumbers();
119
- await client.instances.setAllowedNumbers(['201012345678', '966500000000']);
182
+ // 5. Socket engine controls
183
+ await client.instances.start(); // Boots socket / MTProto connection
184
+ await client.instances.stop(); // Suspends socket session
185
+ await client.instances.logout(); // Unlinks device and clears session credentials
120
186
  ```
121
187
 
122
188
  ---
123
189
 
124
- ### 2. Message and media dispatching (`client.messages`)
190
+ ### 2. Message Dispatching (`client.messages`)
191
+
192
+ All messaging methods work across both **WhatsApp** and **Telegram**:
125
193
 
126
194
  ```typescript
127
- // 1. Text message with mentions and quoted replies
128
- await client.messages.sendText('201012345678', 'Hello World', {
129
- mentions: ['201012345678'],
130
- quotedMsgId: 'MSG_ID_TO_REPLY_TO',
195
+ // 1. Text message
196
+ await client.messages.sendText('+1234567890', 'Hello World', {
197
+ mentions: ['1234567890'], // WhatsApp mentions
131
198
  });
132
199
 
133
- // 2. Image
134
- await client.messages.sendImage('201012345678', {
200
+ // 2. Image / Photo
201
+ await client.messages.sendImage('+1234567890', {
135
202
  url: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800',
136
203
  caption: 'Photo preview',
137
204
  });
138
205
 
139
- // 3. Video (or round PTV message)
140
- await client.messages.sendVideo('201012345678', {
206
+ // 3. Video
207
+ await client.messages.sendVideo('+1234567890', {
141
208
  url: 'https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4',
142
209
  caption: 'Product tutorial video',
143
- ptv: false,
144
210
  });
145
211
 
146
- // 4. Voice note (PTT waveform) and audio
147
- await client.messages.sendVoice('201012345678', {
212
+ // 4. Voice note and audio
213
+ await client.messages.sendVoice('+1234567890', {
148
214
  url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
149
215
  });
150
216
 
151
- // 5. Document, PDF, or file attachment
152
- await client.messages.sendDocument('201012345678', {
217
+ // 5. Document / PDF / File
218
+ await client.messages.sendDocument('+1234567890', {
153
219
  url: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
154
220
  fileName: 'Invoice_2026.pdf',
155
- mimetype: 'application/pdf',
156
221
  caption: 'Monthly invoice statement',
157
222
  });
158
223
 
159
- // 6. Sticker
160
- await client.messages.sendSticker('201012345678', {
161
- url: 'https://raw.githubusercontent.com/WhatsApp/stickers/main/Android/app/src/main/assets/1/01_Cider_Happy.webp',
162
- });
163
-
164
- // 7. Location coordinates
165
- await client.messages.sendLocation('201012345678', {
224
+ // 6. Location coordinates
225
+ await client.messages.sendLocation('+1234567890', {
166
226
  latitude: 24.7136,
167
227
  longitude: 46.6753,
168
228
  name: 'Kingdom Tower',
169
229
  address: 'King Fahd Rd, Riyadh, Saudi Arabia',
170
230
  });
171
231
 
172
- // 8. Contact vCard
173
- await client.messages.sendContact('201012345678', {
174
- displayName: 'Support Team',
175
- vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:Support Team\nTEL;TYPE=CELL:+201012345678\nEND:VCARD',
232
+ // 7. Contact Card
233
+ await client.messages.sendContact('+1234567890', {
234
+ firstName: 'Support Agent',
235
+ phone: '+1234567890',
176
236
  });
177
237
 
178
- // 9. Interactive poll
179
- await client.messages.sendPoll('201012345678', {
180
- name: 'How do you rate Botcast API speed?',
181
- values: ['Fast', 'Good', 'Needs improvement'],
182
- selectableCount: 1,
183
- });
184
-
185
- // 10. OTP verification code
186
- const otp = await client.messages.sendOTP('201012345678', {
238
+ // 8. Automated OTP verification code
239
+ const otp = await client.messages.sendOTP('+1234567890', {
187
240
  appName: 'Botcast Portal',
188
241
  expiryMinutes: 5,
189
242
  });
@@ -191,7 +244,7 @@ const otp = await client.messages.sendOTP('201012345678', {
191
244
 
192
245
  ---
193
246
 
194
- ### 3. Message operations (`client.messages`)
247
+ ### 3. Message Operations (`client.messages`)
195
248
 
196
249
  ```typescript
197
250
  const msgKey = {
@@ -200,19 +253,19 @@ const msgKey = {
200
253
  id: '3EB0ABCDEF1234567890',
201
254
  };
202
255
 
203
- // 1. Edit sent message (within 15 minutes)
256
+ // 1. Edit sent message
204
257
  await client.messages.edit('201012345678', msgKey, 'Corrected text content');
205
258
 
206
259
  // 2. Delete message for everyone (revoke)
207
260
  await client.messages.delete('201012345678', msgKey);
208
261
 
209
- // 3. Mark message as read (blue tick)
262
+ // 3. Mark message as read
210
263
  await client.messages.markAsRead(msgKey);
211
264
 
212
- // 4. Emoji reaction (pass empty string to remove)
265
+ // 4. Emoji reaction
213
266
  await client.messages.react('201012345678', msgKey, '👍');
214
267
 
215
- // 5. Pin message (86400 = 24h, 604800 = 7d, 2592000 = 30d)
268
+ // 5. Pin message
216
269
  await client.messages.pin('201012345678', msgKey, 1, 86400);
217
270
 
218
271
  // 6. Forward message
@@ -221,173 +274,31 @@ await client.messages.forward('201012345678', { conversation: 'Forwarded message
221
274
 
222
275
  ---
223
276
 
224
- ### 4. Chats, contacts, and sync (`client.chats`)
277
+ ### 4. Chats, Contacts, and History (`client.chats`)
225
278
 
226
279
  ```typescript
227
- // 1. List synced chats
228
- const { chats, total } = await client.chats.list({ limit: 50, offset: 0 });
280
+ // 1. List chats / dialogs
281
+ const { chats } = await client.chats.list({ limit: 50 });
229
282
 
230
- // 2. List synced contacts
283
+ // 2. List contacts
231
284
  const { contacts } = await client.chats.listContacts({ limit: 100 });
232
285
 
233
- // 3. List synced messages
286
+ // 3. List messages for a chat
234
287
  const { messages } = await client.chats.listMessages({ chatJid: '201012345678@s.whatsapp.net', limit: 50 });
235
288
 
236
- // 4. Modify chat state (archive, mute, pin, delete)
289
+ // 4. Modify WhatsApp chat state (archive, mute, pin, delete)
237
290
  await client.chats.archive('201012345678@s.whatsapp.net');
238
- await client.chats.unarchive('201012345678@s.whatsapp.net');
239
291
  await client.chats.mute('201012345678@s.whatsapp.net', 8 * 60 * 60 * 1000); // 8 hours
240
- await client.chats.unmute('201012345678@s.whatsapp.net');
241
292
  await client.chats.pin('201012345678@s.whatsapp.net');
242
- await client.chats.unpin('201012345678@s.whatsapp.net');
243
- await client.chats.deleteChat('201012345678@s.whatsapp.net');
244
-
245
- // 5. Set disappearing messages timer
246
- await client.chats.setDisappearing('201012345678', 86400, true);
247
-
248
- // 6. Request older history from linked phone
249
- await client.chats.fetchHistory({ count: 50 });
250
-
251
- // 7. Trigger immediate sync
252
- await client.instances.sync();
253
- ```
254
-
255
- ---
256
-
257
- ### 5. Profile, presence, and business details (`client.profile`)
258
-
259
- ```typescript
260
- // 1. Get and update bio status
261
- const bio = await client.profile.getStatus('201012345678');
262
- await client.profile.setStatus('Available via Botcast API');
263
-
264
- // 2. Update display name
265
- await client.profile.setName('Botcast Agent');
266
-
267
- // 3. Profile picture management
268
- const pic = await client.profile.getPicture('201012345678', true); // High-res
269
- await client.profile.setPicture({ url: 'https://botcast.site/logo.png' });
270
- await client.profile.removePicture();
271
-
272
- // 4. Inspect WhatsApp Business profile
273
- const biz = await client.profile.getBusinessProfile('201012345678');
274
- console.log('Business category:', biz.businessProfile.category);
275
- ```
276
-
277
- ---
278
-
279
- ### 6. Group administration (`client.groups`)
280
-
281
- ```typescript
282
- // 1. Create a WhatsApp group
283
- const group = await client.groups.create('VIP Customers', ['201012345678', '966500000000']);
284
- const groupJid = group.group.id;
285
-
286
- // 2. List groups and fetch metadata
287
- const { groups } = await client.groups.list();
288
- const { metadata } = await client.groups.getMetadata(groupJid);
289
-
290
- // 3. Participant management (add, remove, promote, demote)
291
- await client.groups.addParticipants(groupJid, ['201099999999']);
292
- await client.groups.removeParticipants(groupJid, ['201099999999']);
293
- await client.groups.promoteParticipants(groupJid, ['201012345678']);
294
- await client.groups.demoteParticipants(groupJid, ['201012345678']);
295
-
296
- // 4. Update group subject and description
297
- await client.groups.updateSubject(groupJid, 'New Group Title');
298
- await client.groups.updateDescription(groupJid, 'Official VIP discussion group.');
299
-
300
- // 5. Update group settings
301
- await client.groups.updateSettings(groupJid, 'announcement'); // Admins only send messages
302
- await client.groups.updateSettings(groupJid, 'not_announcement'); // All members can chat
303
- await client.groups.updateSettings(groupJid, 'locked'); // Admins only edit info
304
- await client.groups.updateSettings(groupJid, 'unlocked');
305
-
306
- // 6. Shareable invite codes and links
307
- const invite = await client.groups.getInviteCode(groupJid);
308
- console.log('Invite link:', invite.link);
309
- await client.groups.revokeInviteCode(groupJid);
310
- await client.groups.acceptInvite('InviteCodeString');
311
- const info = await client.groups.getInviteInfo('InviteCodeString');
312
-
313
- // 7. Join requests moderation (admin approval mode)
314
- const pending = await client.groups.getJoinRequests(groupJid);
315
- await client.groups.updateJoinRequests(groupJid, ['201012345678'], 'approve');
316
-
317
- // 8. Ephemeral messages and member add mode
318
- await client.groups.setEphemeral(groupJid, 86400); // 24h
319
- await client.groups.setMemberAddMode(groupJid, 'admin_add'); // Only admins add
320
-
321
- // 9. Leave group
322
- await client.groups.leave(groupJid);
323
- ```
324
-
325
- ---
326
-
327
- ### 7. Privacy and blocklist (`client.profile`)
328
-
329
- ```typescript
330
- // 1. Block and unblock contacts
331
- await client.profile.block('201012345678');
332
- await client.profile.unblock('201012345678');
333
-
334
- // 2. Get blocklist
335
- const { blocklist } = await client.profile.getBlocklist();
336
-
337
- // 3. Get and update privacy visibility settings
338
- const privacy = await client.profile.getPrivacySettings();
339
- // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
340
- await client.profile.updatePrivacySetting('lastSeen', 'all');
341
- await client.profile.updatePrivacySetting('online', 'all');
342
- await client.profile.updatePrivacySetting('profilePicture', 'contacts');
343
- await client.profile.updatePrivacySetting('status', 'contacts');
344
- await client.profile.updatePrivacySetting('readReceipts', 'all');
345
- ```
346
-
347
- ---
348
-
349
- ### 8. 24-hour status stories and broadcasts (`client.broadcast`)
350
-
351
- ```typescript
352
- // 1. Publish status story (text, image, video, or audio)
353
- await client.broadcast.sendStatusStory({
354
- type: 'text',
355
- text: 'New update available on Botcast.',
356
- backgroundColor: '#10b981',
357
- });
358
-
359
- // 2. Get broadcast list info
360
- const list = await client.broadcast.getListInfo('1234567890@broadcast');
361
- ```
362
-
363
- ---
364
-
365
- ### 9. Rate limits and safety controls (`client.instances`)
366
-
367
- ```typescript
368
- // 1. Read current limits
369
- const limits = await client.instances.getLimits();
370
- console.log('Daily message limit:', limits.daily_message_limit);
371
- console.log('Daily new contacts limit:', limits.daily_new_contacts_limit);
372
-
373
- // 2. Update limits (pass 0 to disable)
374
- await client.instances.setDailyMessageLimit(1000);
375
- await client.instances.setDailyNewContactsLimit(100);
376
-
377
- // Or update both at once
378
- await client.instances.updateLimits({
379
- daily_message_limit: 500,
380
- daily_new_contacts_limit: 50,
381
- });
382
293
  ```
383
294
 
384
295
  ---
385
296
 
386
- ### 10. Webhook event handling
297
+ ### 5. Webhook Event Handling
387
298
 
388
- The SDK includes an event dispatcher and middleware for handling inbound webhooks:
299
+ The SDK includes a built-in event dispatcher and middleware for handling inbound webhooks from both WhatsApp and Telegram:
389
300
 
390
- #### Express example
301
+ #### Express Example
391
302
 
392
303
  ```typescript
393
304
  import express from 'express';
@@ -397,13 +308,14 @@ const app = express();
397
308
  app.use(express.json());
398
309
 
399
310
  const client = new BotcastClient({
311
+ platform: 'telegram', // or 'whatsapp'
400
312
  instanceId: 'inst_123',
401
313
  instanceToken: 'tok_abc',
402
314
  });
403
315
 
404
316
  // Listen for incoming messages
405
317
  client.webhook.onMessage(async (event) => {
406
- console.log(`Message from ${event.pushName || event.sender}: ${event.message}`);
318
+ console.log(`Message from ${event.sender}: ${event.message} [Platform: ${event.platform || 'whatsapp'}]`);
407
319
 
408
320
  if (event.message.trim().toLowerCase() === 'ping') {
409
321
  await client.messages.sendText(event.sender, 'pong');
@@ -412,7 +324,7 @@ client.webhook.onMessage(async (event) => {
412
324
 
413
325
  // Listen for connection changes
414
326
  client.webhook.onConnection(async (event) => {
415
- console.log(`Instance state updated: ${event.status}`);
327
+ console.log(`Instance status updated: ${event.status}`);
416
328
  });
417
329
 
418
330
  // Mount middleware on your webhook route
@@ -423,7 +335,7 @@ app.listen(3000, () => console.log('Webhook server running on port 3000'));
423
335
 
424
336
  ---
425
337
 
426
- ## Error handling
338
+ ## Error Handling
427
339
 
428
340
  `botcast-sdk` maps API status codes to typed error classes:
429
341
 
@@ -439,16 +351,16 @@ import {
439
351
  } from 'botcast-sdk';
440
352
 
441
353
  try {
442
- await client.messages.sendText('201012345678', 'Hello World');
354
+ await client.messages.sendText('+1234567890', 'Hello World');
443
355
  } catch (error) {
444
356
  if (error instanceof BotcastAuthError) {
445
357
  console.error('Invalid instance credentials or token.');
446
358
  } else if (error instanceof BotcastPaymentRequiredError) {
447
- console.error('Instance requires subscription activation.');
359
+ console.error('Instance requires payment confirmation.');
448
360
  } else if (error instanceof BotcastSubscriptionExpiredError) {
449
- console.error('Instance subscription expired on:', error.expiresAt);
361
+ console.error('Subscription expired on:', error.expiresAt);
450
362
  } else if (error instanceof BotcastRateLimitError) {
451
- console.error('Daily sending limit reached. Please wait before retrying.');
363
+ console.error('Daily message limit reached.');
452
364
  } else if (error instanceof BotcastValidationError) {
453
365
  console.error('Validation error:', error.message, error.details);
454
366
  } else if (error instanceof BotcastNotFoundError) {
@@ -465,12 +377,11 @@ try {
465
377
 
466
378
  - Website: [https://botcast.site](https://botcast.site)
467
379
  - Documentation: [https://botcast.site/docs](https://botcast.site/docs)
468
- - Postman collection: [https://botcast.site/botcast.postman_collection.json](https://botcast.site/botcast.postman_collection.json)
469
- - NPM package: [https://www.npmjs.com/package/botcast-sdk](https://www.npmjs.com/package/botcast-sdk)
470
- - GitHub repository: [https://github.com/ANOOBALSA/Botcast](https://github.com/ANOOBALSA/Botcast)
380
+ - NPM Package: [https://www.npmjs.com/package/botcast-sdk](https://www.npmjs.com/package/botcast-sdk)
381
+ - GitHub Repository: [https://github.com/ANOOBALSA/Botcast](https://github.com/ANOOBALSA/Botcast)
471
382
 
472
383
  ---
473
384
 
474
385
  ## License
475
386
 
476
- MIT (c) [Botcast](https://botcast.site)
387
+ MIT © [Botcast](https://botcast.site)
package/dist/admin.cjs ADDED
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BotcastAdminClient = void 0;
4
+ const errors_js_1 = require("./errors.js");
5
+ class BotcastAdminClient {
6
+ baseUrl;
7
+ apiKey;
8
+ timeout;
9
+ headers;
10
+ constructor(config) {
11
+ if (!config.apiKey) {
12
+ throw new Error('BotcastAdminClient requires a valid "apiKey" (e.g. bcast_live_...)');
13
+ }
14
+ this.baseUrl = (config.baseUrl || 'https://botcast.site').replace(/\/+$/, '');
15
+ this.apiKey = config.apiKey.trim();
16
+ this.timeout = config.timeout || 30000;
17
+ this.headers = config.headers || {};
18
+ }
19
+ async request(endpoint, options = {}) {
20
+ const url = `${this.baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
21
+ const controller = new AbortController();
22
+ const timer = setTimeout(() => controller.abort(), this.timeout);
23
+ const mergedHeaders = {
24
+ 'Content-Type': 'application/json',
25
+ 'x-api-key': this.apiKey,
26
+ ...this.headers,
27
+ ...(options.headers || {}),
28
+ };
29
+ try {
30
+ const res = await fetch(url, {
31
+ ...options,
32
+ headers: mergedHeaders,
33
+ signal: controller.signal,
34
+ });
35
+ const body = await res.json().catch(() => ({}));
36
+ if (!res.ok) {
37
+ throw new errors_js_1.BotcastError(body.message || body.error || `HTTP ${res.status}: ${res.statusText}`, res.status, body);
38
+ }
39
+ return body;
40
+ }
41
+ catch (err) {
42
+ if (err.name === 'AbortError') {
43
+ throw new errors_js_1.BotcastError(`Request timed out after ${this.timeout}ms`, 408);
44
+ }
45
+ throw err;
46
+ }
47
+ finally {
48
+ clearTimeout(timer);
49
+ }
50
+ }
51
+ /**
52
+ * Lists all instances under this admin/partner account with live statuses and stats.
53
+ */
54
+ async listInstances() {
55
+ return this.request('/api/instances', { method: 'GET' });
56
+ }
57
+ /**
58
+ * Retrieves single instance details including QR code, pairing code, status, and expiry.
59
+ */
60
+ async getInstance(instanceId) {
61
+ return this.request(`/api/instances/${instanceId}`, { method: 'GET' });
62
+ }
63
+ /**
64
+ * Creates and immediately provisions a new WhatsApp or Telegram instance.
65
+ * Admins are zero-payment, so instances are provisioned as active paid instances.
66
+ */
67
+ async createInstance(options) {
68
+ return this.request('/api/instances', {
69
+ method: 'POST',
70
+ body: JSON.stringify({
71
+ name: options.name,
72
+ platform: options.platform || 'whatsapp',
73
+ type: options.type || 'paid',
74
+ plan_months: options.plan_months || 12,
75
+ allowed_numbers: options.allowed_numbers || [],
76
+ webhook_url: options.webhook_url || '',
77
+ target_user_id: options.target_user_id,
78
+ }),
79
+ });
80
+ }
81
+ /**
82
+ * Programmatically renews an instance's subscription without payment transactions.
83
+ */
84
+ async renewInstance(instanceId, options) {
85
+ return this.request(`/api/instances/${instanceId}/renew`, {
86
+ method: 'POST',
87
+ body: JSON.stringify({
88
+ months: options?.months || options?.plan_months || 12,
89
+ }),
90
+ });
91
+ }
92
+ /**
93
+ * Updates instance configuration (name, webhook URL, allowed recipient numbers).
94
+ */
95
+ async updateInstance(instanceId, updates) {
96
+ return this.request(`/api/instances/${instanceId}`, {
97
+ method: 'PUT',
98
+ body: JSON.stringify(updates),
99
+ });
100
+ }
101
+ /**
102
+ * Regenerates secret instance token for an instance.
103
+ */
104
+ async regenerateInstanceToken(instanceId) {
105
+ return this.request(`/api/instances/${instanceId}/regenerate-token`, {
106
+ method: 'POST',
107
+ });
108
+ }
109
+ /**
110
+ * Deletes and cleans up an instance.
111
+ */
112
+ async deleteInstance(instanceId) {
113
+ return this.request(`/api/instances/${instanceId}`, {
114
+ method: 'DELETE',
115
+ });
116
+ }
117
+ }
118
+ exports.BotcastAdminClient = BotcastAdminClient;
@@ -0,0 +1,97 @@
1
+ export interface BotcastAdminConfig {
2
+ baseUrl?: string;
3
+ apiKey: string;
4
+ timeout?: number;
5
+ headers?: Record<string, string>;
6
+ }
7
+ export interface CreateAdminInstanceOptions {
8
+ name: string;
9
+ platform?: 'whatsapp' | 'telegram';
10
+ type?: 'dev' | 'paid';
11
+ plan_months?: number;
12
+ allowed_numbers?: string[];
13
+ webhook_url?: string;
14
+ target_user_id?: number;
15
+ }
16
+ export interface AdminInstanceRecord {
17
+ id: string;
18
+ user_id: number;
19
+ name: string;
20
+ instance_token: string;
21
+ platform: 'whatsapp' | 'telegram';
22
+ type: 'dev' | 'paid';
23
+ status: string;
24
+ allowed_numbers: string[];
25
+ webhook_url: string | null;
26
+ plan_months: number;
27
+ expires_at: string | null;
28
+ is_expired?: boolean;
29
+ qr?: string | null;
30
+ pairingCode?: string | null;
31
+ created_at: string;
32
+ }
33
+ export declare class BotcastAdminClient {
34
+ private baseUrl;
35
+ private apiKey;
36
+ private timeout;
37
+ private headers;
38
+ constructor(config: BotcastAdminConfig);
39
+ private request;
40
+ /**
41
+ * Lists all instances under this admin/partner account with live statuses and stats.
42
+ */
43
+ listInstances(): Promise<{
44
+ instances: AdminInstanceRecord[];
45
+ }>;
46
+ /**
47
+ * Retrieves single instance details including QR code, pairing code, status, and expiry.
48
+ */
49
+ getInstance(instanceId: string): Promise<{
50
+ instance: AdminInstanceRecord;
51
+ }>;
52
+ /**
53
+ * Creates and immediately provisions a new WhatsApp or Telegram instance.
54
+ * Admins are zero-payment, so instances are provisioned as active paid instances.
55
+ */
56
+ createInstance(options: CreateAdminInstanceOptions): Promise<{
57
+ message: string;
58
+ instance: AdminInstanceRecord;
59
+ }>;
60
+ /**
61
+ * Programmatically renews an instance's subscription without payment transactions.
62
+ */
63
+ renewInstance(instanceId: string, options?: {
64
+ months?: number;
65
+ plan_months?: number;
66
+ }): Promise<{
67
+ success: boolean;
68
+ message: string;
69
+ instance: AdminInstanceRecord;
70
+ }>;
71
+ /**
72
+ * Updates instance configuration (name, webhook URL, allowed recipient numbers).
73
+ */
74
+ updateInstance(instanceId: string, updates: {
75
+ name?: string;
76
+ webhook_url?: string;
77
+ allowed_numbers?: string[];
78
+ }): Promise<{
79
+ message: string;
80
+ instance: AdminInstanceRecord;
81
+ }>;
82
+ /**
83
+ * Regenerates secret instance token for an instance.
84
+ */
85
+ regenerateInstanceToken(instanceId: string): Promise<{
86
+ message: string;
87
+ instance_token: string;
88
+ }>;
89
+ /**
90
+ * Deletes and cleans up an instance.
91
+ */
92
+ deleteInstance(instanceId: string): Promise<{
93
+ message: string;
94
+ instanceId: string;
95
+ }>;
96
+ }
97
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/admin.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB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AAA;KAAE,CAAC;IAShF;;OAEG;IACU,cAAc,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAC3E,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,mBAAmB,CAAA;KAAE,CAAC;IAO9D;;OAEG;IACU,uBAAuB,CAClC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IAMvD;;OAEG;IACU,cAAc,CACzB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAKpD"}
package/dist/admin.js ADDED
@@ -0,0 +1,114 @@
1
+ import { BotcastError } from './errors.js';
2
+ export class BotcastAdminClient {
3
+ baseUrl;
4
+ apiKey;
5
+ timeout;
6
+ headers;
7
+ constructor(config) {
8
+ if (!config.apiKey) {
9
+ throw new Error('BotcastAdminClient requires a valid "apiKey" (e.g. bcast_live_...)');
10
+ }
11
+ this.baseUrl = (config.baseUrl || 'https://botcast.site').replace(/\/+$/, '');
12
+ this.apiKey = config.apiKey.trim();
13
+ this.timeout = config.timeout || 30000;
14
+ this.headers = config.headers || {};
15
+ }
16
+ async request(endpoint, options = {}) {
17
+ const url = `${this.baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
18
+ const controller = new AbortController();
19
+ const timer = setTimeout(() => controller.abort(), this.timeout);
20
+ const mergedHeaders = {
21
+ 'Content-Type': 'application/json',
22
+ 'x-api-key': this.apiKey,
23
+ ...this.headers,
24
+ ...(options.headers || {}),
25
+ };
26
+ try {
27
+ const res = await fetch(url, {
28
+ ...options,
29
+ headers: mergedHeaders,
30
+ signal: controller.signal,
31
+ });
32
+ const body = await res.json().catch(() => ({}));
33
+ if (!res.ok) {
34
+ throw new BotcastError(body.message || body.error || `HTTP ${res.status}: ${res.statusText}`, res.status, body);
35
+ }
36
+ return body;
37
+ }
38
+ catch (err) {
39
+ if (err.name === 'AbortError') {
40
+ throw new BotcastError(`Request timed out after ${this.timeout}ms`, 408);
41
+ }
42
+ throw err;
43
+ }
44
+ finally {
45
+ clearTimeout(timer);
46
+ }
47
+ }
48
+ /**
49
+ * Lists all instances under this admin/partner account with live statuses and stats.
50
+ */
51
+ async listInstances() {
52
+ return this.request('/api/instances', { method: 'GET' });
53
+ }
54
+ /**
55
+ * Retrieves single instance details including QR code, pairing code, status, and expiry.
56
+ */
57
+ async getInstance(instanceId) {
58
+ return this.request(`/api/instances/${instanceId}`, { method: 'GET' });
59
+ }
60
+ /**
61
+ * Creates and immediately provisions a new WhatsApp or Telegram instance.
62
+ * Admins are zero-payment, so instances are provisioned as active paid instances.
63
+ */
64
+ async createInstance(options) {
65
+ return this.request('/api/instances', {
66
+ method: 'POST',
67
+ body: JSON.stringify({
68
+ name: options.name,
69
+ platform: options.platform || 'whatsapp',
70
+ type: options.type || 'paid',
71
+ plan_months: options.plan_months || 12,
72
+ allowed_numbers: options.allowed_numbers || [],
73
+ webhook_url: options.webhook_url || '',
74
+ target_user_id: options.target_user_id,
75
+ }),
76
+ });
77
+ }
78
+ /**
79
+ * Programmatically renews an instance's subscription without payment transactions.
80
+ */
81
+ async renewInstance(instanceId, options) {
82
+ return this.request(`/api/instances/${instanceId}/renew`, {
83
+ method: 'POST',
84
+ body: JSON.stringify({
85
+ months: options?.months || options?.plan_months || 12,
86
+ }),
87
+ });
88
+ }
89
+ /**
90
+ * Updates instance configuration (name, webhook URL, allowed recipient numbers).
91
+ */
92
+ async updateInstance(instanceId, updates) {
93
+ return this.request(`/api/instances/${instanceId}`, {
94
+ method: 'PUT',
95
+ body: JSON.stringify(updates),
96
+ });
97
+ }
98
+ /**
99
+ * Regenerates secret instance token for an instance.
100
+ */
101
+ async regenerateInstanceToken(instanceId) {
102
+ return this.request(`/api/instances/${instanceId}/regenerate-token`, {
103
+ method: 'POST',
104
+ });
105
+ }
106
+ /**
107
+ * Deletes and cleans up an instance.
108
+ */
109
+ async deleteInstance(instanceId) {
110
+ return this.request(`/api/instances/${instanceId}`, {
111
+ method: 'DELETE',
112
+ });
113
+ }
114
+ }
package/dist/client.cjs CHANGED
@@ -52,6 +52,7 @@ class BotcastClient {
52
52
  }
53
53
  this.config = {
54
54
  baseUrl: config.baseUrl || 'https://botcast.site',
55
+ platform: config.platform || 'whatsapp',
55
56
  instanceId: config.instanceId,
56
57
  instanceToken: config.instanceToken,
57
58
  timeout: config.timeout || 30000,
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAgC;IAE9C,iDAAiD;IAC1C,SAAS,EAAE,eAAe,CAAC;IAElC,6EAA6E;IACtE,QAAQ,EAAE,cAAc,CAAC;IAEhC,0DAA0D;IACnD,KAAK,EAAE,WAAW,CAAC;IAE1B,iDAAiD;IAC1C,MAAM,EAAE,YAAY,CAAC;IAE5B,0DAA0D;IACnD,OAAO,EAAE,aAAa,C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AE,WAAW,CAAC;IAE1B,iDAAiD;IAC1C,MAAM,EAAE,YAAY,CAAC;IAE5B,0DAA0D;IACnD,OAAO,EAAE,aAAa,CAAC;IAE9B,gDAAgD;IACzC,SAAS,EAAE,eAAe,CAAC;IAElC,mCAAmC;IAC5B,OAAO,EAAE,cAAc,CAAC;IAE/B;;;;;;;;;;;;;;;;;;OAkBG;gBACS,MAAM,EAAE,mBAAmB;IA+BvC;;OAEG;IACU,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrD;;OAEG;IACU,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;;;IAI7G;;OAEG;IACU,SAAS;IAItB;;OAEG;IACU,KAAK;IAIlB;;;;OAIG;IACU,YAAY,CAAC,WAAW,EAAE,MAAM;IAI7C;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM;CAG7C"}
package/dist/client.js CHANGED
@@ -49,6 +49,7 @@ export class BotcastClient {
49
49
  }
50
50
  this.config = {
51
51
  baseUrl: config.baseUrl || 'https://botcast.site',
52
+ platform: config.platform || 'whatsapp',
52
53
  instanceId: config.instanceId,
53
54
  instanceToken: config.instanceToken,
54
55
  timeout: config.timeout || 30000,
package/dist/index.cjs CHANGED
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BotcastWebhook = exports.BotcastClient = void 0;
17
+ exports.BotcastWebhook = exports.BotcastAdminClient = exports.BotcastClient = void 0;
18
18
  var client_js_1 = require("./client.js");
19
19
  Object.defineProperty(exports, "BotcastClient", { enumerable: true, get: function () { return client_js_1.BotcastClient; } });
20
+ var admin_js_1 = require("./admin.js");
21
+ Object.defineProperty(exports, "BotcastAdminClient", { enumerable: true, get: function () { return admin_js_1.BotcastAdminClient; } });
20
22
  var index_js_1 = require("./webhooks/index.js");
21
23
  Object.defineProperty(exports, "BotcastWebhook", { enumerable: true, get: function () { return index_js_1.BotcastWebhook; } });
22
24
  __exportStar(require("./errors.js"), exports);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { BotcastClient } from './client.js';
2
+ export { BotcastAdminClient, BotcastAdminConfig, CreateAdminInstanceOptions, AdminInstanceRecord } from './admin.js';
2
3
  export { BotcastWebhook } from './webhooks/index.js';
3
4
  export * from './errors.js';
4
5
  export * from './types/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,eAAe,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { BotcastClient } from './client.js';
2
+ export { BotcastAdminClient } from './admin.js';
2
3
  export { BotcastWebhook } from './webhooks/index.js';
3
4
  export * from './errors.js';
4
5
  export * from './types/index.js';
@@ -8,11 +8,12 @@ class BaseModule {
8
8
  this.config = config;
9
9
  }
10
10
  /**
11
- * Builds the instance-specific URL path prefix: `/whatsapp/:instanceId/:instanceToken/...`
11
+ * Builds the instance-specific URL path prefix: `/:platform/:instanceId/:instanceToken/...`
12
12
  */
13
13
  buildPath(subPath) {
14
+ const platform = this.config.platform || 'whatsapp';
14
15
  const cleanSubPath = subPath.startsWith('/') ? subPath.slice(1) : subPath;
15
- return `/whatsapp/${encodeURIComponent(this.config.instanceId)}/${encodeURIComponent(this.config.instanceToken)}/${cleanSubPath}`;
16
+ return `/${platform}/${encodeURIComponent(this.config.instanceId)}/${encodeURIComponent(this.config.instanceToken)}/${cleanSubPath}`;
16
17
  }
17
18
  /**
18
19
  * Executes an HTTP request against the Botcast API Gateway with retry & error translation.
@@ -10,7 +10,7 @@ export declare class BaseModule {
10
10
  protected config: Required<BotcastClientConfig>;
11
11
  constructor(config: Required<BotcastClientConfig>);
12
12
  /**
13
- * Builds the instance-specific URL path prefix: `/whatsapp/:instanceId/:instanceToken/...`
13
+ * Builds the instance-specific URL path prefix: `/:platform/:instanceId/:instanceToken/...`
14
14
  */
15
15
  protected buildPath(subPath: string): string;
16
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/modules/base.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACrE,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AC;IAyFlE,OAAO,CAAC,eAAe;CAuBxB"}
@@ -5,11 +5,12 @@ export class BaseModule {
5
5
  this.config = config;
6
6
  }
7
7
  /**
8
- * Builds the instance-specific URL path prefix: `/whatsapp/:instanceId/:instanceToken/...`
8
+ * Builds the instance-specific URL path prefix: `/:platform/:instanceId/:instanceToken/...`
9
9
  */
10
10
  buildPath(subPath) {
11
+ const platform = this.config.platform || 'whatsapp';
11
12
  const cleanSubPath = subPath.startsWith('/') ? subPath.slice(1) : subPath;
12
- return `/whatsapp/${encodeURIComponent(this.config.instanceId)}/${encodeURIComponent(this.config.instanceToken)}/${cleanSubPath}`;
13
+ return `/${platform}/${encodeURIComponent(this.config.instanceId)}/${encodeURIComponent(this.config.instanceToken)}/${cleanSubPath}`;
13
14
  }
14
15
  /**
15
16
  * Executes an HTTP request against the Botcast API Gateway with retry & error translation.
@@ -22,9 +22,9 @@ class InstancesModule extends base_js_1.BaseModule {
22
22
  });
23
23
  }
24
24
  /**
25
- * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
25
+ * Generates a pairing / login code for phone number authentication.
26
26
  *
27
- * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
27
+ * @param phoneNumber Phone number with country code (e.g. `201000000000` or `15551234567`)
28
28
  */
29
29
  async pairWithCode(phoneNumber) {
30
30
  return this.request({
@@ -33,6 +33,16 @@ class InstancesModule extends base_js_1.BaseModule {
33
33
  body: { phoneNumber },
34
34
  });
35
35
  }
36
+ /**
37
+ * Completes phone code verification (e.g. for Telegram login with optional 2FA password).
38
+ */
39
+ async verifyCode(phoneNumber, code, password) {
40
+ return this.request({
41
+ method: 'POST',
42
+ path: this.buildPath('verify-code'),
43
+ body: { phoneNumber, code, password },
44
+ });
45
+ }
36
46
  /**
37
47
  * Boots up the WhatsApp socket connection.
38
48
  *
@@ -10,11 +10,20 @@ export declare class InstancesModule extends BaseModule {
10
10
  */
11
11
  getQR(): Promise<InstanceQRResponse>;
12
12
  /**
13
- * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
13
+ * Generates a pairing / login code for phone number authentication.
14
14
  *
15
- * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
15
+ * @param phoneNumber Phone number with country code (e.g. `201000000000` or `15551234567`)
16
16
  */
17
17
  pairWithCode(phoneNumber: string): Promise<PairCodeResponse>;
18
+ /**
19
+ * Completes phone code verification (e.g. for Telegram login with optional 2FA password).
20
+ */
21
+ verifyCode(phoneNumber: string, code: string, password?: string): Promise<{
22
+ success: boolean;
23
+ status: string;
24
+ user?: any;
25
+ message?: string;
26
+ }>;
18
27
  /**
19
28
  * Boots up the WhatsApp socket connection.
20
29
  *
@@ -1 +1 @@
1
- {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../../src/modules/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,eAAgB,SAAQ,UAAU;IAC7C;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAOzD;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAOjD;;;;OAIG;IACU,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQzE;;;;OAIG;IACU,KAAK,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ9H;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,O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H;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAM5F"}
@@ -19,9 +19,9 @@ export class InstancesModule extends BaseModule {
19
19
  });
20
20
  }
21
21
  /**
22
- * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
22
+ * Generates a pairing / login code for phone number authentication.
23
23
  *
24
- * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
24
+ * @param phoneNumber Phone number with country code (e.g. `201000000000` or `15551234567`)
25
25
  */
26
26
  async pairWithCode(phoneNumber) {
27
27
  return this.request({
@@ -30,6 +30,16 @@ export class InstancesModule extends BaseModule {
30
30
  body: { phoneNumber },
31
31
  });
32
32
  }
33
+ /**
34
+ * Completes phone code verification (e.g. for Telegram login with optional 2FA password).
35
+ */
36
+ async verifyCode(phoneNumber, code, password) {
37
+ return this.request({
38
+ method: 'POST',
39
+ path: this.buildPath('verify-code'),
40
+ body: { phoneNumber, code, password },
41
+ });
42
+ }
33
43
  /**
34
44
  * Boots up the WhatsApp socket connection.
35
45
  *
@@ -35,6 +35,13 @@ class MessagesModule extends base_js_1.BaseModule {
35
35
  * @param options OTP configuration (code, app name, expiry minutes)
36
36
  */
37
37
  async sendOTP(recipient, options) {
38
+ if (this.config.platform === 'telegram') {
39
+ return this.send({
40
+ recipient,
41
+ type: 'otp',
42
+ ...options,
43
+ });
44
+ }
38
45
  return this.request({
39
46
  method: 'POST',
40
47
  path: this.buildPath('otp'),
@@ -126,6 +133,14 @@ class MessagesModule extends base_js_1.BaseModule {
126
133
  * Sends a contact vCard card.
127
134
  */
128
135
  async sendContact(recipient, contact, options) {
136
+ if (this.config.platform === 'telegram') {
137
+ return this.send({
138
+ recipient,
139
+ type: 'contact',
140
+ ...contact,
141
+ ...options,
142
+ });
143
+ }
129
144
  return this.request({
130
145
  method: 'POST',
131
146
  path: this.buildPath('messages/contact'),
@@ -83,7 +83,9 @@ export declare class MessagesModule extends BaseModule {
83
83
  * Sends a contact vCard card.
84
84
  */
85
85
  sendContact(recipient: string, contact: {
86
- displayName: string;
86
+ displayName?: string;
87
+ firstName?: string;
88
+ phone?: string;
87
89
  vcard?: string;
88
90
  contacts?: Array<{
89
91
  displayName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/modules/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,mBAAmB,EAMnB,cAAc,EACd,UAAU,EACV,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;OAEG;IACU,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ7E;;;;;;OAMG;IACU,QAAQ,CACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IAS/B;;;;;OAKG;IACU,OAAO,CAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,mBAAmB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAWtD;;OAEG;IACU,SAAS,CACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAChE,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IAS/B;;OAEG;IACU,SAAS,CACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE;QAAE,GAAG,CAAC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C,EAAE,GAAG,CAAA;KAAE,CAAC;IAQ/D;;;;;;;OAOG;IACU,GAAG,CACd,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,IAAI,GAAE,CAAC,GAAG,CAAK,EACf,QAAQ,GAAE,MAAc,GACvB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;CAOhE"}
@@ -32,6 +32,13 @@ export class MessagesModule extends BaseModule {
32
32
  * @param options OTP configuration (code, app name, expiry minutes)
33
33
  */
34
34
  async sendOTP(recipient, options) {
35
+ if (this.config.platform === 'telegram') {
36
+ return this.send({
37
+ recipient,
38
+ type: 'otp',
39
+ ...options,
40
+ });
41
+ }
35
42
  return this.request({
36
43
  method: 'POST',
37
44
  path: this.buildPath('otp'),
@@ -123,6 +130,14 @@ export class MessagesModule extends BaseModule {
123
130
  * Sends a contact vCard card.
124
131
  */
125
132
  async sendContact(recipient, contact, options) {
133
+ if (this.config.platform === 'telegram') {
134
+ return this.send({
135
+ recipient,
136
+ type: 'contact',
137
+ ...contact,
138
+ ...options,
139
+ });
140
+ }
126
141
  return this.request({
127
142
  method: 'POST',
128
143
  path: this.buildPath('messages/contact'),
@@ -10,6 +10,10 @@ export interface BotcastClientConfig {
10
10
  * Default: `https://botcast.site`
11
11
  */
12
12
  baseUrl?: string;
13
+ /**
14
+ * Platform type: 'whatsapp' or 'telegram'. Default: 'whatsapp'.
15
+ */
16
+ platform?: 'whatsapp' | 'telegram';
13
17
  /**
14
18
  * Your unique Botcast Instance ID.
15
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAEnC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "botcast-sdk",
3
- "version": "1.0.3",
4
- "description": "Official TypeScript/JavaScript SDK for Botcast WhatsApp Multi-Instance API Gateway",
3
+ "version": "1.0.6",
4
+ "description": "Official TypeScript/JavaScript SDK for Botcast WhatsApp & Telegram MTProto Multi-Instance API Gateway",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -33,9 +33,14 @@
33
33
  "whatsapp",
34
34
  "whatsapp-api",
35
35
  "whatsapp-gateway",
36
+ "telegram",
37
+ "telegram-api",
38
+ "mtproto",
39
+ "teleproto",
36
40
  "baileys",
37
41
  "multi-instance",
38
42
  "whatsapp-bot",
43
+ "telegram-bot",
39
44
  "otp",
40
45
  "messaging",
41
46
  "sms-alternative",