Skip to main content
Tables define data storage schemas for your agent. They provide structured storage that’s automatically synced with Botpress Cloud and accessible throughout your agent.

Creating a table

Create a table definition in src/tables/:
import { Table, z } from "@botpress/runtime";

export default new Table({
  name: "PricingTable",
  columns: {
    itemName: z.string(),
    price: z.string(),
  },
});

Naming a table

To properly deploy your agent, make sure your table name follows the correct convention:
  • Cannot start with a number
  • Must be 30 characters or less
  • Can contain only letters, numbers, and underscores
  • Must end with Table

Table schema

Simple definition

Define your table using Zod schemas:
export default new Table({
  name: "OrderTable",
  columns: {
    userId: z.string(),
    items: z.array(z.string()),
    total: z.number(),
    status: z.string(),
    createdAt: z.string().datetime(),
    updatedAt: z.string().datetime(),
  },
});

Extended definition

You can also define table columns with additional options for each column:
import { Table, z } from "@botpress/runtime";

export default new Table({
  name: "OrderTable",
  columns: {
    itemName: {
      schema: z.string(),
      searchable: true
    },
    price: {
      schema: z.string(),
      searchable: true
    }
  },
});
Check out the column options in the Table props reference for a full overview of the available options.

Using tables

Tables are automatically created and synced when you deploy. You can import them and interact with them directly using the table instance methods, which provide type-safe operations:
src/workflows/create-order.ts
import { Workflow } from "@botpress/runtime";
import OrderTable from "../tables/order-table";

export default new Workflow({
  name: "createOrder",
  handler: async ({ step }) => {
    // Create rows
    const { rows } = await OrderTable.createRows({
      rows: [{ userId: "user123", total: 99.99, status: "pending" }],
    });

    // Find rows with filters
    const { rows: orders } = await OrderTable.findRows({
      filter: { status: "pending" },
      orderBy: "createdAt",
      orderDirection: "desc",
      limit: 10,
    });

    // Update rows
    await OrderTable.updateRows({
      rows: [{ id: orders[0].id, status: "completed" }],
    });
  },
});

Reference

Tables are automatically synced with Botpress Cloud. When you deploy your agent, table schemas are created or updated to match your definitions.
Last modified on December 10, 2025