Domain Whitelist
What it does: Checks the attendee list against a defined set of approved domains and only passes events that include at least one attendee from those domains.
Use case: Only sync meetings that involve people from your own organization or approved partner organizations, filtering out external or unknown contacts automatically.
function gate(event: GateEvent): GateResult {
const allowedDomains = ['company.com', 'partner.org', 'contractor.io'];
const hasApprovedAttendee = event.attendees.some((attendee) =>
allowedDomains.some((domain) => attendee.email.endsWith(`@${domain}`))
);
if (!hasApprovedAttendee) {
return { pass: false, reason: 'No attendees from approved domains' };
}
return { pass: true };
}
How It Works
Unlike the simpler hasAttendee() helper, this recipe uses event.attendees.some() to iterate directly over the attendees array and check each email against a list of allowed domains. String.endsWith() ensures the match is at the domain boundary (e.g. @company.com matches alice@company.com but not alias-company.com). If no attendee matches any allowed domain, the event is blocked.
Customization
Switch to a blocklist (block events with any attendee from a disallowed domain):
function gate(event: GateEvent): GateResult {
const blockedDomains = ['competitor.com', 'spam.org'];
const hasBlockedAttendee = event.attendees.some((attendee) =>
blockedDomains.some((domain) => attendee.email.endsWith(`@${domain}`))
);
if (hasBlockedAttendee) {
return { pass: false, reason: 'Event includes an attendee from a blocked domain' };
}
return { pass: true };
}
Separate internal from contractor events:
function gate(event: GateEvent): GateResult {
const internalDomains = ['company.com'];
const contractorDomains = ['contractor.io', 'agency.co'];
const hasInternal = event.attendees.some((a) =>
internalDomains.some((d) => a.email.endsWith(`@${d}`))
);
const hasContractor = event.attendees.some((a) =>
contractorDomains.some((d) => a.email.endsWith(`@${d}`))
);
if (hasInternal && hasContractor) {
return { pass: true, transform: { title: `[External] ${event.title}` } };
}
return { pass: true };
}
Related Recipes
- Filter by Attendee Domain -- Simpler single-domain check using
hasAttendee() - Multi-Condition Filter -- Combine domain filtering with other conditions