> For the complete documentation index, see [llms.txt](https://docs.diaflow.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.diaflow.io/teammates/routines-and-automation/schedule-and-event-routines.md).

# Schedule & Event Routines

Learn how to automate proactive workflows by creating scheduled routines or triggering your AI Teammate from integrated app events.

**Routines** are automated background workflows that empower your AI Teammates to work autonomously without waiting for manual prompts. Whether checking critical customer emails every morning or auditing database query costs every Monday, Routines ensure repetitive tasks are handled proactively.

Diaflow offers flexible ways to access, create, and configure routines, either by letting AI draft the instructions for you or by manually fine-tuning every parameter.

## Where to Add a Routine <a href="#user-content-1-how-routines-work-the-inbox-delivery-model" id="user-content-1-how-routines-work-the-inbox-delivery-model"></a>

You can initiate routine creation from two convenient locations in your workspace:

* **Option A: From the Chat Workspace (Routines Widget):**\
  Look at the bottom-right panel of your chat view. In the **Routines** widget header, click the **`+` (Add)** icon to quickly create a new routine for the active Teammate.
* **Option B: From Teammate Settings:**\
  Click the **Settings `⚙️`** icon in the top-right corner of the workspace, navigate to the **Routines** tab on the left sidebar, and click the green **`+` (Add)** button located next to the search and filter bar.

{% tabs %}
{% tab title="Option A" %}

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2F6FpdS3gzTWJtJhDGdxtw%2Frounded-image%20(38).png?alt=media&amp;token=5c7441f1-b4da-4a29-8ed3-85e25a517589" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Option B" %}

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FdHWlusIII7G9Ae1lwZck%2Frounded-image%20(39).png?alt=media&amp;token=906d2084-c908-4ffd-8ec1-a777e2312861" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Methods of Creating a Routine <a href="#user-content-2-routine-trigger-types" id="user-content-2-routine-trigger-types"></a>

When the **Create a routine** window opens, you can choose between AI-assisted generation or full manual control:

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2Fxse2Xd6Hja7DEopUXCmk%2Frounded-image%20(40).png?alt=media&amp;token=3cba51d8-72bb-4400-b4a4-9a8fd2abd90d" alt=""><figcaption></figcaption></figure>

### **Method 1: Generate with AI (Fast & Recommended)**

Simply describe what you want the Teammate to accomplish in plain language:

1. In the input box under *"What do you want the teammate to do?"*, type your request (e.g., `Check email everyday at 7am` or `Audit database query costs every Monday at 8am`).
2. Press **Enter** or click the **Arrow Up `↑`** button.
3. **What Diaflow does automatically:**
   * **Names the Routine:** Generates a professional title (e.g., *Check email daily at 7 AM*).
   * **Drafts a Structured Prompt:** Composes a comprehensive, production-ready instruction set including scope, priority criteria, formatting requirements, and fallback handling (e.g., *"If there are no new emails, respond with 'No new emails found.'"*).
   * **Pre-configures Triggers:** Automatically maps your time preference to the appropriate recurrence schedule.
4. Review the generated configuration and click **Save**.

### **Method 2: Create a Routine Manually**

For granular control over triggers, execution prompts, and thread behaviors, click **`Create a routine manually →`** at the bottom of the modal:

1. **Routine name:** Enter a clear, identifiable name for your routine (e.g., *Daily Data Pipeline Health & Query Cost Audit*).
2. **Prompt:** Write the detailed prompt your Teammate must follow on each run. You can specify what data to inspect, how to prioritize findings, and the exact output format.
3. **Trigger Configuration:** Choose how this routine initiates:
   * **Schedule (Recurring Time):**
     * Click **`+ Add`** to set execution times (e.g., *At 07:00, every 1 day(s), starting 09/07/2026*). You can configure multiple schedules for different intervals (Daily, Weekly, etc.).
   * **On App Event (Event-Driven Automation):**
     * Select a connected third-party tool (e.g., *Gmail, Google Calendar, Slack, HubSpot*) and define the triggering event (e.g., *New email received, Meeting ended, Deal stage updated*).
4. **Thread Management (`Start a new thread each run`):**
   * **Checked (ON):** Each automated run generates a fresh conversation thread. This prevents long-running routines from cluttering your existing chats and keeps each execution history isolated.
   * **Unchecked (OFF):** New run outputs will append directly to the current conversation thread.
5. Click **Save** to activate the routine.

<figure><img src="https://3864624312-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdo1pkMnofwxf3lpWftw%2Fuploads%2FkedkJhhop8Cvd0SU0woq%2Frounded-image%20(41).png?alt=media&amp;token=bb03ce86-0c81-420b-b5b1-1a5a15523f3a" alt=""><figcaption></figcaption></figure>

### Next steps <a href="#user-content-next-steps" id="user-content-next-steps"></a>

* [**Managing & Running Routines**:](/teammates/routines-and-automation/managing-and-running-routines.md) Learn how to test routines with on-demand runs, toggle active schedules, and review execution logs.
