Skip to main content
Get your first BuilderBot chatbot up and running in minutes with this quick start guide.

Prerequisites

  • Node.js 18 or higher
  • npm, pnpm, or yarn package manager

Create your first bot

1

Create a new project

Use the BuilderBot CLI to scaffold a new project:
npm create builderbot@latest
You’ll be prompted to choose:
  • Project name: Your bot’s directory name
  • Provider: Messaging platform (start with Baileys for WhatsApp)
  • Database: Storage option (start with Memory for testing)
  • Language: TypeScript or JavaScript
2

Navigate to your project

cd your-project-name
3

Install dependencies

npm install
4

Start your bot

npm start
For WhatsApp providers like Baileys, scan the QR code that appears in your terminal with WhatsApp.
5

Test your bot

Send a message to your bot:
  • Send hi, hello, or hola to trigger the welcome flow
  • Type doc to see the documentation flow
  • Try samples to receive media files

Understanding the basic structure

Your generated bot includes a simple conversation flow. Here’s what the code looks like:
import { createBot, createProvider, createFlow, addKeyword } from '@builderbot/bot'
import { MemoryDB as Database } from '@builderbot/bot'
import { BaileysProvider as Provider } from '@builderbot/provider-baileys'

// Define a simple welcome flow
const welcomeFlow = addKeyword(['hi', 'hello', 'hola'])
    .addAnswer('🙌 Hello welcome to this *Chatbot*')
    .addAnswer('I share with you the following links of interest about the project')

// Create the bot
const main = async () => {
    const adapterFlow = createFlow([welcomeFlow])
    const adapterProvider = createProvider(Provider)
    const adapterDB = new Database()

    await createBot({
        flow: adapterFlow,
        provider: adapterProvider,
        database: adapterDB,
    })
}

main()

Next steps

Learn core concepts

Understand flows, keywords, and conversation patterns

Explore providers

Connect to WhatsApp, Telegram, email, and more

Add a database

Persist conversations with MongoDB, PostgreSQL, or MySQL

Build advanced flows

Create complex multi-step conversations

Common patterns

Capture user input

const nameFlow = addKeyword('register')
    .addAnswer('What is your name?', { capture: true }, async (ctx, { state }) => {
        await state.update({ name: ctx.body })
    })
    .addAnswer('What is your email?', { capture: true }, async (ctx, { state }) => {
        await state.update({ email: ctx.body })
    })
    .addAction(async (_, { flowDynamic, state }) => {
        await flowDynamic(`Thanks ${state.get('name')}! We'll contact you at ${state.get('email')}`)
    })

Send media

const mediaFlow = addKeyword('photo')
    .addAnswer('Here is your image', { 
        media: 'https://example.com/image.jpg' 
    })

Create custom HTTP endpoints

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

adapterProvider.server.post(
    '/v1/messages',
    handleCtx(async (bot, req, res) => {
        const { number, message } = req.body
        await bot.sendMessage(number, message)
        return res.end('sent')
    })
)

httpServer(3000)

Need help?

Build docs developers (and LLMs) love