> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automations

> Schedule recurring tasks and trigger functions automatically based on database events or connector webhook events

<div className="dev-docs-banner">
  <div className="dev-docs-banner-content">
    <div className="dev-docs-banner-title">
      You're viewing developer documentation
    </div>

    <div className="dev-docs-banner-text">
      This documentation is for developers working with the Base44 developer platform. For information about automations in the app editor, see <a href="/Building-your-app/Creating-automations">Creating automations for your app</a>.
    </div>
  </div>
</div>

Automations allow [backend functions](/developers/backend/resources/backend-functions/overview) to run automatically on a schedule, in response to database events, or when a connected integration sends a webhook event. Use automations to process data at regular intervals, handle entity changes, react to external service events, or execute one-time tasks at specific times.

Each backend function can have multiple automations attached, configured in the function's `function.jsonc` file. If you only have an `entry.ts` or `entry.js` file, you'll need to add this configuration file to use automations. Automations are [deployed atomically with the function code](#deploy-automations) when you run [`deploy`](/developers/references/cli/commands/deploy) or [`functions deploy`](/developers/references/cli/commands/functions-deploy).

## Automation types

Base44 supports 4 types of automations:

* **[Scheduled automations with cron](#cron)**: Use cron expressions for precise scheduling control.
* **[Scheduled automations with simple schedules](#simple-schedule)**: Configure recurring tasks by interval without cron expressions.
* **[Entity event automations](#entity-events)**: Trigger functions when database records are created, updated, or deleted.
* **[Connector automations](#connector-automations)**: Respond to events from connected services in real time, such as a new email in Gmail or a file change in Google Drive.

## Common fields

### Common fields for all automations

All automation types share the following fields:

| Field           | Type      | Required | Description                                                                                     |
| --------------- | --------- | -------- | ----------------------------------------------------------------------------------------------- |
| `type`          | `string`  | Yes      | The automation type. Possible values: `"scheduled"`, `"entity"`, or `"connector"`.              |
| `name`          | `string`  | Yes      | Unique identifier for the automation.                                                           |
| `description`   | `string`  | No       | Human-readable description.                                                                     |
| `function_args` | `object`  | No       | Arguments passed to the function when triggered. See [Function arguments](#function-arguments). |
| `is_active`     | `boolean` | No       | Whether the automation is enabled. Defaults to `true`.                                          |

### Common fields for scheduled automations

Both cron and simple scheduled automations share these additional fields:

| Field              | Type     | Required    | Description                                                                                                                                                           |
| ------------------ | -------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schedule_mode`    | `string` | Yes         | Whether the schedule repeats. Possible values: `"recurring"` or `"one-time"`.                                                                                         |
| `schedule_type`    | `string` | Yes         | Scheduling method to use. Possible values: `"cron"` or `"simple"`.                                                                                                    |
| `ends_type`        | `string` | No          | When the recurring schedule should stop. Possible values: `"never"`, `"on"`, or `"after"`. Defaults to `"never"`.                                                     |
| `ends_on_date`     | `string` | Conditional | Date when the recurring schedule ends, inclusive, in UTC. Required when `ends_type` is `"on"`. Format: `YYYY-MM-DDTHH:MM:SSZ`. For example, `"2026-12-31T23:59:59Z"`. |
| `ends_after_count` | `number` | Conditional | Number of executions after which the recurring schedule stops. Required when `ends_type` is `"after"`.                                                                |

## Automation configuration

Configure automations in your `function.jsonc` file using one of the following approaches. All automations use the [common fields for all automations](#common-fields-for-all-automations) listed above, plus the fields specific to each type.

### Cron

Use [common fields for all automations](#common-fields-for-all-automations) and [common fields for scheduled automations](#common-fields-for-scheduled-automations) along with the cron-specific fields listed here.

Set `type` to `"scheduled"` and `schedule_type` to `"cron"` to use cron expressions for precise scheduling control.

Cron automations use standard 5-field syntax: `minute hour day-of-month month day-of-week`. See [crontab.guru](https://crontab.guru/) for an interactive cron expression editor and syntax reference.

| Field             | Type     | Required | Description              |
| ----------------- | -------- | -------- | ------------------------ |
| `cron_expression` | `string` | Yes      | 5-field cron expression. |

#### Cron example

This example runs a function every day at midnight UTC:

```jsonc theme={null}
{
  "name": "sendDailyReport",
  "entry": "entry.ts",
  "automations": [
    {
      "type": "scheduled",
      "name": "daily_midnight_report",
      "description": "Runs every day at midnight UTC",
      "function_args": { "mode": "full_sync" },
      "is_active": true,

      "schedule_mode": "recurring",
      "schedule_type": "cron",
      "cron_expression": "0 0 * * ?"
    }
  ]
}
```

### Simple schedule

Use [common fields for all automations](#common-fields-for-all-automations) and [common fields for scheduled automations](#common-fields-for-scheduled-automations) along with the simple schedule fields listed here.

Set `type` to `"scheduled"` and `schedule_type` to `"simple"` for straightforward scheduling needs.

Configure recurring tasks by interval such as minutes, hours, days, weeks, or months without writing cron expressions.

| Field                    | Type       | Required    | Description                                                                                                                                                                |
| ------------------------ | ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `one_time_date`          | `string`   | Conditional | Date and time when the automation runs once, in UTC. Required when `schedule_mode` is `"one-time"`. Format: `YYYY-MM-DDTHH:MM:SSZ`. For example, `"2026-02-15T10:00:00Z"`. |
| `repeat_unit`            | `string`   | Conditional | Time unit for recurring automations. Required when `schedule_mode` is `"recurring"`. Possible values: `"minutes"`, `"hours"`, `"days"`, `"weeks"`, or `"months"`.          |
| `repeat_interval`        | `number`   | Conditional | Interval between executions. Required when `repeat_unit` is `"minutes"`, `"hours"`, or `"days"`.                                                                           |
| `start_time`             | `string`   | Conditional | Time of day when the automation runs, in UTC. Required when `repeat_unit` is `"days"`, `"weeks"`, or `"months"`. Format: `HH:MM`.                                          |
| `repeat_on_days`         | `number[]` | Conditional | Days of the week when the automation runs. Required when `repeat_unit` is `"weeks"`. Array of weekday numbers, where `0` is Sunday and `6` is Saturday.                    |
| `repeat_on_day_of_month` | `number`   | Conditional | Day of the month when the automation runs. Required when `repeat_unit` is `"months"`. Valid values: `1`-`31`.                                                              |

#### Simple schedule examples

The following examples show different ways to schedule automations with simple schedules:

<CodeGroup>
  ```jsonc Every 30 minutes theme={null}
  {
    "type": "scheduled",
    "name": "every_30_minutes",
    "description": "Runs every 30 minutes.",
    "is_active": true,

    "schedule_mode": "recurring",
    "schedule_type": "simple",
    "repeat_unit": "minutes",
    "repeat_interval": 30
  }
  ```

  ```jsonc Weekdays at 9am theme={null}
  {
    "type": "scheduled",
    "name": "weekday_morning_report",
    "description": "Runs at 9 AM Monday through Friday.",
    "is_active": true,

    "schedule_mode": "recurring",
    "schedule_type": "simple",
    "repeat_unit": "weeks",
    "repeat_interval": 1,
    "start_time": "09:00",
    "repeat_on_days": [1, 2, 3, 4, 5],

    "ends_type": "after",
    "ends_after_count": 52
  }
  ```

  ```jsonc One-time execution theme={null}
  {
    "type": "scheduled",
    "name": "one_time_cleanup",
    "description": "Runs once at a specific date and time.",
    "function_args": { "cleanup": true },
    "is_active": true,

    "schedule_mode": "one-time",
    "schedule_type": "simple",
    "one_time_date": "2026-02-15T10:00:00Z"
  }
  ```
</CodeGroup>

### Entity events

Use [common fields for all automations](#common-fields-for-all-automations) along with the entity event fields listed here.

Set `type` to `"entity"` to trigger functions automatically when database records are created, updated, or deleted.

Entity automations can listen to 1 or more event types on a specific entity.

| Field         | Type       | Required | Description                                                                                              |
| ------------- | ---------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `entity_name` | `string`   | Yes      | Name of the entity to monitor.                                                                           |
| `event_types` | `string[]` | Yes      | Database events to listen for. Possible values: `"create"`, `"update"`, `"delete"`. At least 1 required. |

#### Entity event examples

The following examples show how to trigger functions based on entity events:

<CodeGroup>
  ```jsonc All order events theme={null}
  {
    "name": "processOrders",
    "entry": "entry.ts",
    "automations": [
      {
        "type": "entity",
        "name": "on_order_changes",
        "description": "Triggered on order create, update, or delete.",
        "function_args": { "notify_slack": true },
        "is_active": true,

        "entity_name": "orders",
        "event_types": ["create", "update", "delete"]
      }
    ]
  }
  ```

  ```jsonc New records only theme={null}
  {
    "type": "entity",
    "name": "on_customer_create",
    "description": "Triggered when a new customer is created.",
    "is_active": true,

    "entity_name": "customers",
    "event_types": ["create"]
  }
  ```
</CodeGroup>

### Connector automations

Use [common fields for all automations](#common-fields-for-all-automations) along with the connector-specific fields listed here.

Set `type` to `"connector"` to trigger functions when a connected integration sends a webhook event. Use these to react to external service activity in real time. For example, you can parse a new email, sync a calendar change, or respond to a file update in Google Drive.

You can optionally add [trigger conditions](#trigger-conditions) to filter events so your function only runs when the payload matches rules you define.

When a connector automation fires, your function receives a structured [webhook payload](#webhook-payload) containing the event type, integration details, and the raw data from the external service.

<Note>
  The connector must be configured in your project and authorized before deployment. See [Shared connectors](/developers/backend/resources/connectors/shared-connectors) for setup instructions.
</Note>

| Field                | Type       | Required    | Description                                                                                                                                                                                                                     |
| -------------------- | ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `integration_type`   | `string`   | Yes         | The connector type identifier to listen on. See [supported integrations](#supported-integrations-and-events) for accepted values.                                                                                               |
| `events`             | `string[]` | Yes         | One or more webhook event names to subscribe to. See [supported integrations](#supported-integrations-and-events) for available events per connector.                                                                           |
| `resource_id`        | `string`   | Conditional | Scopes the automation to a specific resource. The expected format depends on the connector. See [Resource ID formats](#resource-id-formats) below. Required for Google Drive file-scoped events. Optional for other connectors. |
| `trigger_conditions` | `object`   | No          | Rules that must match the incoming event before your function runs. If the event does not match, the run is skipped. See [Trigger conditions](#trigger-conditions) for the full reference.                                      |

#### Supported integrations and events

| Connector            | `integration_type` | `events` value          | Description                                                                         |
| -------------------- | ------------------ | ----------------------- | ----------------------------------------------------------------------------------- |
| Gmail                | `gmail`            | `mailbox`               | Any mailbox change, including new messages, label updates, and read status changes. |
| Google Calendar      | `googlecalendar`   | `events`                | Any calendar event change, including created, updated, and deleted.                 |
| Google Drive         | `googledrive`      | `changes`               | Any change in the drive, including files added, modified, or deleted.               |
| Google Drive         | `googledrive`      | `file`                  | Any change to a specific file (requires `resource_id`).                             |
| Google Drive         | `googledrive`      | `file.update`           | File content or properties changed (requires `resource_id`).                        |
| Google Drive         | `googledrive`      | `file.trash`            | File moved to trash (requires `resource_id`).                                       |
| Google Drive         | `googledrive`      | `file.untrash`          | File restored from trash (requires `resource_id`).                                  |
| Google Drive         | `googledrive`      | `file.delete`           | File permanently deleted (requires `resource_id`).                                  |
| Microsoft OneDrive   | `one_drive`        | `updated`               | Any file or folder change, including created, modified, and deleted.                |
| Microsoft Outlook    | `outlook`          | `created`               | A new email, calendar event, or contact is created.                                 |
| Microsoft Outlook    | `outlook`          | `updated`               | An email, calendar event, or contact is updated.                                    |
| Microsoft Outlook    | `outlook`          | `deleted`               | An email, calendar event, or contact is deleted.                                    |
| Microsoft SharePoint | `share_point`      | `updated`               | When a list item or document is created, modified, or deleted.                      |
| Microsoft Teams      | `microsoft_teams`  | `created`               | When a new chat message is posted.                                                  |
| Microsoft Teams      | `microsoft_teams`  | `updated`               | When a chat message is updated.                                                     |
| Microsoft Teams      | `microsoft_teams`  | `deleted`               | When a chat message is deleted.                                                     |
| Slack                | `slack`            | `message`               | When a message is posted to a channel.                                              |
| Slack                | `slack`            | `message.im`            | When a direct message is posted.                                                    |
| Slack                | `slack`            | `message.groups`        | When a message is posted to a private channel.                                      |
| Slack                | `slack`            | `message.channels`      | When a message is posted to a public channel.                                       |
| Slack                | `slack`            | `message.mpim`          | When a message is posted to a multi-party IM.                                       |
| Slack                | `slack`            | `reaction_added`        | When a reaction is added to a message.                                              |
| Slack                | `slack`            | `reaction_removed`      | When a reaction is removed from a message.                                          |
| Slack                | `slack`            | `member_joined_channel` | When a user joins a channel.                                                        |
| Slack                | `slack`            | `member_left_channel`   | When a user leaves a channel.                                                       |
| Slack                | `slack`            | `file_shared`           | When a file is shared.                                                              |

<Tip>
  Gmail's `mailbox` event fires for any mailbox change, not just new messages. To run your function only when new emails arrive, add a trigger condition: `{ "field": "has_new_messages", "operator": "equals", "value": true }`.
</Tip>

<Note>
  Slack connector automations require trigger conditions. Deployment will fail if no conditions are set for Slack connector automations.
</Note>

#### Resource ID formats

The expected value for `resource_id` varies by connector:

* **Google Drive:** The file ID. Required for file-scoped events (`file`, `file.update`, `file.trash`, `file.untrash`, `file.delete`).
* **Gmail:** A comma-separated list of label IDs to watch. Defaults to `"INBOX"` if omitted.
* **Microsoft Teams:** `{teamId}/{channelId}` to watch a specific channel, or `{chatId}` to watch a specific chat.
* **SharePoint:** `{siteId}/{listId}` to watch a specific list.

#### Trigger conditions

Use `trigger_conditions` to filter webhook events so your function only runs when the payload matches rules you define. If no conditions are set, the function runs for every incoming event. See [Connector automation examples](#connector-automation-examples) for complete configurations.

<ResponseField name="logic" type="string">
  How to combine the conditions. Possible values: `"and"` (all must match), `"or"` (any must match). Defaults to `"and"`.
</ResponseField>

<ResponseField name="conditions" type="array" required>
  One or more condition objects or nested condition groups. Maximum 20 leaf conditions and 5 levels of nesting.

  <Expandable title="Condition object fields">
    <ResponseField name="field" type="string" required>
      Dot-separated path into the webhook payload. For example, `"status"` reads `payload.data.status`, and `"sender.email"` reads `payload.data.sender.email`.
    </ResponseField>

    <ResponseField name="operator" type="string" required>
      How to compare the field value.

      <Expandable title="Supported operators">
        | Operator       | Description                                                                              |
        | -------------- | ---------------------------------------------------------------------------------------- |
        | `equals`       | Field value exactly matches `value`.                                                     |
        | `not_equals`   | Field value does not match `value`.                                                      |
        | `contains`     | Field value contains `value` as a substring.                                             |
        | `not_contains` | Field value does not contain `value` as a substring.                                     |
        | `starts_with`  | Field value starts with `value`.                                                         |
        | `ends_with`    | Field value ends with `value`.                                                           |
        | `gt`           | Field value is greater than `value`.                                                     |
        | `gte`          | Field value is greater than or equal to `value`.                                         |
        | `lt`           | Field value is less than `value`.                                                        |
        | `lte`          | Field value is less than or equal to `value`.                                            |
        | `in_list`      | Field value is one of the items in `value` (an array).                                   |
        | `not_in_list`  | Field value is not one of the items in `value` (an array).                               |
        | `exists`       | Field is present and not null. No `value` required.                                      |
        | `not_exists`   | Field is null or missing. No `value` required.                                           |
        | `is_empty`     | Field is null, an empty string, an empty array, or an empty object. No `value` required. |
        | `is_not_empty` | Field is not null, empty string, empty array, or empty object. No `value` required.      |
      </Expandable>
    </ResponseField>

    <ResponseField name="value" type="any">
      The value to compare against. Not required for `exists`, `not_exists`, `is_empty`, and `is_not_empty`.
    </ResponseField>
  </Expandable>
</ResponseField>

#### Webhook payload

When a connector automation triggers your function, the request body contains a `payload` object with the following structure. See [Connector automation examples](#connector-automation-examples) for a function that reads the payload.

| Field                               | Type      | Description                                                                                          |
| ----------------------------------- | --------- | ---------------------------------------------------------------------------------------------------- |
| `payload.automation.id`             | `string`  | ID of the automation that triggered this run.                                                        |
| `payload.automation.name`           | `string`  | Name of the automation.                                                                              |
| `payload.automation.type`           | `string`  | Always `"connector"`.                                                                                |
| `payload.event.type`                | `string`  | The webhook event name. For example, `"mailbox"`, `"events"`, or `"changes"`.                        |
| `payload.event.integration_type`    | `string`  | The connector type. For example, `"gmail"` or `"googlecalendar"`.                                    |
| `payload.event.provider_identifier` | `string`  | The provider account identifier used for routing.                                                    |
| `payload.data`                      | `object`  | The raw webhook payload from the external service. Set to `null` when `payload_too_large` is `true`. |
| `payload.payload_too_large`         | `boolean` | Is `true` when the webhook payload exceeded \~200 KB and `data` is `null`.                           |

#### Connector automation examples

<CodeGroup>
  ```jsonc Basic connector automation theme={null}
  // Triggers the function whenever a new email arrives in Gmail.

  {
    "name": "processInboundEmails",
    "entry": "entry.ts",
    "automations": [
      {
        "type": "connector",
        "name": "on_new_gmail",
        "description": "Runs when a new email arrives in Gmail.",
        "is_active": true,

        "integration_type": "gmail",
        "events": ["mailbox"]
      }
    ]
  }
  ```

  ```jsonc Single trigger condition theme={null}
  // Triggers only when a Google Calendar event has status "cancelled".

  {
    "type": "connector",
    "name": "on_event_cancelled",
    "description": "Runs only when a Google Calendar event is cancelled.",
    "is_active": true,

    "integration_type": "googlecalendar",
    "events": ["events"],
    "trigger_conditions": {
      "logic": "and",
      "conditions": [
        { "field": "status", "operator": "equals", "value": "cancelled" }
      ]
    }
  }
  ```

  ```jsonc Nested trigger conditions theme={null}
  // Triggers only for Gmail messages that are both in the inbox and unread.

  {
    "type": "connector",
    "name": "on_unread_inbox_email",
    "description": "Runs only for unread emails in the inbox.",
    "is_active": true,

    "integration_type": "gmail",
    "events": ["mailbox"],
    "trigger_conditions": {
      "logic": "and",
      "conditions": [
        { "field": "labelIds", "operator": "contains", "value": "INBOX" },
        { "field": "labelIds", "operator": "contains", "value": "UNREAD" }
      ]
    }
  }
  ```

  ```typescript Reading the payload theme={null}
  // Reads the structured payload from the request body.

  Deno.serve(async (req) => {
    const body = await req.json();
    const { payload } = body;

    const eventType = payload.event.type;            
    const integration = payload.event.integration_type; 

    if (payload.payload_too_large) {
      console.warn("Webhook payload was too large and was not included.");
      return Response.json({ ok: false, reason: "payload_too_large" });
    }

    const data = payload.data; 
    
    // Your function logic
    console.log(`Received ${eventType} event from ${integration}`, data);

    return Response.json({ ok: true });
  });
  ```
</CodeGroup>

### Function arguments

Pass data to your function when it's triggered by including the `function_args` field in your automation configuration. This is useful when one function handles multiple automations with different behaviors, such as a sync function that runs incrementally every 15 minutes but does a full sync daily.

Access these arguments in your function code through the request body.

#### Function arguments example

This example shows a function that handles both incremental and full sync modes based on the automation config:

<CodeGroup>
  ```typescript Function code theme={null}
  Deno.serve(async (req) => {
    const body = await req.json();
    const args = body.args ?? {};

    // Use the arguments from automation config
    const mode = args.mode ?? "incremental";

    // Your function logic
  });
  ```

  ```jsonc Automation config theme={null}
  {
    "name": "syncData",
    "entry": "entry.ts",
    "automations": [
      {
        "type": "scheduled",
        "name": "incremental_sync",
        "description": "Runs every 15 minutes with incremental mode.",
        "function_args": { "mode": "incremental" },
        "is_active": true,
        "schedule_mode": "recurring",
        "schedule_type": "simple",
        "repeat_unit": "minutes",
        "repeat_interval": 15
      },
      {
        "type": "scheduled",
        "name": "full_sync",
        "description": "Runs daily at midnight with full sync mode.",
        "function_args": { "mode": "full" },
        "is_active": true,
        "schedule_mode": "recurring",
        "schedule_type": "cron",
        "cron_expression": "0 0 * * ?"
      }
    ]
  }
  ```
</CodeGroup>

## Deploy automations

Deploy backend functions with their automations using the CLI [`functions deploy`](/developers/references/cli/commands/functions-deploy) command or the unified [`deploy`](/developers/references/cli/commands/deploy) command. You can deploy specific functions by name with `functions deploy <names...>`.

The deployment is atomic per function. A function is only considered deployed if both the Deno deployment and all its automations succeed. If any automation fails to deploy, the entire function deployment is rolled back.

After deploying, the CLI shows per-function status: deployed, unchanged, or error.

## Manage automations in the dashboard

<Warning>
  Any changes made in the dashboard will be overwritten the next time you run [`functions deploy`](/developers/references/cli/commands/functions-deploy). There is no two-way sync between the dashboard and your local files. Automations defined in your local `function.jsonc` files are the source of truth.

  If you want to make changes to your automations, update your local `function.jsonc` files and redeploy. Use the dashboard for monitoring execution logs and manually triggering automations when needed.
</Warning>

View and manage your automations in the Base44 dashboard under the **Automations** tab. From the dashboard, you can:

* View execution logs and history
* Run automations manually for testing
* Monitor automation status

## See also

* [Backend Functions](/developers/backend/resources/backend-functions/overview): Learn about backend functions
* [`functions deploy`](/developers/references/cli/commands/functions-deploy): Deploy functions with automations
* [`deploy`](/developers/references/cli/commands/deploy): Deploy all resources at once
* [`logs`](/developers/references/cli/commands/logs): View function logs
