{"_id":"@akson/chatsuite-sdk","_rev":"6-a26b3a538611ea275c1df4bf32a92fdc","name":"@akson/chatsuite-sdk","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@akson/chatsuite-sdk","version":"1.0.0","keywords":["chatsuite","messaging","whatsapp","api","sdk","typescript","automation"],"author":{"name":"ChatSuite Team"},"license":"MIT","_id":"@akson/chatsuite-sdk@1.0.0","maintainers":[{"name":"akson","email":"contact@akson.ch"}],"homepage":"https://github.com/antoineschaller/chatsuite/tree/main/packages/sdk#readme","bugs":{"url":"https://github.com/antoineschaller/chatsuite/issues"},"dist":{"shasum":"4aa99d853849d8748eaeea62689c88215b2d757f","tarball":"https://registry.npmjs.org/@akson/chatsuite-sdk/-/chatsuite-sdk-1.0.0.tgz","fileCount":9,"integrity":"sha512-xXY1hmQAKwToKlhVYRJRaXXJm7QLgd2nVXnGGt/gewyuKoQE3ZeaHPSwDbHDMEwutYWGnmx2ahtCHkm3HIi/ig==","signatures":[{"sig":"MEUCIQDS5INl1bpR4JiEBKiuJ9qbB/+3l42FHala0MomVnXQYQIgKjwfMxkCU6PGUEM4tRBqU7aTbQfZ0j4CIz8poA4Dav8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":462401},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=16.0.0"},"gitHead":"883d3c1e744aa9bf2ffd20d9d80d843223a03b3b","scripts":{"dev":"tsup --watch","lint":"eslint . --ext .ts,.tsx","test":"jest","build":"tsup","test:watch":"jest --watch","type-check":"tsc --noEmit","publish:dry":"npm pack --dry-run","publish:test":"node publish-test.js","release:major":"npm version major && git push --follow-tags","release:minor":"npm version minor && git push --follow-tags","release:patch":"npm version patch && git push --follow-tags","prepublishOnly":"npm run build && npm run test && npm run type-check"},"_npmUser":{"name":"akson","actor":{"name":"akson","type":"user","email":"contact@akson.ch"},"email":"contact@akson.ch"},"repository":{"url":"git+https://github.com/antoineschaller/chatsuite.git","type":"git","directory":"packages/sdk"},"_npmVersion":"10.7.0","description":"TypeScript SDK for ChatSuite - Easy integration for multi-platform messaging automation","directories":{},"_nodeVersion":"20.15.1","dependencies":{"axios":"^1.6.7","form-data":"^4.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.0.2","eslint":"^8.57.0","ts-jest":"^29.1.2","typescript":"^5.3.3","@types/jest":"^29.5.12","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"_npmOperationalInternal":{"tmp":"tmp/chatsuite-sdk_1.0.0_1751887904753_0.6988919454884597","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Deprecated: no consumers. No longer maintained."},"2.0.0":{"name":"@akson/chatsuite-sdk","version":"2.0.0","keywords":["chatsuite","messaging","whatsapp","api","sdk","typescript","automation","session-management","message-queue","webhook-server","database-sync","rate-limiting","baileys","chatbot","mongodb","production-ready"],"author":{"name":"ChatSuite Team"},"license":"MIT","_id":"@akson/chatsuite-sdk@2.0.0","maintainers":[{"name":"akson","email":"contact@akson.ch"}],"homepage":"https://github.com/antoineschaller/chatsuite/tree/main/packages/sdk#readme","bugs":{"url":"https://github.com/antoineschaller/chatsuite/issues"},"dist":{"shasum":"9aef603b7ec0a62dc613f744465d06217d3e7ff0","tarball":"https://registry.npmjs.org/@akson/chatsuite-sdk/-/chatsuite-sdk-2.0.0.tgz","fileCount":19,"integrity":"sha512-uP4JMiLfE1QQghjdb9DQRSCy06okjsPGMzZll8e2Dn68LXvInnhiIZQnFz0Y7qaKWz3m4jvkkG22j8GiZloxKA==","signatures":[{"sig":"MEUCIQC/tCbIjTFBf1saWBkgIYLve8qH3sfYHQC1ZdgfZ5OKLQIgZNWAXKJRe1QutzkN21hsh50MFuXzCZwGO2RzLpHtgOk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1037321},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=16.0.0"},"gitHead":"ecfe75fa28729b96079ce664631cbbc0a5da818e","scripts":{"dev":"tsup --watch","lint":"eslint . --ext .ts,.tsx","test":"jest","build":"tsup","test:watch":"jest --watch","type-check":"tsc --noEmit","publish:dry":"npm pack --dry-run","publish:test":"node publish-test.js","release:major":"npm version major && git push --follow-tags","release:minor":"npm version minor && git push --follow-tags","release:patch":"npm version patch && git push --follow-tags","prepublishOnly":"npm run build && npm run test && npm run type-check"},"_npmUser":{"name":"akson","actor":{"name":"akson","type":"user","email":"contact@akson.ch"},"email":"contact@akson.ch"},"repository":{"url":"git+https://github.com/antoineschaller/chatsuite.git","type":"git","directory":"packages/sdk"},"_npmVersion":"10.7.0","description":"Production-ready TypeScript SDK for ChatSuite - WhatsApp automation with built-in session management, message queuing, webhook server, and database sync","directories":{},"_nodeVersion":"20.15.1","dependencies":{"axios":"^1.6.7","form-data":"^4.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.0.2","eslint":"^8.57.0","ts-jest":"^29.1.2","typescript":"^5.3.3","@types/jest":"^29.5.12","@types/node":"^20.11.24","@typescript-eslint/parser":"^7.1.0","@typescript-eslint/eslint-plugin":"^7.1.0"},"peerDependencies":{"express":"^4.18.0","mongodb":"^6.0.0"},"peerDependenciesMeta":{"express":{"optional":true},"mongodb":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/chatsuite-sdk_2.0.0_1751897189586_0.47005173137828726","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Deprecated: no consumers. No longer maintained."}},"time":{"created":"2025-07-07T11:31:44.614Z","modified":"2026-03-19T12:46:20.835Z","1.0.0":"2025-07-07T11:31:45.004Z","2.0.0":"2025-07-07T14:06:29.852Z"},"bugs":{"url":"https://github.com/antoineschaller/chatsuite/issues"},"author":{"name":"ChatSuite Team"},"license":"MIT","homepage":"https://github.com/antoineschaller/chatsuite/tree/main/packages/sdk#readme","keywords":["chatsuite","messaging","whatsapp","api","sdk","typescript","automation","session-management","message-queue","webhook-server","database-sync","rate-limiting","baileys","chatbot","mongodb","production-ready"],"repository":{"url":"git+https://github.com/antoineschaller/chatsuite.git","type":"git","directory":"packages/sdk"},"description":"Production-ready TypeScript SDK for ChatSuite - WhatsApp automation with built-in session management, message queuing, webhook server, and database sync","maintainers":[{"name":"antoineschaller","email":"antoine.schaller@akson.ch"}],"readme":"# ChatSuite SDK 🚀\n\n**Production-ready TypeScript SDK for ChatSuite** - WhatsApp automation with comprehensive session management, message operations, webhooks, and **enterprise-grade automation features**.\n\n## ✨ Core Features\n\n- **🗄️ Session Management**: Complete session lifecycle with QR code handling\n- **📬 Message Operations**: Text, media, interactive messages, polls, reactions\n- **👥 Group Management**: Create, manage, and moderate WhatsApp groups  \n- **📞 Contact Management**: Check registration, manage contacts, profile pictures\n- **📝 Status Updates**: Post and manage WhatsApp status (stories)\n- **🔗 Webhook Integration**: Real-time event handling\n- **🧪 Production Ready**: Comprehensive error handling and TypeScript support\n\n## 🚀 Enhanced Automation Features\n\n- **🤖 Bot Framework**: Command parsing, middleware, conversation management\n- **📬 Message Queue**: Rate limiting, bulk operations, priority handling, retry logic\n- **🗄️ Database Sync**: MongoDB integration with field mapping and transformers\n- **🔄 Polling Service**: Smart message syncing with adaptive intervals\n- **💾 Session Management**: Health monitoring, auto-recovery, persistence\n- **📊 Metrics Collection**: Performance monitoring, observability, multiple exporters\n- **🔄 Migration Helper**: Format adapters and compatibility layers\n\n## 📈 Dramatic Code Reduction\n\nWith the enhanced SDK features, reduce implementation complexity by **80-96%**:\n\n| Feature | Without SDK | With SDK | Reduction |\n|---------|-------------|----------|-----------|\n| Session Management | 120 lines | 10 lines | **92%** |\n| Database Sync | 80 lines | 15 lines | **81%** |\n| Message Queue | 60 lines | 8 lines | **87%** |\n| Bot Framework | 100 lines | 25 lines | **75%** |\n| **Complete Project** | **775 lines** | **30 lines** | **96%** |\n\n## Installation\n\n```bash\nnpm install @akson/chatsuite-sdk\n# or\nyarn add @akson/chatsuite-sdk\n# or\npnpm add @akson/chatsuite-sdk\n```\n\n## ⚡ Quick Start\n\n### Basic Usage\n\n```typescript\nimport { WhatsAppClient } from '@akson/chatsuite-sdk';\n\nconst client = new WhatsAppClient({\n  apiToken: 'wa_your_token_here'\n});\n\n// Send a message\nawait client.messages.sendText('+1234567890', '1234567890@c.us', 'Hello!');\n```\n\n### 🚀 Complete Automation (30 lines replaces 775+ lines!)\n\n```typescript\nimport { WhatsAppClient, ConsoleExporter } from '@akson/chatsuite-sdk';\n\nconst client = new WhatsAppClient({\n  apiToken: 'wa_your_token_here'\n});\n\n// Complete WhatsApp automation in just a few lines\nconst automation = await client.createAutomation('+1234567890', {\n  name: 'My WhatsApp Bot',\n  webhookUrl: 'https://my-server.com/webhook',\n  \n  // Bot with commands and middleware\n  bot: {\n    prefix: '!',\n    maxCommandsPerMinute: 10\n  },\n  \n  // Message queue with rate limiting\n  queue: {\n    maxConcurrent: 5,\n    rateLimitPerMinute: 30\n  },\n  \n  // Database sync\n  database: {\n    uri: 'mongodb://localhost:27017',\n    collections: {\n      messages: 'whatsapp_messages',\n      chats: 'whatsapp_chats'\n    }\n  },\n  \n  // Smart polling\n  polling: {\n    interval: 5 * 60 * 1000,\n    strategy: 'smart'\n  },\n  \n  // Metrics collection\n  metrics: {\n    enabled: true,\n    collectors: ['messages', 'sessions'],\n    exporters: [new ConsoleExporter()]\n  }\n});\n\n// Bot is ready with all features!\nconsole.log('Automation active:', automation);\n```\n\n## 🤖 Enhanced Automation Features\n\n### Bot Framework\n\nCreate sophisticated bots with command parsing and middleware:\n\n```typescript\n// Create bot\nconst bot = client.createBot('+1234567890', {\n  prefix: '!',\n  maxCommandsPerMinute: 10\n});\n\n// Add middleware\nbot.use(middleware.userContext(getUserFromDB));\nbot.use(middleware.logging());\n\n// Add commands\nbot.addCommand({\n  name: 'order',\n  description: 'Check order status',\n  handler: async (context, args) => {\n    const orderId = args[0];\n    const order = await getOrder(orderId);\n    return `Order ${orderId}: ${order.status}`;\n  }\n});\n\nbot.start();\n```\n\n### Message Queue\n\nHandle bulk messaging with rate limiting and priorities:\n\n```typescript\n// Create queue\nconst queue = client.createMessageQueue({\n  maxConcurrent: 5,\n  rateLimitPerMinute: 30\n});\n\n// Add messages\nawait queue.enqueue({\n  tel: '+1234567890',\n  chatId: '1234567890@c.us',\n  content: { text: 'Urgent notification!' },\n  type: 'text',\n  priority: 'urgent'\n});\n\nqueue.start();\n```\n\n### Database Sync\n\nAutomatically sync WhatsApp data to MongoDB:\n\n```typescript\n// Create database adapter\nconst dbAdapter = client.createDatabaseAdapter({\n  uri: 'mongodb://localhost:27017',\n  collections: { messages: 'whatsapp_messages' },\n  fieldMapping: {\n    'key.id': 'messageId',\n    'messageTimestamp': {\n      target: 'timestamp',\n      transform: (ts) => new Date(ts * 1000)\n    }\n  }\n});\n\nawait dbAdapter.connect();\nawait dbAdapter.sync('messages', messages);\n```\n\n### Polling Service\n\nSmart message syncing with adaptive intervals:\n\n```typescript\n// Create polling service\nconst poller = client.createPollingService('+1234567890', {\n  interval: 5 * 60 * 1000,\n  strategy: 'smart'\n});\n\npoller.start();\n```\n\n### Session Management\n\nAdvanced session handling with health monitoring:\n\n```typescript\n// Create session manager\nconst sessionManager = client.createSessionManager({\n  autoRestart: true,\n  healthCheckInterval: 60000\n});\n\nawait sessionManager.restoreSession('+1234567890');\n```\n\n### Metrics Collection\n\nMonitor performance and collect observability data:\n\n```typescript\n// Create metrics collector\nconst metrics = client.createMetricsCollector({\n  enabled: true,\n  exporters: [new ConsoleExporter(), new PrometheusExporter()]\n});\n\nmetrics.increment('messages_sent_total');\nmetrics.histogram('message_duration_ms', duration);\n```\n\n## 📱 Core API Features\n\n### Session Management\n\n```typescript\n// List sessions\nconst sessions = await client.sessions.list();\n\n// Quick session setup with QR polling\nconst result = await client.quickStart('+1234567890', 'My Bot');\nconsole.log('Scan QR:', result.session.qr);\n```\n\n### Messages\n\n```typescript\n// Send text\nawait client.messages.sendText('+1234567890', '1234567890@c.us', 'Hello!');\n\n// Send interactive buttons  \nawait client.messages.sendButtons('+1234567890', '1234567890@c.us', 'Choose:', [\n  { id: '1', text: 'Option 1' },\n  { id: '2', text: 'Option 2' }\n]);\n\n// Send polls\nawait client.messages.sendPoll('+1234567890', '1234567890@c.us', 'Question?', [\n  'Option A', 'Option B'\n]);\n```\n\n### Groups & Business\n\n```typescript\n// Create group\nconst group = await client.groups.create({\n  tel: '+1234567890',\n  name: 'Team Chat',\n  participants: ['user1@c.us', 'user2@c.us']\n});\n\n// Business catalog\nconst products = await client.business.listProducts('+1234567890');\nawait client.business.createCart('+1234567890', 'customer@c.us');\n```\n\n## Error Handling\n\n```typescript\nimport { WhatsAppClient, ApiError } from '@akson/chatsuite-sdk';\n\ntry {\n  await client.messages.sendText(tel, to, text);\n} catch (error) {\n  if (error instanceof ApiError) {\n    console.error('API Error:', {\n      message: error.message,\n      status: error.status,\n      code: error.code\n    });\n  }\n}\n```\n\n## TypeScript Support\n\nFull TypeScript definitions included:\n\n```typescript\nimport { \n  WhatsAppClient,\n  Session,\n  Message,\n  Contact,\n  Group,\n  ApiError\n} from '@akson/chatsuite-sdk';\n```\n\n## Authentication\n\nGet your API token from the ChatSuite dashboard:\n\n```typescript\nconst client = new WhatsAppClient({\n  apiToken: 'wa_your_token_here',\n  baseUrl: 'https://your-instance.com', // optional\n  timeout: 30000, // optional\n  maxRetries: 3 // optional\n});\n```\n\n## Documentation\n\n- **[Changelog](./CHANGELOG.md)** - Version history and changes\n- **[Examples](./examples/)** - Usage examples and integration guides\n- **[TypeScript Types](./src/types/)** - Complete type definitions\n\n## Support\n\n- 🐛 **Issues**: [GitHub Issues](https://github.com/antoineschaller/whatsapp-baileys-api/issues)\n- 💬 **Discussions**: [GitHub Discussions](https://github.com/antoineschaller/whatsapp-baileys-api/discussions)\n- 📖 **API Reference**: https://api.chatsuite.com/docs\n\n## License\n\nMIT License - see [LICENSE](./LICENSE) file for details.","readmeFilename":"README.md"}