WhatsApp Business API is a paid service. This guide uses the free Baileys library which connects via WhatsApp Web protocol. Use responsibly and in compliance with WhatsApp’s Terms of Service.
# ~/.orcbot/orcbot.config.yaml# Enable WhatsApp channelwhatsappEnabled: true# Session storage pathwhatsappSessionPath: ~/.orcbot/whatsapp-session# Auto-reply to incoming messageswhatsappAutoReplyEnabled: true# Reply to WhatsApp Status updateswhatsappStatusReplyEnabled: false# Auto-react with emojis to messageswhatsappAutoReactEnabled: false# Context profiling for better responseswhatsappContextProfilingEnabled: true# Owner JID (auto-populated on first connection)whatsappOwnerJID: "1234567890@s.whatsapp.net"
OrcBot automatically downloads and analyzes media:
// User sends photo with caption "What is this?"// OrcBot downloads imageconst mediaPath = path.join(downloadsDir, `wa_${messageId}.jpg`);fs.writeFileSync(mediaPath, buffer);// Auto-analyzes the imageconst analysis = await this.agent.llm.analyzeMedia( mediaPath, 'The user sent this image with the message: "What is this?". Describe what you see in detail.');// Responds with analysis"This appears to be a Golden Retriever puppy, approximately 3-4 months old..."
// User sends voice message// OrcBot downloads audioconst mediaPath = path.join(downloadsDir, `wa_${messageId}.ogg`);fs.writeFileSync(mediaPath, buffer);// Auto-transcribesconst transcription = await this.agent.llm.analyzeMedia( mediaPath, 'Transcribe this audio message exactly.');// Processes transcribed text"Transcription: 'Remind me to buy groceries tomorrow'""✅ Reminder set for tomorrow: Buy groceries"
// User sends PDF document// OrcBot downloads fileconst mediaPath = path.join(downloadsDir, `wa_${messageId}.pdf`);fs.writeFileSync(mediaPath, buffer);// Analyzes document (if LLM supports)"I've received the 5-page contract document. Would you like me to:1. Summarize key terms2. Extract dates and obligations3. Review for potential issues"
// Send an imagesend_file( to: "1234567890@s.whatsapp.net", filePath: "/path/to/chart.png", caption: "Here's the sales chart you requested", channel: "whatsapp")// Send a documentsend_file( to: "1234567890@s.whatsapp.net", filePath: "/path/to/report.pdf", caption: "Monthly report attached", channel: "whatsapp")
// When user replies to a messageif (contextInfo?.quotedMessage) { const quotedText = contextInfo.quotedMessage.conversation || '[Media]'; const quotedName = contextInfo.participant.split('@')[0]; replyContext = `[Replying to ${quotedName}'s message: "${quotedText}"]`;}
Example conversation:
Alice: "What's the weather?"You: [Reply to Alice] "@bot answer this"Bot: "Based on Alice's question about weather..." [Reply includes context from Alice's original message]
You: [sends PDF invoice] "Extract the total amount and due date"Bot: "🤖 Analyzing document... Total Amount: $1,234.56 Due Date: March 15, 2024 Invoice #: INV-2024-001"
Family Group:Alice: "What time is dinner?"Bob: "Where are we meeting?"@OrcBot: "Summarize the last 10 messages"Bot: "🤖 Recent discussion: - Alice asked about dinner time - Bob asked about meeting location - Mom suggested 7 PM at home - Dad confirmed he'll bring dessert"