Skip to main content
The Web WhatsApp provider enables WhatsApp integration through direct WhatsApp Web automation, providing a lightweight solution for WhatsApp chatbots.

Features

  • QR code authentication
  • Text messaging
  • Media support
  • Session persistence
  • WhatsApp Web automation
  • Group messaging
  • Contact management

Installation

npm install @builderbot/bot @builderbot/provider-web-whatsapp

Configuration

Basic Setup

import { createBot, createProvider, createFlow } from '@builderbot/bot'
import { WebWhatsAppProvider } from '@builderbot/provider-web-whatsapp'
import { MemoryDB } from '@builderbot/bot'

const provider = createProvider(WebWhatsAppProvider, {
  name: 'my-bot',
  port: 3000
})

const { handleCtx, httpServer } = await createBot({
  flow: adapterFlow,
  provider: provider,
  database: new MemoryDB(),
})

httpServer(3000)

Authentication

QR Code

On first run:
  1. Start your bot
  2. QR code appears at http://localhost:3000/
  3. Scan with WhatsApp
  4. Wait for connection

Session Persistence

Sessions are saved automatically in:
{name}_sessions/

Basic Usage

Sending Messages

import { addKeyword } from '@builderbot/bot'

const welcomeFlow = addKeyword(['hi', 'hello'])
  .addAnswer('Hello! Welcome')
  .addAnswer('How can I help?')

Sending Media

const mediaFlow = addKeyword('media')
  .addAnswer('Here is an image:', {
    media: './assets/image.jpg'
  })

Best Practices

  • Backup session files
  • Monitor session health
  • Implement reconnection logic
  • Use headless browser mode
  • Monitor memory usage
  • Restart periodically

Further Resources

Build docs developers (and LLMs) love