Multi-Condition Filter
What it does: Passes events only when they satisfy a combination of conditions: weekday timing, business hours, attendee requirements, and keyword exclusions.
Use case: Build a precise gate when a single condition is not enough — for example, syncing only confirmed weekday work meetings that include at least one colleague and are not marked as personal.
function gate(event: GateEvent): GateResult {
// Condition 1: Only weekday events
if (!event.isWeekday) {
return { pass: false, reason: 'Event is on a weekend' };
}
// Condition 2: Only during business hours (9 AM – 5 PM)
if (event.hour < 9 || event.hour >= 17) {
return { pass: false, reason: 'Event is outside business hours' };
}
// Condition 3: Must have at least 2 attendees OR be tagged as important
if (event.attendeeCount < 2 && !event.matches('important')) {
return { pass: false, reason: 'No attendees and not flagged as important' };
}
// Condition 4: Exclude personal events
if (event.matches('personal') || event.matches('private')) {
return { pass: false, reason: 'Event is personal' };
}
return { pass: true };
}
How It Works
Each condition is evaluated in sequence. The first condition that fails causes the gate to return pass: false with a specific reason, which helps with debugging in the Code Editor. If the event passes all conditions, it is synced. Using early returns keeps the logic flat and easy to read.
The recipe uses several GateEvent properties:
isWeekday— computed fromdayOfWeekhour— the event's start hour (0–23)attendeeCount— the number of attendeesmatches()— case-insensitive search in title and description
Customization
Add a status check to exclude cancellations:
function gate(event: GateEvent): GateResult {
if (event.status === 'cancelled') {
return { pass: false, reason: 'Cancelled event' };
}
if (!event.isWeekday) {
return { pass: false, reason: 'Weekend event' };
}
if (event.hour < 9 || event.hour >= 17) {
return { pass: false, reason: 'Outside business hours' };
}
return { pass: true };
}
Loosen conditions with OR logic:
function gate(event: GateEvent): GateResult {
// Pass if it matches any approved keyword OR has company attendees
if (event.matches('standup') || event.matches('sync') || event.hasAttendee('@company.com')) {
return { pass: true };
}
return { pass: false, reason: 'Event does not meet approval criteria' };
}
Related Recipes
- Block by Keyword -- Keyword-only blocking
- Business Hours Only -- Time-based filtering
- Filter by Attendee Count -- Attendee-based filtering