What You Get
- -Lead research workflow
- -Message generation with personalization
- -Follow-up scheduling logic
- -CRM update automation
- -Human escalation rule engine
Step by Step
1. Set up the database
Create a PostgreSQL database with tables for leads (id, name, phone, company, role, source, status, enriched_data), messages (id, lead_id, content, direction, status, sent_at), and escalation_log (id, lead_id, reason, assigned_to, resolved_at).
2. Configure WhatsApp Business API
Register for WhatsApp Business API access. Set up a webhook endpoint to receive incoming messages and delivery status callbacks. Configure rate limits (250 messages per day per number for marketing).
3. Build lead import and enrichment
Create an API to accept lead CSV uploads. On import, enrich each lead using OpenAI: extract company info, role seniority, and potential pain points from their website. Store enriched data as JSON in the leads table.
4. Implement message generation
Use OpenAI to generate personalized WhatsApp messages. Prompt should include: lead name, company, role, a relevant pain point, and a clear call to action. Include template variables for fallback.
5. Build the sending pipeline
Create a queue-based sending system that processes leads in batches. Send messages, update status, and handle delivery receipts via webhook. Implement retry logic for failed sends.
6. Track replies and escalate
Parse incoming WhatsApp messages. Use OpenAI to classify intent: interested, not interested, need more info. Auto-escalate interested leads to a human via Slack webhook or CRM task creation.
7. Build the dashboard
Create a simple Next.js dashboard: lead list with status filters, message history view, escalation queue for human review, and stats (sent, delivered, replied, conversion rate).
Stack
Build This
Copy this prompt and paste it into Claude Code, OpenCode, Codex, or Cursor to build this recipe.
Common Failure Modes
- !WhatsApp number not connected to API
- !Rate limiting from WhatsApp
- !Message templates rejected by WhatsApp review
- !Poor personalization from bad lead data
Implementation Notes
Start with 5 test leads before scaling to full list. Verify WhatsApp Business API credentials before building the agent. Use a staging phone number first.
Related skill: whatsapp sales outreach
Want whatsapp sales agent running in your business?
4M Labs can deploy whatsapp sales agent as a production workflow:
- Connected to your tools and data sources
- Secured for your team with proper access controls
- Deployed with monitoring and error handling
- Documented for handoff and future maintenance