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.Documentation Index
Fetch the complete documentation index at: https://howto.paigeme.dev/llms.txt
Use this file to discover all available pages before exploring further.
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.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.
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.”
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.
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.
Cron job tools
Register scheduled tasks that run on a cron schedule — useful for daily reports or recurring notifications.
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.
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.
“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:
- Create the
bookingstable in your database - Add the conversation states needed to walk the user through name → date → confirmation
- Wire up the transitions between states
- Test the full flow in preview mode
Tips for effective prompting
Be specific about the behavior you want. Instead of “add a contact form”, say “ask the user for their name and email address in two separate messages, then save both to aleads table and confirm with a text message.”
Reference behavior, not files. Describe what should happen — “after the user picks an option from the main menu, ask them for their email” — and let the agent figure out which code to change.
Ask the agent to test after every significant change. The agent can send test messages and simulate button clicks automatically. Add “then test it” to the end of your instruction.
Ask for logs when something is broken. “Check the recent error logs and fix whatever is failing” gives the agent everything it needs to diagnose and fix issues without further input from you.
One thing at a time for complex changes. Breaking a large feature into smaller steps (menu first, then each handler) produces more reliable results than asking for everything at once.
