Mirra
Building with MirraFlows

Flow Examples

Practical examples and patterns for common flow use cases

This page provides practical examples for common flow patterns and use cases.

Time-Based Flows

Daily Morning Report

Generate and send a daily report every morning at 9 AM.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Daily Morning Report",
    "description": "Generates and sends analytics report every morning",
    "schedule": "0 9 * * *",
    "scriptId": "script_morning_report"
  }'

Cron Expression: 0 9 * * * (Daily at 9:00 AM)

Use Case: Keep yourself informed with a daily digest of important information without manual checking.


Weekly Data Cleanup

Run data cleanup and optimization tasks every Sunday at midnight.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Weekly Data Cleanup",
    "description": "Cleans up old data and optimizes memory every Sunday",
    "schedule": "0 0 * * 0",
    "scriptId": "script_data_cleanup"
  }'

Cron Expression: 0 0 * * 0 (Sundays at midnight)

Use Case: Automated data maintenance to keep your Mirra account clean and performant.


Hourly Price Check

Monitor cryptocurrency prices every hour during trading hours.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Hourly BTC Price Check",
    "description": "Checks Bitcoin price every hour from 9 AM to 5 PM on weekdays",
    "schedule": "0 9-17 * * 1-5",
    "scriptId": "script_btc_price_check"
  }'

Cron Expression: 0 9-17 * * 1-5 (Hourly from 9 AM to 5 PM on weekdays)

Use Case: Stay informed about price movements during active trading hours without constant manual checking.


Monthly Report Generation

Generate comprehensive monthly reports on the first day of each month.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Monthly Analytics Report",
    "description": "Generates comprehensive monthly report on the 1st of each month",
    "schedule": "0 8 1 * *",
    "scriptId": "script_monthly_report"
  }'

Cron Expression: 0 8 1 * * (First day of every month at 8:00 AM)

Use Case: Automated monthly reporting for personal analytics and productivity tracking.


Event-Based Flows

Auto-Respond to Urgent Messages

Automatically acknowledge urgent Telegram messages and create reminders.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Urgent Message Handler",
    "description": "Auto-responds to urgent messages and creates high-priority reminders",
    "eventType": "telegram.message",
    "conditions": {
      "operator": "AND",
      "conditions": [
        {
          "field": "text",
          "operator": "contains",
          "value": "urgent"
        },
        {
          "field": "isGroupChat",
          "operator": "equals",
          "value": false
        }
      ]
    },
    "scriptId": "script_telegram_auto_reply"
  }'

Trigger: Telegram direct messages containing "urgent"

Use Case: Never miss urgent messages even when busy. Automatic acknowledgment provides peace of mind to senders.


Email Ticket Creation

Automatically create tasks from emails with specific subjects.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Email to Task Converter",
    "description": "Creates tasks from emails with [TASK] in subject line",
    "eventType": "gmail.email_received",
    "conditions": {
      "field": "subject",
      "operator": "contains",
      "value": "[TASK]"
    },
    "scriptId": "script_email_task_creator"
  }'

Trigger: Emails with "[TASK]" in the subject line

Use Case: Convert emails into actionable tasks automatically, ensuring nothing falls through the cracks.


Crypto Price Alerts

Get notified when cryptocurrency prices hit specific thresholds.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "BTC Price Alert",
    "description": "Alerts when Bitcoin ticker is mentioned in Telegram",
    "eventType": "telegram.message",
    "conditions": {
      "operator": "OR",
      "conditions": [
        {
          "field": "text",
          "operator": "contains",
          "value": "$BTC"
        },
        {
          "field": "text",
          "operator": "contains",
          "value": "Bitcoin"
        }
      ]
    },
    "scriptId": "script_crypto_price_monitor"
  }'

Trigger: Telegram messages mentioning $BTC or Bitcoin

Use Case: Stay informed about cryptocurrency discussions and price movements in real-time.


Meeting Reminder Creator

Automatically create reminders before calendar events.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Pre-Meeting Reminder",
    "description": "Creates reminders 30 minutes before meetings",
    "eventType": "calendar.event_created",
    "conditions": {
      "field": "summary",
      "operator": "contains",
      "value": "Meeting"
    },
    "scriptId": "script_meeting_reminder"
  }'

Trigger: Calendar events with "Meeting" in the title

Use Case: Never be caught off-guard by meetings. Automatic reminders help you prepare.


Call Summary Logger

Log voice call summaries to memory and notify via email.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Call Summary Logger",
    "description": "Logs call summaries and sends email recap",
    "eventType": "voice.call_ended",
    "conditions": {
      "field": "duration",
      "operator": "greaterThan",
      "value": 300
    },
    "scriptId": "script_call_summary_processor"
  }'

Trigger: Voice calls longer than 5 minutes (300 seconds)

Use Case: Automatically document important calls and distribute summaries to participants.


Advanced Patterns

Multi-Condition Event Flow

Complex event filtering with nested AND/OR logic.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "VIP Message Handler",
    "description": "Special handling for messages from VIP contacts during business hours",
    "eventType": "telegram.message",
    "conditions": {
      "operator": "AND",
      "conditions": [
        {
          "operator": "OR",
          "conditions": [
            {
              "field": "sender",
              "operator": "equals",
              "value": "john_doe"
            },
            {
              "field": "sender",
              "operator": "equals",
              "value": "jane_smith"
            }
          ]
        },
        {
          "field": "isGroupChat",
          "operator": "equals",
          "value": false
        }
      ]
    },
    "scriptId": "script_vip_message_handler"
  }'

Trigger: Direct messages from specific VIP contacts

Use Case: Provide white-glove service to important contacts with automated prioritization and response.


Chained Flow Pattern

Create a flow that triggers other flows in sequence.

Step 1: Create the data collection flow

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Data Collection",
    "description": "Collects data from multiple sources",
    "schedule": "0 8 * * *",
    "scriptId": "script_data_collector"
  }'

Step 2: Create the processing flow

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Data Processing",
    "description": "Processes collected data and generates insights",
    "schedule": "30 8 * * *",
    "scriptId": "script_data_analyzer"
  }'

Use Case: Build complex multi-stage workflows by chaining flows with appropriate timing offsets.


Conditional Execution Pattern

Flow that executes different logic based on conditions.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Smart Email Router",
    "description": "Routes emails to appropriate handlers based on content",
    "eventType": "gmail.email_received",
    "conditions": {
      "field": "from",
      "operator": "contains",
      "value": "@company.com"
    },
    "scriptId": "script_email_router"
  }'

Trigger: Emails from company domain

Use Case: Intelligent email processing that adapts behavior based on email content and context.


Error Handling Pattern

Flow with robust error handling and notification.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createTimeFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Health Check with Error Handling",
    "description": "Performs health checks and notifies on failures",
    "schedule": "*/30 * * * *",
    "scriptId": "script_health_check"
  }'

Cron Expression: */30 * * * * (Every 30 minutes)

Use Case: Proactive monitoring with intelligent error handling and notifications.


Integration Patterns

Telegram to Email Bridge

Forward important Telegram messages to email.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Telegram to Email Bridge",
    "description": "Forwards tagged Telegram messages to email",
    "eventType": "telegram.message",
    "conditions": {
      "field": "text",
      "operator": "contains",
      "value": "#forward"
    },
    "scriptId": "script_telegram_to_email"
  }'

Trigger: Telegram messages containing #forward

Use Case: Selectively bridge communication between Telegram and email for archival or sharing.


Calendar to Memory Sync

Sync calendar events to searchable memory.

curl -X POST https://api.getmirra.app/api/sdk/v1/flows/createEventFlow \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Calendar to Memory Sync",
    "description": "Saves calendar events to memory for easy search",
    "eventType": "calendar.event_created",
    "conditions": {
      "field": "attendees",
      "operator": "exists",
      "value": true
    },
    "scriptId": "script_event_to_memory"
  }'

Trigger: Calendar events with attendees

Use Case: Make calendar history searchable and cross-reference meetings with other data.


Best Practices

Keep Prompts Focused

Bad: Overly complex prompt

{
  "prompt": "Do everything related to this message including analyzing sentiment, extracting entities, checking if it's spam, translating if needed, saving to 5 different locations, sending notifications via 3 channels, creating multiple types of reminders, and generating a comprehensive report"
}

Good: Focused, clear prompt

{
  "prompt": "1) Extract action items from this message, 2) Create a task in memory for each action item, 3) Send a summary via Telegram"
}

Use Descriptive Names

Bad: Generic naming

{
  "title": "Flow 1",
  "description": "Does stuff"
}

Good: Descriptive naming

{
  "title": "Daily Standup Report Generator",
  "description": "Generates team standup report every weekday at 9 AM with yesterday's completed tasks and today's plans"
}

Specify Tool Recommendations

Bad: No tool guidance

{
  "recommendedTools": []
}

Good: Relevant tools specified

{
  "recommendedTools": ["telegram", "memory", "calendar"]
}

See Also