Automations

Automations

Automations (flows) run workflows when something happens in your Notion database. You can build them visually with the brick builder or write code in PHPScript.

Triggers

Every flow starts with a trigger — the event that causes it to run.

On Record Created — Runs when a new record is added to the database.

On Record Updated — Runs when any property on a record changes. Combine with change detection conditions to target specific property changes.

On Record Deleted — Runs when a record is archived or deleted.

Scheduled — Runs on a recurring schedule. Choose a day (every day, or a specific day of the week) and an hour (every hour, or a specific hour). Useful for daily reports, weekly summaries, or periodic cleanup.

On Webhook — Runs when an HTTP request is sent to the flow's webhook URL. After saving the flow, a unique URL is generated that you can call from external services. Accepts POST and GET parameters. Rate limited to 10 requests per minute.

On Email Received — Runs when an inbound email is received on a record in the database. The email content is available in the payload.

Visual Builder

The visual builder lets you create flows by adding and configuring bricks — discrete steps that execute in sequence.

Adding bricks: Click Add Step in the builder to insert a new brick. Each brick has a type, a label, and configuration options.

Configuring bricks: Click a brick to open its configuration panel. Fill in the required fields. Use the token picker ({{}}) to insert dynamic values from the trigger payload or previous bricks.

Nesting: Some bricks are containers. The Foreach brick loops over a collection, and the If brick branches based on a condition. Drag bricks inside containers to nest them.

Token picker: When editing a brick field, type {{ to open the token picker. Available tokens include:

  • {{payload.page_id}} — the record's Notion page ID
  • {{payload.database_id}} — the database ID
  • {{payload.properties.FieldName}} — a property value from the triggering record
  • {{payload.changed_fields}} — list of changed fields (update trigger only)
  • {{payload.webhook.POST}} / {{payload.webhook.GET}} — webhook data
  • {{payload.email.from}} / {{payload.email.subject}} / {{payload.email.body}} — email data
  • {{item.id}} / {{item.properties.FieldName}} — current item inside a foreach loop

Brick Reference

Collectors

  • Query Database — Query a database with optional filters. Results are used in foreach loops.
  • Get Related — Fetch records linked via a relation property.
  • Get Page Content — Get a page's content as markdown text.
  • Search — Search your Notion workspace by keyword.

Logic

  • Set Variable — Store a value for use in later bricks. Variables persist across the flow and can be read with {{variable_name}}.
  • Foreach — Loop over a collection (query results, related records). Bricks inside the loop run once per item.
  • If — Conditional branch. Supports operators: equals, not equals, greater than, less than, contains, not contains, empty, not empty, changed, changed to.

Actions

  • Create Record — Create a new record in a database with field values.
  • Update Record — Update properties on an existing record.
  • Add Comment — Add a comment to a Notion page.
  • Append to Page — Append markdown content to a page body.
  • Send Email — Send an email. Configure recipient, subject, body (rich text), and sending domain. Optionally log the email to a Notion record.
  • HTTP Post — Send an HTTP POST request to an external URL with a JSON body.
  • Print — Output a value to the flow's execution log.

AI Assistant

The flow editor includes an AI assistant that can generate automation logic for you. Type a plain-English description of what you want, and the AI builds the flow.

The AI prompt bar is at the bottom of the editor. Type your request and press Enter or click Ask AI.

How it works:

  • In visual builder mode, the AI generates blocks (bricks) that appear in the builder
  • In code mode, the AI generates PHPScript code
  • The AI knows your database schema — it uses real field names from your connected database
  • You can ask follow-up questions — the AI remembers the conversation within the same editing session

Example prompts:

  • "Send a welcome email when a new record is created"
  • "When Status changes to Done, add a comment and notify the assignee"
  • "Every Monday, query all overdue tasks and post a summary to Slack"
  • "Check if the email contains 'unsubscribe' and update the record status"

Reviewing AI output:

After the AI generates a response, a preview modal shows what it built. In builder mode you see a visual step summary; in code mode you see a side-by-side diff. Click Accept Changes to apply, or close the modal to discard.

The AI preserves your existing flow steps — it adds to or modifies the current flow rather than starting over (unless you ask it to).

Code Mode

For complex logic, switch to code mode. Click Switch to Code in the builder toolbar.

Code mode uses PHPScript — a PHP-compatible scripting language. You have full access to variables, loops, conditionals, and all built-in functions.

Built-in Functions

Notion Pages:

Function Description
notion_page_get($pageId) Fetch a page by ID
notion_page_create($databaseId, $properties) Create a page with raw Notion properties
notion_page_update($pageId, $properties) Update a page with raw Notion properties
notion_page_delete($pageId) Archive a page
notion_record_create($databaseId, $fields) Create a record with simple {Name: value} pairs
notion_record_update($pageId, $fields) Update a record with simple {Name: value} pairs

Database Queries:

Function Description
notion_db_query($databaseId) Query all pages in a database
notion_db_query_filter($databaseId, $filter) Query with a Notion filter object
notion_search($query) Search the workspace
notion_get_related($databaseId, $relationProp, $pageId) Get records related to a page

Page Content:

Function Description
notion_page_markdown($pageId) Get page content as markdown
notion_page_append($pageId, $text) Append markdown to a page
notion_blocks_get($blockId) Get child blocks
notion_blocks_append($blockId, $children) Append block objects
notion_comment($pageId, $text) Add a comment

HTTP:

Function Description
remote_post($url, $data) POST JSON to a URL
remote_curl($options) Flexible HTTP request: {url, method, headers, body, timeout}

Variables and Email:

Function Description
var_get($key) Read from the persistent key-value store
var_set($key, $value) Write to the persistent key-value store
email_send($options) Send email: {to, subject, body, from?, from_name?, page_id?}
log_message($message) Print to flow output

Example: Welcome Email on New Record

$name = $payload['properties']['Name'];
$email = $payload['properties']['Email'];

email_send([
    'to' => $email,
    'subject' => 'Welcome, ' . $name,
    'body' => '<p>Thanks for signing up!</p>',
]);

notion_record_update($payload['page_id'], [
    'Status' => 'Welcomed',
]);

Switching Between Modes

You can switch between visual builder and code mode. When switching from builder to code, your bricks are compiled into PHPScript. When switching from code to builder, the code is parsed back into bricks (if the structure is compatible).

Changes in one mode overwrite the other. Make sure to save before switching.

Property Change Detection

When using the "On Record Updated" trigger, you can limit execution to specific property changes.

In the If brick, use the changed or changed_to operators:

  • changed — true if the specified property was modified in this update
  • changed_to — true if the property changed to a specific value

Example: Run only when the "Status" property changes to "Done":

  1. Add an If brick after the trigger
  2. Set the field to Status
  3. Set the operator to changed_to
  4. Set the value to Done
  5. Place your action bricks inside the If block

The {{payload.changed_fields}} token contains a list of all properties that changed in the update.

Testing Flows

Test your flow against real records before activating it.

  1. In the flow editor, look for the Test section in the right panel
  2. Search for and select a record from your database
  3. Click Run on Record
  4. The output appears in the Last Output tab
  5. If there's an error, the output shows the error message and line number

Testing runs the flow immediately with the selected record's data. It does not wait for a trigger event.

Execution Logs

Every flow execution is logged for 30 days.

Go to Flow Logs to see:

  • Which flow ran and when
  • Trigger type and triggering record
  • Execution status (success or error)
  • Output and error messages
  • Execution duration

You can also see recent logs for a specific flow in the Logs tab of the flow editor.

Webhook Flows

Webhook flows are triggered by HTTP requests from external services.

  1. Create a flow with the On Webhook trigger
  2. Save the flow — a unique webhook URL is generated
  3. Copy the URL and configure it in your external service

The webhook URL looks like: https://powerup.globi.ca/webhooks/flow/YOUR_TOKEN

Passing data: Send data via POST body (JSON) or GET query parameters. Access it in your flow with:

  • {{payload.webhook.POST}} — the POST body
  • {{payload.webhook.GET}} — query string parameters
  • {{payload.webhook.STDIN}} — raw request body

Webhook flows are rate limited to 10 requests per minute per flow.

Email Received Trigger

The "On Email Received" trigger runs when an inbound email arrives on a record in the database.

The email data is available in the payload:

  • {{payload.email.from}} — sender email address
  • {{payload.email.from_name}} — sender display name
  • {{payload.email.to}} — recipient address
  • {{payload.email.subject}} — email subject
  • {{payload.email.body}} — plain text body
  • {{payload.email.html_body}} — HTML body
  • {{payload.email.date}} — email date
  • {{payload.email.message_id}} — message ID

Use this trigger to automate responses, update records when emails arrive, or forward content to other systems.