Define complex filters using Jsonnet nesting
masterYou can create sophisticated Gmail filters by nesting logical operators like and, or, and not within your Jsonnet configuration. This allows you to combine multiple criteria (such as from, to, subject, or has) into a single rule. Note that while Jsonnet provides structure, the underlying logic ultimately maps to Gmail search expressions.
local me = 'pippo@gmail.com';
local spam = {
or: [
{ from: 'foo@gmail.com' },
{ from: 'bar@hotmail.com' },
{ subject: 'buy this' },
{ subject: 'buy that' },
],
};
{
version: 'v1alpha3',
rules: [
{
filter: {
and: [
{ to: me },
{ from: 'friend@mail.com' },
{ not: spam },
],
},
actions: { delete: true },
},
],
}