Every Paige project has a bot codebase — a Node.js/Express application that runs on Paige’s managed infrastructure. The code receives incoming WhatsApp messages through a webhook, decides how to respond based on the current conversation state, and sends replies back via the WhatsApp Cloud API. You never manage servers or deployments; Paige handles all of that automatically.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 state machine pattern
Your bot tracks each contact’s position in the conversation using a state. The state is a string stored in the database for every contact, and it determines which block of code handles their next message. The template uses two types of states:- SEND-STATE — sends a message or interactive UI, then transitions the contact into an AWAIT state.
- AWAIT-STATE — receives the user’s response and processes it. It may send a reply and transition to another state, or stay in the same state.
| State | Type | Description |
|---|---|---|
unstructured | AWAIT | Default state. A master router classifies the user’s intent and routes to the appropriate sub-agent or state. |
support | AWAIT | AI-powered support conversation. |
collect_info | AWAIT | Gathers structured information from the contact. |
switch or if/else block to decide what to do when a message arrives for a contact in that state.
A contact’s state persists across messages. If a contact stops mid-conversation and comes back later, they resume in the same state.
The template
When you create a new project, Paige loads a production-ready starter template. The template includes:- An Express server entry point (
app.js) - The main webhook handler (
routes/whatsapp_webhook.js) with the state machine pre-wired - Messaging service functions (
services/messages.js) for sending text, buttons, menus, images, and more - Database service functions (
services/dbServices.js) for reading and writing the project database - A logging utility and a prompts file for AI integration
- An example knowledge base directory for AI context documents
The AI code agent
You build and edit your bot through Paige’s AI chat interface. The AI agent understands your project’s full codebase and has access to a set of built-in tools it can use on your behalf.File tools
File tools
The agent can read, write, edit, delete, and search files in your project. It uses targeted edits when possible to avoid overwriting whole files unnecessarily.
| Tool | What it does |
|---|---|
read_file | Read a file by path |
write_file | Create or overwrite a file with complete content |
edit_file | Make a targeted replacement in an existing file |
multi_edit | Apply multiple edits to a single file atomically |
delete_file | Delete a file |
search_files | Search across all project files by text or regex pattern |
Database tools
Database tools
The agent can inspect and modify your project’s database schema and data as part of writing or debugging bot code.
| Tool | What it does |
|---|---|
create_table | Create a new table with specified columns |
list_tables | List all tables and their schemas |
add_column | Add a column to an existing table |
drop_table | Drop a custom table |
describe_table | Get detailed column info for a single table |
query_table | Read rows from a table |
insert_rows | Insert seed or test data |
Flow tools
Flow tools
The agent can create, update, publish, and manage WhatsApp Flows.
| Tool | What it does |
|---|---|
generate_flow | Create a new WhatsApp Flow via the flows sub-agent |
update_flow | Modify an existing flow |
list_flows | List all flows and their status |
publish_flow | Publish a draft flow to Meta |
delete_flow | Delete a draft flow |
check_flow | Validate a flow against Meta and check for errors |
upload_flow | Re-upload an existing flow JSON to Meta as-is |
Template and debugging tools
Template and debugging tools
| Tool | What it does |
|---|---|
get_template | Load the starter template for a new bot (simple or ai type) |
get_api_reference | Get the API reference for messages.js and dbServices.js |
list_templates | List all WhatsApp message templates for the project |
create_template | Create a new WhatsApp message template |
get_recent_logs | Fetch recent bot execution logs for debugging |
Version history (commits)
Every time you save changes to your bot code, Paige creates a commit. Commits are snapshots of your entire codebase at a point in time.Browse your commit history
Open the Version History panel in the editor to see a list of all commits with timestamps.
Inspect a commit
Click any commit to see what changed — which files were added, modified, or deleted.
Live testing
You can test your bot in real time using Paige Dev — a shared WhatsApp number maintained by Paige. Scan the QR code or open the link from your project dashboard to start a conversation with your bot running the current code. Live testing does not require you to have your own WhatsApp number connected.Message types your bot can send
Your bot can send any of the following message types using the functions inservices/messages.js:
- Plain text
- Interactive buttons (up to 3)
- List menus with sections
- URL buttons
- Images with captions
- Documents (PDF and others)
- Location requests
- Voice notes (with automatic transcription on receipt)
- Message templates