Skip to main content

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.

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.

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.
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

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 a leads 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.
If the agent makes a change that breaks something, just tell it what went wrong. It will read the logs, inspect the code, and fix the issue — you don’t need to describe the underlying cause.