Skip to main content
The Code Agent is the primary way you build and modify your bot in Paige. You describe what you want your bot to do in plain language, and the agent writes or edits the underlying bot code for you. It has direct access to your project files, database, and WhatsApp tools, so it can make end-to-end changes — from creating a new conversation state to uploading a Flow to Meta — without you touching a code editor.

How it works

When you open the AI chat for a project, the agent has context about your current bot code and can read, write, and edit files in your project. You describe a change, the agent makes it, and can immediately test it by sending a message through the bot’s preview mode. You stay in the loop through a task list the agent maintains while working through multi-step changes.
1

Open the AI chat

Navigate to your project and open the AI chat panel. For a new project, the agent starts without any existing code.
2

Describe what you want

Type your instruction in plain language. For example: “Add a main menu with three options: Book a demo, Get support, and Learn more.”
3

Review and test

The agent writes the code, then tests it using the built-in preview. You can see the bot’s responses directly in the chat before the change goes live.
4

Iterate

Continue the conversation to refine behavior, fix edge cases, or add new features. Each message builds on the previous context.

What the Code Agent can do

The agent has access to a set of built-in tools it uses behind the scenes to complete your requests.

File tools

Read, write, edit, and delete files in your project. The agent can also search across all files to find functions or patterns.

Database tools

Create tables, add columns, drop tables, query data, and insert rows — all before writing bot code that references those tables.

Bot testing tools

Send test messages through the bot in preview mode, simulate button and list taps, and fetch recent execution logs to debug errors.

Flow tools

Generate and update WhatsApp Flows, upload them to Meta, publish drafts, and embed images into flow screens.

Template tools

List existing message templates and create new ones for outbound notifications, directly from within the conversation.

Scheduled task tools

Register scheduled tasks that run on a repeating schedule — useful for daily reports or recurring notifications.

Connector tools

Look up how Airtable and Slack really work before writing code against them — including your own tables and fields.

Media tools

Send images and documents from your Storage, embed images into flow screens, and save media customers send in.

It knows what you’ve actually connected

Two details worth knowing, because they change what the agent tells you. It looks things up rather than guessing. Before writing any Airtable or Slack code, the agent fetches the real reference — for Airtable, that includes a snapshot of your actual base, so it uses your real table and field names rather than plausible-sounding invented ones. It knows whether you’re connected. Paige tells it, rather than letting it assume. So if you ask for Airtable code without an Airtable connection, it writes the code and then tells you plainly that you need to connect Airtable before the bot will work — instead of cheerfully reporting success on something that can’t run.
The same applies to media capture. The agent can check whether saving customer media is switched on, but it can’t switch it on for you — it’ll tell you to go and do it in Tools → Storage.

The knowledge base

Your bot can answer from your own documents — your menu, your policies, your FAQs, your price list. Add one by attaching it in chat with the paperclip, or uploading it in Tools → Storage. Paige reads PDFs, Word documents, and text files, and your bot can then answer questions from them.
Upload a photo and Paige writes a description of it into the knowledge base, reading any text in the image. So a photo of a printed menu becomes something your bot can answer questions about — no typing required.
Keep these focused. Everything you add is read on every question your bot answers, so a tight FAQ works better than a long brochure — for cost as well as accuracy.

How a new bot starts

When you ask the Code Agent to build a new bot, it begins from one of two starter templates depending on the kind of bot you want.
  • An AI-driven bot — uses an AI router to classify each message and respond conversationally, with structured states for collecting information and handling support.
  • A simple menu bot — a pure state machine with no AI inside the bot itself; responses are predictable and deterministic. Best for menu-driven flows.
Both templates ship with the same core capabilities (messaging, database, logging) so you can switch direction at any time by chatting with the agent.

State machine pattern

Your bot manages each conversation as a state machine. Every conversation has a current state, and each incoming message is handled by the code for that state. There are two kinds of states:
  • SEND states — send a message or UI element, then immediately transition to an AWAIT state
  • AWAIT states — receive the user’s response and process it
A state should never both send a message and handle the user’s reply. SEND and AWAIT are always separate states.
To add a new conversation state, tell the agent what you want. For example:
“Add a booking flow. After the user selects ‘Book a demo’, ask for their name, then their preferred date, then confirm the booking and save it to a bookings table.”
The agent will:
  1. Create the bookings table in your database
  2. Add the conversation states needed to walk the user through name → date → confirmation
  3. Wire up the transitions between states
  4. Test the full flow in preview mode

Prompting the agent well

How you phrase a request has a real effect on the result — and the agent behaves differently in a brand-new project than in one that already has a bot. Both are covered on a dedicated page.

Prompting tips

Describe outcomes not implementation, iterate in small steps, know when the agent edits code versus builds a Flow, and understand why a fresh project feels different. See Prompting the Code Agent well.