Skip to main content
The Code Agent builds and edits your bot from plain-language instructions. How well it does that depends a lot on how you ask. This page collects the habits that get good results, and explains a couple of things about how the agent behaves that are worth understanding before you start.

Why a fresh project feels different

The Code Agent is the one agent in Paige that changes what it can do depending on the project it’s working in. In a brand-new project it behaves quite differently from one that already has a working bot — and that’s deliberate. A project counts as new until it has a deployed webhook — in practice, until the agent has scaffolded your first bot. While it’s new, the agent works in scaffolding mode:
  • It starts from a starter template rather than reading existing code, because there isn’t any yet.
  • It picks the template that matches the kind of bot you asked for — a simple menu bot or an AI bot (see How a new bot starts).
  • It pulls in a reference for how Paige’s messaging and database APIs work, then writes the files.
Once your bot exists, the same agent switches to editing mode:
  • It reads the relevant files first, then makes small, surgical edits rather than rewriting whole files.
  • It can search across your project to find where something lives.
  • It can read your execution logs to debug a problem you describe.
You don’t switch these modes yourself — the agent does it based on whether the project already has a bot. The practical upshot: in a fresh project, describe the bot you want from scratch; in an existing one, describe the change you want against what’s already there.
The agent also adapts to whether Paige Dev testing is linked. When it is, “test it” runs a fuller automated test pass; when it isn’t, the agent sends a single preview message instead. Either way you ask the same way — see Ask it to test below.

What the agent can reach for

The Code Agent has close to forty built-in tools it uses behind the scenes. You never call these directly — you describe an outcome and the agent chooses the tools. It helps to know roughly what’s in its reach, because it shapes what you can ask for in a single instruction.

Files

Read, write, edit, and search your bot’s code. In an existing project it prefers targeted edits over full rewrites.

Database

Create and change tables, and query, insert, update, or delete rows — so it can set up storage before writing the code that uses it.

Flows

Build, update, validate, publish, and upload WhatsApp Flows, and embed images into flow screens.

Scheduled tasks

Register, list, and remove scheduled tasks that run on a repeating schedule.

Reference lookups

Look up how the Paige API, Airtable, Slack and Yoco actually work — including your own Airtable tables and fields — before writing code against them.

Testing & logs

Send test messages through your bot, reset the preview, and read execution logs to debug.
Not every tool is available in every project — the file-reading and log-reading tools only appear once your bot exists, and the testing tools swap depending on whether Paige Dev is linked. You don’t have to track any of this; ask for the outcome and the agent uses whatever it has.

When it edits code versus builds a Flow

This is the distinction most worth understanding, because it changes how you phrase a request. For most changes — a new message, a menu option, a branch of logic, a database write — the agent edits your bot code directly. For collecting several fields of structured information in one go, it builds a WhatsApp Flow instead. A Flow is the native WhatsApp form UI: a screen with real inputs rather than a back-and-forth of questions. When the agent decides a Flow is the right tool, it hands the job to Paige’s dedicated flow builder, which generates the Flow, validates it against Meta’s rules, and drafts it — the agent then wires it into your bot.
The agent can’t hand-edit a Flow’s definition the way it edits ordinary code — Flows always go through the flow builder so they stay valid against Meta’s requirements. This is invisible to you; it just means “change the booking form” and “change the welcome message” take slightly different routes under the hood.
So which should you ask for?
  • Ask for a message or a menu when the interaction is a single question, a choice between a few options, or a short reply. These are quick, edited straight into your code, and easy to iterate on.
  • Ask for a Flow when you’re collecting several details at once — a booking (name, date, time, party size), a lead form, a survey. A Flow is a better experience than asking for each field in a separate message, and Meta requires it for anything beyond a few fields.
You don’t have to use the word “Flow.” Describe the outcome — “collect the customer’s name, email, and preferred date in one form” — and the agent will reach for a Flow on its own. Naming it just makes your intent explicit.

Prompting habits that work

Describe the outcome, not the implementation. Say what should happen from the customer’s point of view — “after they pick ‘Book a demo’, ask for their name and email, then save both and confirm” — and let the agent decide which files and tools to touch. You don’t need to know your bot’s file structure. Be specific about behavior. “Add a contact form” leaves too much open. “Ask for name and email in one form, save them to a leads table, and reply with a thank-you message” tells the agent exactly what done looks like. There’s a lot packed into that habit — the next section unpacks it. Iterate in small steps. A large feature lands more reliably as a sequence of small requests — build the menu first, then each option’s handler, then the edge cases — than as one long instruction. You also get to check each piece as it’s built. Reference behavior, not files. Describe the moment in the conversation you want to change — “when someone replies to the welcome message” — rather than naming a file. The agent finds the right code.
1

Start with the shape

Get the main path working first: the greeting, the menu, the one or two things most customers will do.
2

Fill in the branches

Add the handlers for each option, one at a time, testing as you go.
3

Handle the edges

Then cover the awkward inputs — empty messages, unexpected replies, someone changing their mind mid-flow.

What “be specific about behavior” means

“Be specific” is easy to agree with and hard to act on. In practice, a specific request answers four questions. Answer all four and the agent has nothing left to guess. The third question is the one most people skip, usually because they don’t realise it’s on the menu. Every Paige project comes with a database, and the agent can create a table and write to it in the same request that builds the message. If you never say “save it”, you get a bot that asks a good question and then forgets the answer.

The same request, two ways

Underspecified

“Let people book a table.”

Specific

“When someone taps Book a table, ask for their name, the date, the time, and how many people in one form. Save each booking to a bookings table. Reply ‘Thanks Sam, you’re booked for Friday at 7pm for four.’ Don’t change the welcome menu. It’s done when a test booking shows up as a row in bookings.”
Both requests get you a booking feature. The difference is how many rounds it takes to get the one you wanted. The underspecified version leaves the agent to invent the fields, decide whether to store anything at all, and write its own confirmation wording. The specific version answers all four questions: the trigger is the button tap, the customer sees a form and a named confirmation, the data lands in bookings, and “done” is a row you can go and look at.
The “it’s done when…” sentence is the highest-value habit on this page. It gives the agent something to aim at — and it’s exactly what it checks against when you add “then test it”.

Three worked examples

The same four questions, applied to the three kinds of request you’ll make most often.
The goal: a Join our mailing list option that captures the customer’s details so you can broadcast to them later.A weak ask
“Add a mailing list option.”
You’ll get a menu item and a reply. Whether anything is recorded, and what it records, is the agent’s guess — and quite possibly it records nothing at all.A strong ask
“Add a Join our mailing list option to the main menu. When someone taps it, ask for their name and email in one form. Save both to a subscribers table along with the date they joined, and tag the contact as newsletter. Reply ‘You’re on the list — thanks!’ It’s done when a test signup appears in subscribers and the contact carries the newsletter tag.”
Why it’s better: it names the table and the tag, which is what turns a signup into an audience you can broadcast to. The weak version gets you a polite bot that collects nothing you can use.
The goal: the opening message is too formal and too long.A weak ask
“Make the greeting friendlier.”
“Friendlier” is a judgement call, and you’ve just handed it to the agent. You also haven’t said which message you mean — a bot usually has several that could be called a greeting.A strong ask
“Change the first message a new contact gets — the one that currently reads ‘Good day. You have reached Sunrise Dental. Please select an option below.’ — to two short, warm sentences that still offer the same three menu options. Keep the button labels exactly as they are. Don’t touch anything that happens after they tap.”
Why it’s better: it quotes the message, so there’s no ambiguity about which one to change. It also says what to preserve — the button labels and everything downstream — which is what stops a small copy edit from quietly rewriting your menu logic.
The goal: you want yesterday’s bookings sent to you every morning.A weak ask
“Send me a daily summary.”
Send it where? At what time? Containing what? That’s three guesses, plus a good chance the agent builds something triggered by a customer message rather than by the clock.A strong ask
“Every weekday at 07:00 South African time, send a WhatsApp message to +27 82 555 0100 listing yesterday’s rows from the bookings table — name, time, and party size — with a count at the top. If there were no bookings, send ‘No bookings yesterday.’ rather than an empty message.”
Why it’s better: it describes a scheduled task, which is a capability you’d never think to ask for if you didn’t know it existed. It also names the empty case, which is the one that usually breaks.

Things you can ask for that you may not know exist

The hardest part of prompting Paige isn’t phrasing — it’s knowing what’s there to ask for. You can’t request a table if you don’t know your project has a database. Everything in this list is something the Code Agent can build from a single plain-language instruction.
Not sure whether something is possible at all? Ask the Help Agent. A question costs very little, and “can Paige do X?” is exactly what it’s for.

When the agent can’t find what you mean

“Reference behavior, not files” works most of the time. Sometimes it doesn’t: you describe a moment and the agent edits the wrong message, or tells you it can’t find what you’re describing. That’s a normal thing to hit, not a dead end. Escalate in this order, and stop as soon as one step works.
1

Quote the exact words

The most reliable handle on a message is the message itself. Paste the text your bot really sends — “change the message that reads ‘Welcome! What can I help you with today?’” — and the agent can search your code for that exact string.
2

Describe the step before it

If the wording changes from customer to customer, or you can’t remember it, place the moment in the conversation instead: “the message that comes after someone taps Support”. The agent can follow the conversation states to get there.
3

Reproduce it, then point at the logs

Trigger the problem yourself in the preview or on Paige Dev, then say “I just sent ‘hi’ and got the wrong reply — read the logs and fix it.” The agent reads the same execution logs you can, so it works from what actually happened rather than from your description of it.
4

Name the file or the table

Only now is naming things worth doing. If you know the table is bookings, or you’ve seen the handler in the Bot tab, say so. You lose nothing by being explicit once the vaguer version has already failed.
5

Undo, then re-ask in one clean instruction

If several rounds have left your bot worse than it started, stop patching. Restore the last good version from version history, then ask again — once — with everything you learned folded into a single specific request.
Resist the urge to stack corrections onto a thread that has already gone sideways. Every failed attempt stays in the conversation and competes for the agent’s attention. A restore plus one fresh, complete request is usually faster than a sixth correction — see When to start fresh.

Ask it to test after a change

The agent can test its own work. Add “then test it” to an instruction and it runs a message through your bot and shows you what came back — no need to pick up your phone. This is the fastest way to catch a mistake before it reaches a customer. What “test it” does depends on whether Paige Dev is linked. You ask the same way either way.

Paige Dev not linked

The agent sends a single message through your bot in the preview and reports the reply.

Paige Dev linked

“Test it” runs a fuller automated pass — the agent drives a scenario through your bot and can iterate on the code from what it finds. See Programmatic testing.
Either way, the messages run against your preview copy. Your live bot and your real customers are never involved.

Give the test something to check

“Test it” on its own gets you a message and a reply. Naming the scenario gets you an actual test:

Vague

“Add the booking option, then test it.”

Worth running

“Add the booking option, then test it: send ‘hi’, tap Book a table, fill the form in as Sam for Friday at 7pm for four people, and check that a row appears in bookings.”
The second version fails loudly when the row doesn’t appear. The first can pass while the thing you actually cared about is broken.
Ask for the same scenario again after your next change and you have a regression check: “re-run the booking test.”

Does asking it to test cost credits?

Yes — but not as a charge of its own. There is no per-test, per-message, or per-test-run price anywhere in Paige. Credits are metered on the AI work a billable agent does in answering your request, and a test the agent runs is part of the same Code Agent turn that made the change. So “add the booking option, then test it” uses more of your balance than “add the booking option” on its own — not because testing has a price, but because you asked the agent to do more in one turn. There’s no fixed figure to budget for: bigger requests cost more. Each request and what it cost is listed in Settings → Usage. Two things testing does not cost you:

Testing it yourself is free

Sending a message in the preview, or messaging your bot from your phone on Paige Dev, doesn’t deduct credits — no builder agent is involved. The Try now test template has a rate limit rather than a price: five per number per rolling 24 hours.

A preview run has no WhatsApp fee

A preview test never reaches WhatsApp. Paige captures what your bot tries to send instead of delivering it, so Meta has nothing to charge you for.
Credits only ever pay for Paige’s builder agents. Your bot talking to customers, deploys, and WhatsApp’s own message fees aren’t credit costs — see Billing. If your bot uses AI to write its replies, that runs on your own OpenAI key and is billed by OpenAI, not by Paige: see AI in your bot.
A quick question to the Help Agent, such as “how should I test this?”, costs very little next to a build.

Let it read the logs when something breaks

When a change misbehaves, you don’t have to diagnose it yourself. Describe the symptom and point the agent at the logs:
“Customers say the booking confirmation never arrives. Check the logs and fix it.”
In an existing project the agent can read the same execution logs you see in Tools → Logs, across both your preview and production bots, and change the code in the same conversation. That’s the shortest path from “something’s broken” to a fix.
If the agent makes a change that breaks something, just tell it what went wrong in plain terms. It’ll read the logs, inspect the code, and fix the cause — you don’t need to work out the underlying reason yourself.

A quick reference

For the full reference on what the Code Agent is and how it fits together, see the Code Agent page.