botcast-sdk 1.0.2 → 1.0.4

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,54 +1,73 @@
1
1
  # botcast-sdk
2
2
 
3
- Node.js and TypeScript client for [Botcast](https://botcast.site), a multi-instance WhatsApp API gateway.
4
-
5
- Connect WhatsApp numbers, send messages (text, OTP, media, documents, polls), manage group chats, and process incoming webhooks.
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`).
6
4
 
7
5
  [![npm version](https://img.shields.io/npm/v/botcast-sdk.svg?color=blue)](https://www.npmjs.com/package/botcast-sdk)
6
+ [![npm downloads](https://img.shields.io/npm/dm/botcast-sdk.svg)](https://www.npmjs.com/package/botcast-sdk)
8
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
9
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
10
9
 
11
10
  ---
12
11
 
12
+ ## Features
13
+
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.
25
+
26
+ ---
27
+
13
28
  ## Installation
14
29
 
15
30
  ```bash
16
31
  npm install botcast-sdk
17
32
  # or
33
+ pnpm add botcast-sdk
34
+ # or
18
35
  yarn add botcast-sdk
19
36
  # or
20
- pnpm add botcast-sdk
37
+ bun add botcast-sdk
21
38
  ```
22
39
 
23
40
  ---
24
41
 
25
- ## Quick start
42
+ ## Quick Start
43
+
44
+ ### 1. WhatsApp Client
26
45
 
27
46
  ```typescript
28
47
  import { BotcastClient } from 'botcast-sdk';
29
48
 
30
- const botcast = new BotcastClient({
49
+ const whatsappBot = new BotcastClient({
31
50
  baseUrl: 'https://botcast.site', // or your self-hosted server URL
51
+ platform: 'whatsapp', // 'whatsapp' (default) or 'telegram'
32
52
  instanceId: 'your_instance_id',
33
53
  instanceToken: 'your_instance_token',
34
54
  });
35
55
 
36
56
  async function main() {
37
- // 1. Check WhatsApp connection status
38
- const status = await botcast.instances.getStatus();
39
- console.log('Status:', status.status, 'Phone:', status.phoneNumber);
40
-
41
- // 2. Send a text message
42
- const result = await botcast.messages.sendText('201000000000', 'Hello from Botcast SDK');
43
- console.log('Sent message ID:', result.messageId);
44
-
45
- // 3. Send an OTP verification code
46
- const otp = await botcast.messages.sendOTP('201000000000', {
47
- code: '849201',
48
- appName: 'My SaaS App',
57
+ // Check connectivity
58
+ const status = await whatsappBot.getStatus();
59
+ console.log(`WhatsApp state: ${status.status} (${status.phoneNumber || 'Unpaired'})`);
60
+
61
+ // Send a text message
62
+ const res = await whatsappBot.messages.sendText('201012345678', 'Hello from WhatsApp via Botcast SDK!');
63
+ console.log('Message sent! ID:', res.messageId);
64
+
65
+ // Send a secure 6-digit OTP code
66
+ const otp = await whatsappBot.messages.sendOTP('201012345678', {
67
+ appName: 'My App',
49
68
  expiryMinutes: 5,
50
69
  });
51
- console.log('OTP dispatched:', otp.codeSent);
70
+ console.log('Dispatched OTP:', otp.codeSent);
52
71
  }
53
72
 
54
73
  main().catch(console.error);
@@ -56,12 +75,52 @@ main().catch(console.error);
56
75
 
57
76
  ---
58
77
 
59
- ## CommonJS usage
78
+ ### 2. Telegram MTProto Client
79
+
80
+ ```typescript
81
+ import { BotcastClient } from 'botcast-sdk';
82
+
83
+ const telegramBot = new BotcastClient({
84
+ baseUrl: 'https://botcast.site',
85
+ platform: 'telegram',
86
+ instanceId: 'your_telegram_instance_id',
87
+ instanceToken: 'your_telegram_instance_token',
88
+ });
89
+
90
+ async function main() {
91
+ // Check connectivity
92
+ const status = await telegramBot.getStatus();
93
+ console.log(`Telegram state: ${status.status}`);
94
+
95
+ // Send a text message to a phone number or @username
96
+ const res = await telegramBot.messages.sendText('+1234567890', 'Hello from Telegram MTProto!');
97
+ console.log('Message ID:', res.messageId);
98
+
99
+ // Send a photo
100
+ await telegramBot.messages.sendImage('+1234567890', {
101
+ url: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800',
102
+ caption: 'Welcome flyer',
103
+ });
104
+
105
+ // Send OTP
106
+ const otp = await telegramBot.messages.sendOTP('+1234567890', {
107
+ appName: 'Security Portal',
108
+ });
109
+ console.log('Telegram OTP sent:', otp.codeSent);
110
+ }
111
+
112
+ main().catch(console.error);
113
+ ```
114
+
115
+ ---
116
+
117
+ ### CommonJS (require)
60
118
 
61
119
  ```javascript
62
120
  const { BotcastClient } = require('botcast-sdk');
63
121
 
64
- const botcast = new BotcastClient({
122
+ const client = new BotcastClient({
123
+ platform: 'telegram', // or 'whatsapp'
65
124
  instanceId: 'your_instance_id',
66
125
  instanceToken: 'your_instance_token',
67
126
  });
@@ -69,120 +128,149 @@ const botcast = new BotcastClient({
69
128
 
70
129
  ---
71
130
 
72
- ## API reference
131
+ ## API Reference
73
132
 
74
- ### 1. Instance management
133
+ ### 1. Device Pairing and Lifecycle (`client.instances`)
75
134
 
76
135
  ```typescript
77
- // Get status and phone profile details
78
- const status = await botcast.instances.getStatus();
79
-
80
- // Get QR code string for scanning
81
- const qr = await botcast.instances.getQR();
82
-
83
- // Generate an 8-digit phone pairing code (no camera scan needed)
84
- const pair = await botcast.instances.pairWithCode('201000000000');
85
- console.log('Enter this code in WhatsApp:', pair.formattedCode); // e.g. 1234-5678
86
-
87
- // Start, stop, or log out
88
- await botcast.instances.start();
89
- await botcast.instances.stop();
90
- await botcast.instances.logout();
91
-
92
- // Check whether a phone number is on WhatsApp
93
- const check = await botcast.instances.checkNumber('201000000000');
94
- console.log('Exists:', check.exists, 'JID:', check.jid);
95
-
96
- // Set presence (typing, recording audio, online/offline)
97
- await botcast.instances.setPresence({
98
- presence: 'composing', // 'available' | 'unavailable' | 'composing' | 'recording' | 'paused'
99
- recipient: '201000000000',
100
- });
136
+ // 1. Get live status
137
+ const status = await client.instances.getStatus();
138
+ console.log('State:', status.status); // 'connected' | 'qr_ready' | 'stopped' | 'connecting'
139
+
140
+ // 2. Option A: Get QR code string for camera scanning
141
+ // (WhatsApp: Linked Devices | Telegram: Settings > Devices > Link Desktop Device)
142
+ const qr = await client.getQR(); // or client.instances.getQR()
143
+ console.log('QR DataURL:', qr.qr);
144
+
145
+ // 3. Option B: Request Phone Pairing / Login Code
146
+ // (WhatsApp sends 8-digit PIN | Telegram sends verification code into app)
147
+ const pair = await client.pairWithCode('+1234567890');
148
+ console.log('Code request status:', pair);
149
+
150
+ // 4. Complete Telegram Phone Login (with optional 2FA cloud password)
151
+ await client.instances.verifyCode('+1234567890', '12345', 'myCloudPassword2fa');
152
+
153
+ // 5. Socket engine controls
154
+ await client.instances.start(); // Boots socket / MTProto connection
155
+ await client.instances.stop(); // Suspends socket session
156
+ await client.instances.logout(); // Unlinks device and clears session credentials
101
157
  ```
102
158
 
103
159
  ---
104
160
 
105
- ### 2. Messaging
161
+ ### 2. Message Dispatching (`client.messages`)
162
+
163
+ All messaging methods work across both **WhatsApp** and **Telegram**:
106
164
 
107
165
  ```typescript
108
- // 1. Text message with mentions
109
- await botcast.messages.sendText('201000000000', 'Hello @user', {
110
- mentions: ['201000000000'],
166
+ // 1. Text message
167
+ await client.messages.sendText('+1234567890', 'Hello World', {
168
+ mentions: ['1234567890'], // WhatsApp mentions
169
+ });
170
+
171
+ // 2. Image / Photo
172
+ await client.messages.sendImage('+1234567890', {
173
+ url: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800',
174
+ caption: 'Photo preview',
111
175
  });
112
176
 
113
- // 2. Image with caption
114
- await botcast.messages.sendImage('201000000000', {
115
- url: 'https://example.com/invoice.png',
116
- caption: 'Here is your monthly invoice.',
177
+ // 3. Video
178
+ await client.messages.sendVideo('+1234567890', {
179
+ url: 'https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4',
180
+ caption: 'Product tutorial video',
117
181
  });
118
182
 
119
- // 3. Document / PDF
120
- await botcast.messages.sendDocument('201000000000', {
121
- url: 'https://example.com/statement.pdf',
122
- fileName: 'Statement_August.pdf',
123
- mimetype: 'application/pdf',
183
+ // 4. Voice note and audio
184
+ await client.messages.sendVoice('+1234567890', {
185
+ url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
124
186
  });
125
187
 
126
- // 4. Voice note (PTT waveform)
127
- await botcast.messages.sendVoice('201000000000', {
128
- url: 'https://example.com/audio-note.mp3',
188
+ // 5. Document / PDF / File
189
+ await client.messages.sendDocument('+1234567890', {
190
+ url: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
191
+ fileName: 'Invoice_2026.pdf',
192
+ caption: 'Monthly invoice statement',
129
193
  });
130
194
 
131
- // 5. Interactive poll
132
- await botcast.messages.sendPoll('201000000000', {
133
- name: 'How was our service?',
134
- values: ['Great', 'Average', 'Needs work'],
135
- selectableCount: 1,
195
+ // 6. Location coordinates
196
+ await client.messages.sendLocation('+1234567890', {
197
+ latitude: 24.7136,
198
+ longitude: 46.6753,
199
+ name: 'Kingdom Tower',
200
+ address: 'King Fahd Rd, Riyadh, Saudi Arabia',
136
201
  });
137
202
 
138
- // 6. Contact card (vCard)
139
- await botcast.messages.sendContact('201000000000', {
140
- displayName: 'Customer Support',
141
- vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:Customer Support\nTEL;TYPE=CELL:+201000000000\nEND:VCARD',
203
+ // 7. Contact Card
204
+ await client.messages.sendContact('+1234567890', {
205
+ firstName: 'Support Agent',
206
+ phone: '+1234567890',
142
207
  });
143
208
 
144
- // 7. Message actions: react, pin, edit, delete for everyone
145
- await botcast.messages.react('201000000000', msgKey, '👍');
146
- await botcast.messages.pin('201000000000', msgKey, 1, 86400); // pin for 24 hours
147
- await botcast.messages.edit('201000000000', msgKey, 'Updated text message');
148
- await botcast.messages.delete('201000000000', msgKey); // Revoke for everyone
209
+ // 8. Automated OTP verification code
210
+ const otp = await client.messages.sendOTP('+1234567890', {
211
+ appName: 'Botcast Portal',
212
+ expiryMinutes: 5,
213
+ });
149
214
  ```
150
215
 
151
216
  ---
152
217
 
153
- ### 3. Group administration
218
+ ### 3. Message Operations (`client.messages`)
154
219
 
155
220
  ```typescript
156
- // Create a group
157
- const newGroup = await botcast.groups.create('VIP Customers', ['201000000000', '201111111111']);
221
+ const msgKey = {
222
+ remoteJid: '201012345678@s.whatsapp.net',
223
+ fromMe: true,
224
+ id: '3EB0ABCDEF1234567890',
225
+ };
226
+
227
+ // 1. Edit sent message
228
+ await client.messages.edit('201012345678', msgKey, 'Corrected text content');
229
+
230
+ // 2. Delete message for everyone (revoke)
231
+ await client.messages.delete('201012345678', msgKey);
232
+
233
+ // 3. Mark message as read
234
+ await client.messages.markAsRead(msgKey);
235
+
236
+ // 4. Emoji reaction
237
+ await client.messages.react('201012345678', msgKey, '👍');
238
+
239
+ // 5. Pin message
240
+ await client.messages.pin('201012345678', msgKey, 1, 86400);
158
241
 
159
- // List joined groups
160
- const groups = await botcast.groups.list();
242
+ // 6. Forward message
243
+ await client.messages.forward('201012345678', { conversation: 'Forwarded message text' });
244
+ ```
245
+
246
+ ---
161
247
 
162
- // Add or remove participants
163
- await botcast.groups.addParticipants('group-jid@g.us', ['201222222222']);
164
- await botcast.groups.removeParticipants('group-jid@g.us', ['201222222222']);
248
+ ### 4. Chats, Contacts, and History (`client.chats`)
165
249
 
166
- // Promote or demote admins
167
- await botcast.groups.promoteParticipants('group-jid@g.us', ['201000000000']);
250
+ ```typescript
251
+ // 1. List chats / dialogs
252
+ const { chats } = await client.chats.list({ limit: 50 });
168
253
 
169
- // Update permissions and settings
170
- await botcast.groups.updateSettings('group-jid@g.us', 'announcement'); // Only admins can send messages
171
- await botcast.groups.updateSubject('group-jid@g.us', 'New Group Name');
172
- await botcast.groups.updateDescription('group-jid@g.us', 'Official VIP group discussion.');
254
+ // 2. List contacts
255
+ const { contacts } = await client.chats.listContacts({ limit: 100 });
173
256
 
174
- // Get invite link
175
- const invite = await botcast.groups.getInviteCode('group-jid@g.us');
176
- console.log('Invite link:', invite.link);
257
+ // 3. List messages for a chat
258
+ const { messages } = await client.chats.listMessages({ chatJid: '201012345678@s.whatsapp.net', limit: 50 });
259
+
260
+ // 4. Modify WhatsApp chat state (archive, mute, pin, delete)
261
+ await client.chats.archive('201012345678@s.whatsapp.net');
262
+ await client.chats.mute('201012345678@s.whatsapp.net', 8 * 60 * 60 * 1000); // 8 hours
263
+ await client.chats.pin('201012345678@s.whatsapp.net');
177
264
  ```
178
265
 
179
266
  ---
180
267
 
181
- ### 4. Webhook handling
268
+ ### 5. Webhook Event Handling
269
+
270
+ The SDK includes a built-in event dispatcher and middleware for handling inbound webhooks from both WhatsApp and Telegram:
182
271
 
183
- The package includes a helper for parsing incoming events in Express, Fastify, Next.js, or plain Node HTTP:
272
+ #### Express Example
184
273
 
185
- #### Express example:
186
274
  ```typescript
187
275
  import express from 'express';
188
276
  import { BotcastClient } from 'botcast-sdk';
@@ -190,54 +278,37 @@ import { BotcastClient } from 'botcast-sdk';
190
278
  const app = express();
191
279
  app.use(express.json());
192
280
 
193
- const botcast = new BotcastClient({
281
+ const client = new BotcastClient({
282
+ platform: 'telegram', // or 'whatsapp'
194
283
  instanceId: 'inst_123',
195
284
  instanceToken: 'tok_abc',
196
285
  });
197
286
 
198
287
  // Listen for incoming messages
199
- botcast.webhook.onMessage(async (event) => {
200
- console.log(`Incoming message from +${event.sender}: ${event.message}`);
288
+ client.webhook.onMessage(async (event) => {
289
+ console.log(`Message from ${event.sender}: ${event.message} [Platform: ${event.platform || 'whatsapp'}]`);
201
290
 
202
- if (event.message.toLowerCase() === 'ping') {
203
- await botcast.messages.sendText(event.sender, 'pong');
291
+ if (event.message.trim().toLowerCase() === 'ping') {
292
+ await client.messages.sendText(event.sender, 'pong');
204
293
  }
205
294
  });
206
295
 
207
- // Mount the webhook handler
208
- app.post('/webhook', botcast.webhook.middleware());
209
-
210
- app.listen(3000, () => console.log('Webhook server listening on port 3000'));
211
- ```
212
-
213
- ---
214
-
215
- ### 5. Safety rate limits
296
+ // Listen for connection changes
297
+ client.webhook.onConnection(async (event) => {
298
+ console.log(`Instance status updated: ${event.status}`);
299
+ });
216
300
 
217
- You can check and update daily sending caps to control outbound message volume:
301
+ // Mount middleware on your webhook route
302
+ app.post('/webhook/botcast', client.webhook.middleware());
218
303
 
219
- ```typescript
220
- // Read current daily limits
221
- const limits = await botcast.instances.getLimits();
222
- console.log('Daily message limit:', limits.daily_message_limit);
223
- console.log('Daily new contacts limit:', limits.daily_new_contacts_limit);
224
-
225
- // Update limits individually (pass 0 to remove the cap)
226
- await botcast.instances.setDailyMessageLimit(500);
227
- await botcast.instances.setDailyNewContactsLimit(50);
228
-
229
- // Or update both at once
230
- await botcast.instances.updateLimits({
231
- daily_message_limit: 1000,
232
- daily_new_contacts_limit: 100,
233
- });
304
+ app.listen(3000, () => console.log('Webhook server running on port 3000'));
234
305
  ```
235
306
 
236
307
  ---
237
308
 
238
- ### 6. Error handling
309
+ ## Error Handling
239
310
 
240
- The SDK maps API status codes to typed error classes:
311
+ `botcast-sdk` maps API status codes to typed error classes:
241
312
 
242
313
  ```typescript
243
314
  import {
@@ -246,21 +317,27 @@ import {
246
317
  BotcastPaymentRequiredError,
247
318
  BotcastSubscriptionExpiredError,
248
319
  BotcastRateLimitError,
320
+ BotcastValidationError,
321
+ BotcastNotFoundError,
249
322
  } from 'botcast-sdk';
250
323
 
251
324
  try {
252
- await botcast.messages.sendText('201000000000', 'Test');
325
+ await client.messages.sendText('+1234567890', 'Hello World');
253
326
  } catch (error) {
254
327
  if (error instanceof BotcastAuthError) {
255
- console.error('Invalid instance token or instance ID');
328
+ console.error('Invalid instance credentials or token.');
256
329
  } else if (error instanceof BotcastPaymentRequiredError) {
257
- console.error('Instance requires payment confirmation before sending messages');
330
+ console.error('Instance requires payment confirmation.');
258
331
  } else if (error instanceof BotcastSubscriptionExpiredError) {
259
- console.error('Instance subscription expired on:', error.expiresAt);
332
+ console.error('Subscription expired on:', error.expiresAt);
260
333
  } else if (error instanceof BotcastRateLimitError) {
261
- console.error('Rate limit reached. Reduce request frequency.');
334
+ console.error('Daily message limit reached.');
335
+ } else if (error instanceof BotcastValidationError) {
336
+ console.error('Validation error:', error.message, error.details);
337
+ } else if (error instanceof BotcastNotFoundError) {
338
+ console.error('Resource not found:', error.message);
262
339
  } else {
263
- console.error('Request error:', error.message);
340
+ console.error('Unexpected error:', error);
264
341
  }
265
342
  }
266
343
  ```
@@ -270,11 +347,12 @@ try {
270
347
  ## Links
271
348
 
272
349
  - Website: [https://botcast.site](https://botcast.site)
273
- - Dashboard: [https://botcast.site/?lang=en](https://botcast.site/?lang=en)
274
- - Service health: [https://botcast.site/health](https://botcast.site/health)
350
+ - Documentation: [https://botcast.site/docs](https://botcast.site/docs)
351
+ - NPM Package: [https://www.npmjs.com/package/botcast-sdk](https://www.npmjs.com/package/botcast-sdk)
352
+ - GitHub Repository: [https://github.com/ANOOBALSA/Botcast](https://github.com/ANOOBALSA/Botcast)
275
353
 
276
354
  ---
277
355
 
278
356
  ## License
279
357
 
280
- MIT (c) [Botcast](https://botcast.site)
358
+ MIT © [Botcast](https://botcast.site)
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,
@@ -87,5 +88,27 @@ class BotcastClient {
87
88
  async getStatus() {
88
89
  return this.instances.getStatus();
89
90
  }
91
+ /**
92
+ * Shortcut to get the device pairing QR code string.
93
+ */
94
+ async getQR() {
95
+ return this.instances.getQR();
96
+ }
97
+ /**
98
+ * Shortcut to request an 8-digit phone PIN pairing code without scanning QR.
99
+ *
100
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
101
+ */
102
+ async pairWithCode(phoneNumber) {
103
+ return this.instances.pairWithCode(phoneNumber);
104
+ }
105
+ /**
106
+ * Shortcut to verify if a phone number exists on WhatsApp.
107
+ *
108
+ * @param phoneNumber The phone number to check (with country code)
109
+ */
110
+ async checkNumber(phoneNumber) {
111
+ return this.instances.checkNumber(phoneNumber);
112
+ }
90
113
  }
91
114
  exports.BotcastClient = BotcastClient;
package/dist/client.d.ts CHANGED
@@ -60,5 +60,21 @@ export declare class BotcastClient {
60
60
  * Shortcut to check instance connectivity status.
61
61
  */
62
62
  getStatus(): Promise<import("./types/instances.js").InstanceStatusResponse>;
63
+ /**
64
+ * Shortcut to get the device pairing QR code string.
65
+ */
66
+ getQR(): Promise<import("./types/instances.js").InstanceQRResponse>;
67
+ /**
68
+ * Shortcut to request an 8-digit phone PIN pairing code without scanning QR.
69
+ *
70
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
71
+ */
72
+ pairWithCode(phoneNumber: string): Promise<import("./types/instances.js").PairCodeResponse>;
73
+ /**
74
+ * Shortcut to verify if a phone number exists on WhatsApp.
75
+ *
76
+ * @param phoneNumber The phone number to check (with country code)
77
+ */
78
+ checkNumber(phoneNumber: string): Promise<import("./types/instances.js").CheckNumberResponse>;
63
79
  }
64
80
  //# sourceMappingURL=client.d.ts.map
@@ -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,CAAC;IAE9B,gDAAgD;IACzC,SAAS,EAAE,eAAe,CAAC;IAElC,mCAAmC;IAC5B,OAAO,EAAE,cAAc,CAAC;IAE/B;;;;;;;;;;;;;;;;;;OAkBG;gBACS,MAAM,EAAE,mBAAmB;IA8BvC;;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,OAA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C;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,
@@ -84,4 +85,26 @@ export class BotcastClient {
84
85
  async getStatus() {
85
86
  return this.instances.getStatus();
86
87
  }
88
+ /**
89
+ * Shortcut to get the device pairing QR code string.
90
+ */
91
+ async getQR() {
92
+ return this.instances.getQR();
93
+ }
94
+ /**
95
+ * Shortcut to request an 8-digit phone PIN pairing code without scanning QR.
96
+ *
97
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
98
+ */
99
+ async pairWithCode(phoneNumber) {
100
+ return this.instances.pairWithCode(phoneNumber);
101
+ }
102
+ /**
103
+ * Shortcut to verify if a phone number exists on WhatsApp.
104
+ *
105
+ * @param phoneNumber The phone number to check (with country code)
106
+ */
107
+ async checkNumber(phoneNumber) {
108
+ return this.instances.checkNumber(phoneNumber);
109
+ }
87
110
  }
@@ -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,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,qBAAa,UAAU;IACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;gBAEpC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAIjD;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAK5C;;OAEG;IACU,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAyFlE,OAAO,CAAC,eAAe;CAuBxB"}
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,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,qBAAa,UAAU;IACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;gBAEpC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAIjD;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAM5C;;OAEG;IACU,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;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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AyB,CAAC;IAQ5F;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ3E;;OAEG;IACU,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAQlG;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAOzD;;;;OAIG;IACU,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAcjI;;;;OAIG;IACU,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3H;;;;OAIG;IACU,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/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,kBAAk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AAC;IAQ/D;;OAEG;IACU,IAAI,CACf,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAQ/D;;OAEG;IACU,MAAM,CACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAQ/D;;OAEG;IACU,UAAU,CACrB,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,GAC9B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAS/D;;OAEG;IACU,KAAK,CAChB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,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.2",
4
- "description": "Official TypeScript/JavaScript SDK for Botcast WhatsApp Multi-Instance API Gateway",
3
+ "version": "1.0.4",
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",