Editorial

Give Your AI Agent a Browser and a Voice: Playwright MCP + LiveKit

Give an AI agent a real browser via Playwright MCP and a live voice via LiveKit and Gemini Live, with the Ubuntu 20.04 and latency fixes tutorials skip.

JJyoti Ranjan SwainUpdated
Two upgrades for an AI agent: a Playwright MCP server driving a real Chromium browser, and a LiveKit voice pipeline with a Gemini Live model that calls the agent tools and speaks the answer back

A coding agent that only reads and writes files is useful. One that can drive a real browser and hold a live voice conversation can check your live site the way a user does, and you can talk to it hands-free while it runs real commands. This post is a build log of setting that up on a plain Ubuntu box. First the Playwright MCP server, which gives the agent a real Chromium. Then a live voice agent on LiveKit, powered by a Gemini Live model, where the voice you talk to runs your agent's tools and speaks the result back.

Two things bit us that most tutorials skip: a browser version mismatch on older Linux, and a platform limit (chat bots cannot place phone calls). Both have fixes, and knowing them up front saves an afternoon.

Table of Contents

Get the agent running and on Telegram

This build assumes you already have an agent installed and talking to you. If you don't, here is the short path.

Install the agent first. The example throughout uses Hermes Agent, an open-source agent by Nous Research that runs the same core in a terminal, a desktop app, and a messaging gateway. On Linux, macOS, or WSL2 it is one command:

bash
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash

That provisions Python, Node.js, and the hermes launcher, then hermes starts a setup wizard where you pick a model provider. For local models with Ollama or LM Studio, VRAM planning, and the Windows and Mac steps, see the separate Hermes Agent Setup Guide. The rest of this post applies to any MCP-capable agent.

Next, make a Telegram bot. Open Telegram, message @BotFather, send /newbot, and follow the prompts. It hands you a bot token that looks like 123456789:AA.... Treat that token like a password and store it in your agent's env file, never in code:

bash
# ~/.hermes/.env
TELEGRAM_BOT_TOKEN=123456789:AA-your-token-here

Then find your chat ID. For the bot to message you it needs the numeric chat ID of your conversation, and Telegram never shows that in the app. Direct chats, groups, and channels each have their own ID, and groups carry a leading minus (channels a -100 prefix). The quickest way to get it is our Telegram Chat ID Finder: paste the bot token, send your bot a message, and it reads the numeric chat.id straight back. It also clears the common 409 webhook is active conflict in one click. Add the number to your env:

bash
# ~/.hermes/.env
TELEGRAM_ALLOWED_USERS=123456789      # your chat ID, so only you can talk to it

Finally, start the gateway with the token and chat ID in place and message your bot. It should reply with full tool access, not just chat. From here, "send me a link in Telegram" is something your agent can really do, and that is how the voice-call join link reaches you later in this post.

What MCP and LiveKit provide

They are separate things, and people often mix them up.

MCP (Model Context Protocol) is a standard way to hand an AI agent new tools. A Playwright MCP server exposes browser actions (navigate, click, type, snapshot the page) as tools the model can call. Once connected, your agent can open your live website, read the rendered accessibility tree, and click through it. That suits QA, scraping your own pages, or verifying a deploy.

LiveKit is real-time audio and video infrastructure built on WebRTC. Paired with a Live speech model, it gives you a low-latency, interruptible voice conversation with an agent in a room you join from a browser or phone.

The useful part is joining the two. The voice you talk to is not a separate chatbot but a front end to your real agent, the one with terminal, file, and web tools and your memory.

Playwright MCP for browser control

Most agent runtimes read MCP servers from a config file, and the server itself is an npm package you run with npx. A minimal entry looks like this (the config location depends on your agent):

yaml
mcp_servers:
  playwright:
    command: npx
    args:
      - -y
      - "@playwright/mcp@latest"

Prerequisites are just Node.js and npx:

bash
node --version    # v18+ is plenty
npx --version

Then install the browser the server will drive. Playwright ships its own Chromium build rather than using your system Chrome:

bash
npx -y playwright@latest install chromium

Restart your agent so it discovers the new server. Most runtimes register tools at startup and have no hot reload, so the restart is mandatory. After that the agent has tools like browser_navigate, browser_click, browser_snapshot, and browser_type. Ask it to open a page and describe what it sees, and it drives the real browser to do it.

To check the whole chain (agent, MCP, Chromium, live site), point it at a page and have it read back the structure. A clean run returns the page title and an accessibility snapshot with zero console errors.

Chromium version pinning on Ubuntu 20.04

On older Linux (Ubuntu 20.04), two failures show up in order.

  1. "Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome." The MCP server defaults to looking for system Google Chrome, which isn't installed. Tell it to use Playwright's bundled Chromium with a --browser chromium flag in the server args.
  2. "Browser is not installed; expected executable at .../chromium-XXXX/..." The MCP server pins a specific Chromium build number, and the newest builds have dropped Ubuntu 20.04 support, so the auto-installer refuses to fetch them.

Rather than fight the version pin, point the server directly at a Chromium build that does run on your OS, using an explicit executable path:

yaml
mcp_servers:
  playwright:
    command: npx
    args:
      - -y
      - "@playwright/mcp@latest"
      - --browser
      - chromium
      - --executable-path
      - /home/youruser/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome

Before trusting it, check that the binary launches headless on your box. This catches missing system libraries in one shot:

bash
BIN=~/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome
"$BIN" --headless=new --no-sandbox --dump-dom "data:text/html,<h1>ok</h1>"

If that prints the DOM, restart the agent and the browser tools come alive. On older distros, pin to a browser build you have verified locally instead of whatever the tool wants to download.

LiveKit for voice

Live voice needs three pieces: a LiveKit project (URL, API key, secret), a Live speech model that supports bidirectional streaming, and a small agent worker process that joins the room and bridges audio to the model.

The worker is short. In Python, using the LiveKit Agents SDK with a Google Live model, it looks like this:

python
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, cli
from livekit.plugins.google.realtime import RealtimeModel

async def entrypoint(ctx: JobContext):
    await ctx.connect()
    session = AgentSession(
        llm=RealtimeModel(
            model="your-gemini-live-model",
            api_key="YOUR_GOOGLE_API_KEY",   # load from env, never hardcode
            voice="Puck",
            instructions="You are a warm, quick voice assistant.",
        ),
    )
    await session.start(agent=Agent(instructions="..."), room=ctx.room)

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

Install the SDK in its own virtual environment and run the worker:

bash
python -m venv .venv && . .venv/bin/activate
pip install "livekit-agents[google]" livekit-api python-dotenv
python agent.py dev

When it prints registered worker, it is connected to your LiveKit project and waiting. You join the room from a hosted LiveKit web client using an access token your code signs with your API key and secret. Talk, and the model talks back, live and interruptible.

Bots cannot make phone calls

If your goal was "call my chat bot and talk to it," stop here: chat platform bot APIs cannot place or receive phone calls. On Telegram, calling belongs to the user (client) API and is restricted to real user accounts, so a bot account cannot ring you or pick up. No code changes that. It is a platform boundary, not a missing feature.

The call therefore happens in a LiveKit room, not through the chat app's call button. Your agent generates a room join link and sends it to you in chat, you tap it, and the call opens in the browser. You still start from chat, and the audio runs over WebRTC.

Routing voice requests to your agent's tools

A plain voice bot only converses. To make it a front end to your real agent, so that speaking a task runs terminal, file, and web tools and speaks back the result, you give the voice agent a function tool.

Give the Live model one tool, say ask_agent, and instruct it to call the tool with the caller's request whenever they want something done. The tool forwards the text to your real agent (its CLI or an API), gets the answer, and returns it to be spoken:

python
from livekit.agents import function_tool, RunContext

class VoiceAgent(Agent):
    @function_tool()
    async def ask_agent(self, ctx: RunContext, request: str) -> str:
        """Run a real task through the full agent (terminal, files, web, memory)."""
        answer = await run_my_real_agent(request)   # your CLI / API call
        await ctx.session.say(answer)               # speak the result
        return answer

We hit two model-specific traps, and your model may have them too:

  • Some Live models report supports_say = False, meaning the session cannot synthesize arbitrary text through the realtime model. Attach a separate TTS to the session so say() has a voice to use.
  • Some Live models don't support a server-side "greet on connect" call. Let the model greet on the first user audio instead of forcing an opening line.

Once wired, you speak, the model calls ask_agent, your real agent runs the tools, and the answer is spoken back. Without the bridge you have a talking toy. Anyone who can join your voice room can run your agent's tools, so guard the join link.

Cutting latency by keeping the agent warm

The first working version took about 35 seconds per spoken task. The tools were not the problem. Spawning a fresh agent process for each request paid about 9 seconds of startup every time, and a heavyweight model added the rest. Nobody waits 35 seconds on a live call. They repeat themselves, which cancels the in-flight reply, and the call falls apart.

Two changes fixed it:

  1. Keep one agent process warm. Instead of launching the agent per request, run a small daemon that boots the agent once and answers over a local socket. The per-turn boot cost disappears.
  2. Use a fast model for the voice path. A lightweight "haiku" or "flash" class model answers tool questions in a few seconds instead of tens. Keep the heavy model for deep work and route only voice calls to the fast one.

After both, warm turns dropped to roughly 6-7 seconds, which is model and tool time with no boot tax. That is not instant, because real work is happening, but it holds up in conversation.

Running it as a systemd user service

A worker you started in a terminal dies when the terminal does. To make the voice agent survive logout and reboot and restart after a crash, wrap it in a systemd user service. It needs no root:

ini
# ~/.config/systemd/user/voice-agent.service
[Unit]
Description=LiveKit voice agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/home/youruser/voice-agent
ExecStart=/home/youruser/voice-agent/.venv/bin/python agent.py start
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

Enable lingering (so it runs without an active login), then enable and start it:

bash
loginctl enable-linger "$USER"
systemctl --user daemon-reload
systemctl --user enable --now voice-agent.service
systemctl --user status voice-agent.service

Two commands do the reboot-survival work. loginctl enable-linger "$USER" lets your user's services run, and start, when you are not logged in. Without it, user services stop when your session ends and stay down until you log in again, which is why so many agents silently die after a reboot. systemctl --user enable marks the service to start on boot. With Restart=always in the unit, the machine reboots, the agent starts on its own, and if it crashes, systemd brings it back within seconds.

Confirm both with loginctl show-user "$USER" | grep Linger (expect Linger=yes) and systemctl --user is-enabled voice-agent.service (expect enabled). Watch the logs with journalctl --user -u voice-agent.service -f. The warm agent daemon works the same way as a second user service, so both come back after a reboot.

Handling secrets

This build touches several credentials: a model API key, plus the LiveKit API key and secret.

  • Never hardcode them in source or paste them into a chat, an issue, or a commit. Load them from environment variables or a local, git-ignored env file.
  • Confirm your .gitignore covers .env*, and check again before every push.
  • For any token you control, such as a webhook secret, a room password, or a service token, generate it with the API Key & .env Secret Generator rather than typing something guessable.
  • If a key ever lands somewhere it shouldn't, whether a log, a screenshot, or a message, revoke and reissue it. Assume exposure is permanent.

None of the config snippets above contain a real key. Every value is a placeholder like YOUR_GOOGLE_API_KEY, and it should stay that way in your own repo.

FAQ

Do I need system Chrome for Playwright MCP?

No. Playwright ships its own Chromium via playwright install chromium. On mainstream OSes it just works. On older Linux you may need --browser chromium and an explicit --executable-path to a build that runs on your system, as shown above.

Why can't I call my Telegram or Discord bot and talk to it?

Bot APIs don't expose calling. It belongs to the real-user client API and is off-limits to bot accounts. Use a LiveKit room instead: your agent sends you a join link in chat, and the call runs over WebRTC in the browser.

Why was my voice agent so slow?

Almost always per-request startup cost. Keep one agent process warm, answer over a socket instead of spawning a new process each turn, and route voice to a fast model. That took our turns from ~35s to ~6-7s.

Is it safe to run this as a background service?

Yes, with care. Use a systemd user service (no root), keep secrets in an environment file the service reads, and never expose the agent's tools to untrusted callers. Anyone who can join your voice room can run your agent's tools.

Sources

  • Model Context Protocol: specification and server catalog
  • Playwright: official browser automation and playwright install documentation
  • LiveKit: Agents framework and Google/Gemini Live plugin documentation
  • Google AI for Developers: Live API (bidirectional streaming) overview
  • systemd: user services and loginctl enable-linger documentation

Tools In This Article

Browser-based, no sign-up. Try them while the topic is fresh.

More From ToolMintX

Other Blog Posts