Bot Browser Automation

Give a messaging bot a local Playwright browser it can drive to complete web tasks

--browser gives your bot a browser_automate tool that drives a real local Chromium — no cloud API key required.

Diagram

💬 User

🤖 Bot Agent

🔧 browser_automate

🎭 PlaywrightBrowserAgent

🌐 Chromium

✅ Result

Quick Start

  1. Install the local browser
    bash
    pip install "praisonai-browser[playwright]"
    playwright install chromium

    This playwright install chromium step is required — no browsers are downloaded automatically by pip install in any tier.

  2. Enable on a bot
    bash
    # Headed — a visible Chromium window opens
    praisonai bot telegram --token $TELEGRAM_BOT_TOKEN --browser
    
    # Headless — Chromium runs invisibly (recommended for servers)
    praisonai bot telegram --token $TELEGRAM_BOT_TOKEN --browser --browser-headless
  3. Try it from your chat

    Message the bot from Telegram, Slack, or Discord:

    Go to news.ycombinator.com and tell me the top 3 stories.

    The agent calls browser_automate(goal="Get the top 3 stories", start_url="https://news.ycombinator.com"), the local Chromium opens (or stays headless), and the bot replies with the summary.


How It Works

--browser prefers local Playwright automation and falls back to the cloud tool only when the local browser is unavailable.

Diagram
🌐 Chromium🎭 PlaywrightBrowserAgent🔧 browser_automate🤖 Bot💬 User🌐 Chromium🎭 PlaywrightBrowserAgent🔧 browser_automate🤖 Bot💬 User“Summarise the top 3 stories”browser_automate(goal, start_url)spawn local browser agentnavigate + snapshot + clickpage content{“success”: True, …}result dictsummary reply
PieceWhat it does
browser_available()Returns True only when both praisonai_browser and playwright import. Guards against selecting local automation that would fail at launch.
create_browser_tool(...)Builds the browser_automate callable the agent sees, passing through model, headless, and profile.
BrowserBaseTool (fallback)Cloud scraping tool used when the local browser is missing. Requires BrowserBase credentials.

Configuration Options

OptionTypeDefaultDescription
--browserflagoffTurn the tool on. Off by default so bots stay lightweight.
--browser-headlessflagoffRun Chromium without a visible window. Recommended for servers.
--browser-profile NAMEstr"default"Currently accepted but not yet applied — the local Playwright agent opens a fresh ephemeral context each session.
--model MODELstrgpt-4o-miniSame flag as the bot’s own model. Also drives the browser tool’s internal LLM.
browser_automate(goal, start_url)callablestart_url="https://www.google.com"The tool the agent sees. goal is required; start_url defaults to Google.

Common Patterns

Choosing local vs cloud

Use local Playwright for zero-credential dev boxes and personal automation; use the cloud fallback for serverless or no-Playwright environments.

Diagram

Yes

No

Playwright
installed?

🎭 Local Chromium
no API key

☁️ BrowserBaseTool
needs credentials

Combining with --web

bash
praisonai bot slack --browser --browser-headless --web --memory

--web adds a search tool, --browser adds a real browser, and --memory lets the agent remember what it saw between messages.


Best Practices

Use –browser-headless on servers

Headed mode requires a display; on a headless server or Docker container the launch will fail. On a display-less host, wrap the command with xvfb-run to provide a virtual display.

Confirm which tool loaded from the startup log

Three exact log lines tell you which mode you landed in:

  • Local browser automation enabled (headless=…, profile=…) — local Playwright is running.
  • Browser tool enabled via BrowserBaseTool (cloud fallback). Install praisonai-browser for local automation. — cloud fallback path.
  • Browser tool not available. Install praisonai-browser (local) or praisonai-tools (cloud). — --browser was a no-op; the agent has no browser tool.
Named profiles aren't yet honoured

--browser-profile is accepted for forward-compatibility, but the current release always uses a fresh Chromium context. For a persistent profile, watch praisonai-browser upstream and use the CDP mode from Browser Agent → Deep Dive in the meantime.

Failures reach the agent, not the process

browser_automate returns {"success": False, "error": "…"} on Playwright errors instead of raising — the agent can retry, apologise, or fall back to search_web. This differs from BrowserBaseTool, which fails at construction if the API key is absent.


Related