UNPKG

@akson/chatsuite-sdk

Version:

Production-ready TypeScript SDK for ChatSuite - WhatsApp automation with built-in session management, message queuing, webhook server, and database sync

134 lines (108 loc) • 3.7 kB
/** * ChatSuite SDK v2.0 Examples * * This directory contains comprehensive examples demonstrating all the enhanced features * available in ChatSuite SDK v2.0. * * Examples included: * - Enhanced Client: Complete integration example * - Session Management: Advanced session handling * - Message Queue: Priority queuing and rate limiting * - Webhook Server: Built-in webhook server * - Database Sync: MongoDB integration (in other examples) */ // Example imports export { enhancedClientExample } from './enhanced-client'; export { sessionManagementExample } from './session-management'; export { messageQueueExample } from './message-queue'; export { webhookServerExample } from './webhook-server'; // Main demo runner export async function runAllExamples() { console.log('šŸš€ ChatSuite SDK v2.0 - Running All Examples\n'); try { console.log('1ļøāƒ£ Enhanced Client Example'); console.log('='.repeat(50)); // Note: This would run the enhanced client example // await enhancedClientExample(); console.log('\n2ļøāƒ£ Session Management Example'); console.log('='.repeat(50)); // await sessionManagementExample(); console.log('\n3ļøāƒ£ Message Queue Example'); console.log('='.repeat(50)); // await messageQueueExample(); console.log('\n4ļøāƒ£ Webhook Server Example'); console.log('='.repeat(50)); // await webhookServerExample(); console.log('\nāœ… All examples completed successfully!'); } catch (error) { console.error('āŒ Error running examples:', error); } } /** * Quick start guide */ export function printQuickStart() { console.log(` šŸš€ ChatSuite SDK v2.0 - Quick Start Examples To run individual examples: šŸ“¦ Basic Setup: npm install @akson/chatsuite-sdk npm install mongodb express # Optional dependencies šŸ”§ Environment Variables: export WHATSAPP_API_TOKEN="wa_your_token_here" export MONGODB_URI="mongodb://localhost:27017/whatsapp" šŸ“‹ Examples: 1. Enhanced Client (All-in-One): npx ts-node examples/enhanced-client.ts Features: - āœ… Session management with MongoDB - āœ… Message queuing with rate limiting - āœ… Webhook server integration - āœ… Database synchronization - āœ… Real-time event handling 2. Session Management: npx ts-node examples/session-management.ts Features: - āœ… Multi-session handling - āœ… Auto-reconnection logic - āœ… Health monitoring - āœ… MongoDB persistence 3. Message Queue: npx ts-node examples/message-queue.ts Features: - āœ… Priority-based queuing - āœ… Rate limiting and throttling - āœ… Retry logic with backoff - āœ… Bulk operations - āœ… Real-time statistics 4. Webhook Server: npx ts-node examples/webhook-server.ts Features: - āœ… Built-in Express server - āœ… Event routing and handling - āœ… Signature verification - āœ… CORS and rate limiting - āœ… Health monitoring šŸ”„ Migration from v1.x: // v1.x (Basic Client) import { WhatsAppClient } from '@akson/chatsuite-sdk'; const client = new WhatsAppClient({ apiToken: 'token' }); // v2.0 (Enhanced Client) import { createEnhancedClient } from '@akson/chatsuite-sdk'; const client = createEnhancedClient({ apiToken: 'token', mongoUri: 'mongodb://localhost:27017/whatsapp' }); šŸ“š Documentation: - Enhanced Features: README-ENHANCED.md - API Reference: README.md - Changelog: CHANGELOG.md šŸ†˜ Support: - Issues: https://github.com/antoineschaller/whatsapp-baileys-api/issues - Discussions: https://github.com/antoineschaller/whatsapp-baileys-api/discussions `); } // Print quick start when this file is run directly if (require.main === module) { printQuickStart(); }