# AI scheduled tasks

> Prompts a user schedules on a cron, with a run per occurrence; the scheduler claims due tasks, queues an ai_task_run job when jobs is installed, and fails runs that stall.

- Category: AI
- Module: `ai-schedules`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/ai-schedules
- Page: https://bettersupabase.com/blocks/ai-schedules

## Install

```bash
npx better-supabase add ai-schedules
```

The command also installs `updated-at`, `memberships`, `permissions`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by ai-schedules; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    // Modes: "managed". The default is "managed".
    "ai-schedules": { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/ai-schedules`.

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md)

Works with: [agents](https://bettersupabase.com/blocks/agents.md), [ai-chat](https://bettersupabase.com/blocks/ai-chat.md), [queue](https://bettersupabase.com/blocks/queue.md)

## Recipes

- [AI task queue](https://bettersupabase.com/recipes/ai-task-queue.md): A table of scheduled AI prompts with each task's next run and latest run status, plus pause and resume.
