Script Events
Event-driven scripts automatically execute when specific events occur in your Mirra account. This system enables powerful automation workflows that respond to messages, calendar events, document changes, and more.
Event System Overview
The Mirra event system allows scripts to subscribe to specific event types with optional filtering conditions. When an event matches the subscription criteria, the script executes automatically with the event data passed as the event parameter.
Event Structure
All events follow a standardized structure with common fields:
Creating Event Subscriptions
Endpoint
Basic Subscription
Subscribe to all events of a specific type:
Filtered Subscription
Subscribe only to events matching specific conditions:
Condition Operators
equals- Exact matchnot_equals- Not equal to valuecontains- String contains substringnot_contains- String does not contain substringstarts_with- String starts with valueends_with- String ends with valuegreater_than- Numeric greater thanless_than- Numeric less thanexists- Field exists and is not nullnot_exists- Field does not exist or is null
Event Handler Pattern
Basic Handler
Type-Specific Handler
Available Event Types
Telegram Events
telegram.message - New message received
Gmail Events
gmail.message_received - New email received
Calendar Events
calendar.event_created - New calendar event created
calendar.event_updated - Calendar event modified
calendar.event_deleted - Calendar event removed
Voice Call Events
voice.call_started - Voice call initiated
voice.call_ended - Voice call completed
Document Events
docs.document_created - Google Doc created
docs.document_updated - Google Doc modified
drive.file_created - Google Drive file added
drive.file_updated - Google Drive file modified
sheets.spreadsheet_updated - Google Sheets modified
Crypto Events
crypto.price_alert - Price threshold crossed
Advanced Filtering
Multiple Conditions
Combine multiple conditions (AND logic):
Field Paths
Use dot notation to access nested fields:
Best Practices
Event Filtering
- Filter early: Use subscription conditions instead of filtering in code
- Be specific: Narrow subscriptions to reduce unnecessary executions
- Test filters: Verify conditions match expected events before deployment
Error Handling
Performance
- Keep handlers fast: Event handlers should complete quickly (< 5 seconds)
- Use async operations: Don't block on long-running tasks
- Batch when possible: Aggregate multiple events before processing
- Monitor execution: Track success rates and error patterns
Debugging Event Subscriptions
Test Event Delivery
Manually trigger an event subscription to test your handler:
View Subscription Logs
Check execution history for event-triggered runs:
See Also
- Overview - Script concepts and runtimes
- Endpoints - Complete API reference
- Examples - Event-driven code examples
- Technical Notes - Configuration and limits