Example Next.js app demonstrating Kapso's Broadcasts API for WhatsApp mass messaging campaigns.
- 5-step wizard UI - Clean, intuitive stepper interface
- Batch recipient upload - Add up to 1,000 recipients per request via CSV
- Real-time progress tracking - Auto-polling during broadcast send
- Recipient-level analytics - Per-phone delivery status with pagination
- Response rate metrics - Track engagement and campaign performance
# Clone the repository
git clone https://github.com/gokapso/whatsapp-broadcasts-example.git
cd whatsapp-broadcasts-example
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Add your Kapso API key and WhatsApp phone number ID
# Run development server
npm run dev- Sign up at app.kapso.ai
- Go to Sidebar → API Keys
- Create a new API key
- Copy the key to your
.envfile
- In your Kapso dashboard, go to Connected numbers and connect a WhatsApp Business account
- Copy the phone number ID from your connected WhatsApp number
- Copy your WhatsApp Business Account ID
- Add both IDs to your
.envfile:PHONE_NUMBER_ID- Used for sending broadcastsNEXT_PUBLIC_PHONE_NUMBER_ID- Used for client-side displayBUSINESS_ACCOUNT_ID- Used for fetching templates
- In Kapso dashboard (or directly in Meta), create WhatsApp message templates
- Get them approved by Meta
- Templates will appear in the app automatically
Upload a CSV file with phone numbers and template parameters:
phone,param1,param2
+15551234567,John,Order123
+15559876543,Jane,Order456
- First column: Phone number (E.164 format with + prefix)
- Remaining columns: Template parameters in order
This app uses the following Kapso API endpoints:
GET /whatsapp_templates- Fetch approved templatesPOST /whatsapp_broadcasts- Create draft broadcastPOST /whatsapp_broadcasts/:id/recipients- Add recipientsPOST /whatsapp_broadcasts/:id/send- Send broadcastGET /whatsapp_broadcasts/:id- Get broadcast statusGET /whatsapp_broadcasts/:id/recipients- List recipients
- Next.js 15 - React framework
- TypeScript - Type safety
- Tailwind CSS v4 - Styling
- shadcn/ui - UI components
- Kapso API - WhatsApp broadcasts
src/
├── app/
│ ├── api/
│ │ ├── broadcasts/ # Broadcast API routes
│ │ └── templates/ # Template API routes
│ └── page.tsx # Main stepper UI
├── components/ui/ # shadcn components
├── lib/
│ ├── kapso-api.ts # Kapso API client
│ ├── csv-parser.ts # CSV parsing utilities
│ └── utils.ts # Utility functions
└── types/index.ts # TypeScript types
MIT