How to give your iMessage agent a browser
Give an iMessage or WhatsApp agent a cloud browser with TinyFish, from fetch to logins.

A customer texts your agent "move my appointment to Thursday" or "did my refund go through?" The answer is on a website with no API behind it: a booking portal, a carrier dashboard, an account page. To get it done, the agent needs a browser for AI agents: a real Chromium session it can drive, running somewhere other than your server.
This guide covers what changes when that agent lives in iMessage or WhatsApp instead of a chat window, and how to wire one up with TinyBrowser from TinyFish, in about 30 lines of TypeScript. If you're still building the agent itself, start with how to build and test an iMessage agent in TypeScript.
Do you need a full browser?
Not always. A browser is the slowest and most expensive way to read the web, so use the lightest tool that works.
| The agent needs to | Use |
|---|---|
| Find pages about a topic or a person | Search (TinySearch) |
| Read pages it already has URLs for | Fetch (TinyFetch) |
| Sign in, click through a portal, fill in a form | Browser (TinyBrowser) |
Keiki's own contact research sits on the first two rows. When someone texts a business for the first time, Keiki runs one TinySearch query and fetches up to five pages with TinyFetch, which handles page rendering when needed and returns clean Markdown. The agent never opens a session for that.
A browser earns its cost the moment the task needs state: a login, a cart, a multi-step form, a page that only appears after a click.
What's different when the agent lives in a text thread
A browser agent in a web app has a screen next to it. In iMessage and WhatsApp, the person sees nothing but messages. That changes five things.
1. Nobody is watching the screen
The person can't see the page, so the agent has to bring the page to them. Return a short text answer and, when it helps, a screenshot sent into the thread. "Your refund of $48.20 posted on Nov 30" plus a picture of the account page is more convincing than a paragraph.
2. Browser sessions can take time, so reply first
TinyFish's docs say creating a TinyBrowser session typically takes 10 to 30 seconds, and navigating websites and completing multi-step tasks take longer. In a text thread, a long silence makes the agent feel unresponsive. Send "Checking your account now" before the browser starts, then send the result.
3. Logins belong to the person
Never ask for a password over text. When the agent reaches a login, CAPTCHA or payment step, it should hand the live session to the person: text them a link, let them sign in themselves, then take the session back. On Keiki this is the browser_handoff tool. The agent texts the link, the person finishes in the browser, and the agent resumes automatically.
4. Pick up where you left off
After a handoff, the agent continues in the same session, with the same cookies and the same page. Starting a fresh browser would lose the login the person just did.
5. One session belongs to one person
A session ID the model passes in is a lookup into your own records, never a key you trust directly. Check that the session belongs to the conversation that asked for it before reusing it, or one customer's signed-in session can end up serving another.
Step by step: give your agent a browser with TinyBrowser
TinyBrowser creates a managed Chromium session in the cloud and returns a CDP WebSocket URL. You drive it with Playwright, Puppeteer or raw CDP, and TinyFish handles anti-bot checks and proxy routing at the infrastructure layer.
Step 1: Get an API key and install the packages
Create a key at agent.tinyfish.ai/api-keys, then:
export TINYFISH_API_KEY="your_api_key_here"
npm install @tiny-fish/sdk@latest playwrightStep 2: Write a browse tool
This function is the tool your agent calls. It opens a session at a URL, reads the page, takes a screenshot and always closes the session.
import { TinyFish } from '@tiny-fish/sdk'
import { type Browser, chromium } from 'playwright'
const tinyfish = new TinyFish()
export async function browse({ url }: { url: string }) {
const session = await tinyfish.browser.sessions.create({ url })
let browser: Browser | undefined
try {
browser = await chromium.connectOverCDP(session.cdp_url)
const context = browser.contexts()[0] ?? (await browser.newContext())
let page = context.pages()[0]
if (!page) {
page = await context.newPage()
await page.goto(url)
}
await page.waitForLoadState('domcontentloaded')
return {
title: await page.title(),
text: (await page.innerText('body')).slice(0, 6_000),
screenshot: (await page.screenshot({ type: 'png' })).toString('base64'),
}
} finally {
await browser?.close()
await fetch(`https://api.browser.tinyfish.ai/${session.session_id}`, {
method: 'DELETE',
headers: { 'X-API-Key': process.env.TINYFISH_API_KEY! },
})
}
}Cap the text you hand back. A model reads 6,000 characters of a page faster and more accurately than the whole thing, and that's the limit Keiki uses for fetched pages too. The screenshot comes back base64-encoded: send it into the thread as an image rather than passing it to the model.
Step 3: Route traffic from the right country
Sessions go through a TinyFish residential proxy in the US by default, with one exit IP for the whole session. If your customers are elsewhere, pick their country so prices, availability and language match what they'd see:
curl -X POST https://api.browser.tinyfish.ai \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "proxy_config": {"country_code": "DE"}}'Delete that session the same way as in Step 2 when the task is done.
Step 4: Clean up sessions
A session ends after a period with no CDP commands: 15 minutes on free plans, 60 minutes on paid ones, or sooner if you set timeout_seconds. Don't rely on that. Delete the session as soon as the task is done, as the finally block above does.
Step 5: Keep logins across conversations
Direct TinyBrowser sessions are isolated and don't keep cookies. If a customer signs in once, you can use TinyFish's TinyProfiles to preserve and reuse authenticated browser state across supported runs while the saved session remains valid.
On Keiki
If you build your agent on Keiki, the browser is a feature you turn on, not code you write:
browser: { enabled: true, handoff: true, screenshotDelivery: true },The agent gets a browse tool for web tasks and a browser_handoff tool for steps only the person can do. Screenshots land in the thread, handoff links are signed, and the agent resumes on its own when the person finishes. If you bring your own agent, the browse function above is a tool you register like any other.
FAQ
What is a browser for AI agents? A browser for AI agents is a real browser session that an agent controls through code instead of a person clicking. It runs in the cloud, loads JavaScript-heavy pages, keeps state across steps and handles anti-bot checks, so the agent can sign in, click and fill in forms on sites that have no API.
Is fetching a page enough, or do I need a browser? If the agent only needs to read public pages, fetch is enough and much cheaper. You need a browser when the task has state: a login, a cart, a form or content that only appears after a click.
Can the agent log in for the customer? It shouldn't ask for the password. Hand the live session to the customer with a link, let them sign in, then let the agent continue in the same session.
How long does a TinyBrowser session last?
Until you delete it, or until it has been idle for 15 minutes on free plans or 60 minutes on paid ones. You can set a shorter timeout_seconds.
Try it
Create a TinyBrowser session to give your agent a browser, and put it in iMessage and WhatsApp with Keiki. For more on keeping a person in the loop, read Human in the loop for iMessage agents.