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.

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.

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.
The default template ships with three states:
StateTypeDescription
unstructuredAWAITDefault state. A master router classifies the user’s intent and routes to the appropriate sub-agent or state.
supportAWAITAI-powered support conversation.
collect_infoAWAITGathers structured information from the contact.
You can add as many states as your bot needs. A state is just a string — the webhook handler uses a 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 template connects to your project’s Postgres database automatically — no connection string configuration required inside the Paige environment.

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.
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.
ToolWhat it does
read_fileRead a file by path
write_fileCreate or overwrite a file with complete content
edit_fileMake a targeted replacement in an existing file
multi_editApply multiple edits to a single file atomically
delete_fileDelete a file
search_filesSearch across all project files by text or regex pattern
The agent can inspect and modify your project’s database schema and data as part of writing or debugging bot code.
ToolWhat it does
create_tableCreate a new table with specified columns
list_tablesList all tables and their schemas
add_columnAdd a column to an existing table
drop_tableDrop a custom table
describe_tableGet detailed column info for a single table
query_tableRead rows from a table
insert_rowsInsert seed or test data
The agent can create, update, publish, and manage WhatsApp Flows.
ToolWhat it does
generate_flowCreate a new WhatsApp Flow via the flows sub-agent
update_flowModify an existing flow
list_flowsList all flows and their status
publish_flowPublish a draft flow to Meta
delete_flowDelete a draft flow
check_flowValidate a flow against Meta and check for errors
upload_flowRe-upload an existing flow JSON to Meta as-is
ToolWhat it does
get_templateLoad the starter template for a new bot (simple or ai type)
get_api_referenceGet the API reference for messages.js and dbServices.js
list_templatesList all WhatsApp message templates for the project
create_templateCreate a new WhatsApp message template
get_recent_logsFetch 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.
1

Browse your commit history

Open the Version History panel in the editor to see a list of all commits with timestamps.
2

Inspect a commit

Click any commit to see what changed — which files were added, modified, or deleted.
3

Restore a commit

Click Restore on any commit to roll your codebase back to that point. A new commit is created for the restore so you never lose history.
Commits are created automatically on every save. You don’t need to do anything to enable version history — it is always on.

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 in services/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