List Gmail Filters

Definition

The List Gmail Filters action retrieves a list of filters set up within a specific Gmail account, providing details on how emails are processed, categorized, and managed by the filter system. This action allows administrators to view the rules configured in a user's Gmail account, such as specific conditions like sender, subject, or message size, and what actions are applied, such as forwarding or applying labels. It is essential for auditing, monitoring, and managing email automation, especially when users have complex filtering rules.


Example Use Cases

1. Auditing Email Filtering Rules

An IT admin can use this action to regularly review Gmail filters set by users, ensuring that no sensitive or important emails are being incorrectly routed or filtered out.

2. Migrating Email Filters

When transitioning users to a new email system or account, administrators can retrieve existing Gmail filters and replicate them in the new account, ensuring a seamless migration without losing any email organization settings.

3. Managing Corporate Email Policies

A company can automate a process to check for filters that may conflict with corporate email policies, such as forwarding business emails to external addresses or certain labels being applied to sensitive content.

4. Troubleshooting Email Delivery Issues

If users report missing emails, admins can use this action to verify if any filters might be inadvertently redirecting or archiving emails that are crucial to the user's workflow.

5. Generating Reports on Email Organization

For compliance or operational reviews, admins can generate a report showing all filters applied to employees’ Gmail accounts, helping to monitor and optimize email management practices.


Inputs

Connection

The authenticated Google Workspace Administration connection used to access Gmail account data.

  • Explanation: You must provide a Google Workspace Administration connection that includes a credential JSON file for a service account with domain-wide delegation enabled.
  • Guide: Follow this guide to create the connection.
  • Best Practices:
    • Ensure the service account has the necessary scopes (e.g., https://www.googleapis.com/auth/gmail.settings.basic).
    • Keep the credential file secure and rotate it periodically to enhance security.

User Email

The email address of the Gmail account whose filters you want to retrieve.

  • Explanation: Enter the full email address (e.g., [email protected]) of the user whose Gmail filters you wish to list.
  • Best Practices:
    • Verify the user has Gmail filters set up to ensure meaningful results.

Outputs

The action returns a list of items, where each item corresponds to a filter set in the specified Gmail account. Each item contains the following fields:

Id

The unique identifier assigned by the Gmail server for the filter.

  • Explanation: This ID helps uniquely identify and reference the filter within Gmail, useful for further actions like editing or deleting the filter.
  • Example: abc123xyz

From

The email address or display name of the sender condition.

  • Explanation: This field shows the sender's email or display name that the filter is applied to. It’s part of the filter’s condition to determine which incoming emails are affected.
  • Example: [email protected]

To

The email address or display name of the recipient condition.

  • Explanation: This field shows the recipient’s email address or display name that the filter applies to. It defines who the filter is targeting for a specific recipient.
  • Example: [email protected]

Subject

A phrase or keywords found in the subject line of the message.

  • Explanation: This field contains the specific subject phrase the filter is looking for to apply actions like labeling or forwarding. It's case-insensitive and trims spaces.
  • Example: Meeting Invitation

Has the Words

A query that specifies the words the filter looks for in the email content.

  • Explanation: This condition allows the filter to look for specific words or phrases within the body of the email, using the same query format as Gmail’s search box.
  • Example: project report

Doesn't Have

A query that specifies the words the filter checks to ensure are not present in the email.

  • Explanation: This condition works in the opposite way to "Has the Words"—it excludes emails that match certain words or phrases.
  • Example: spam, promotional

Size

The size (in bytes) of the entire email message, including headers and attachments.

  • Explanation: This field allows the filter to apply conditions based on the size of the email message, such as filtering large attachments.
  • Example: 1000000 (for a 1 MB email)

Size Comparison

Defines how the email size should be compared to the Size field.

  • Explanation: This field specifies whether the size must be greater than, less than, or exactly the size specified in the Size field.
  • Example: greater_than

Has Attachment

Indicates whether the email contains any attachments.

  • Explanation: This field returns true if the email has attachments and false if it doesn’t.
  • Example: true

Forward

The email address to which the message should be forwarded.

  • Explanation: If the filter is set to forward emails, this field specifies the forwarding email address.
  • Example: [email protected]

Add Labels

A list of labels to add to the email.

  • Explanation: This field shows the labels that the filter will apply to the email. It can be used to categorize emails based on the filter conditions.
  • Example: ["Important", "Work"]

Remove Labels

A list of labels to remove from the email.

  • Explanation: This field lists labels that the filter will remove from the email if they’re applied.
  • Example: ["Spam"]

Example Scenario

Situation:
An IT administrator needs to review and audit the Gmail filters set by employees in the organization to ensure that email management follows company guidelines. Specifically, the admin is concerned about filters that automatically forward sensitive company emails to personal accounts or add labels that could be misused.

Solution Using Zenphi:
The administrator configures the List Gmail Filters action in Zenphi with the following steps:

  1. Connection: They set up the Google Workspace Administration connection using the proper credentials.
  2. User Email: They enter the email address of an employee, e.g., [email protected], whose Gmail filters they want to review.

Once the flow runs, the admin receives a list of all filters applied to that user’s Gmail account, including details like the filter conditions (e.g., subject, size, attachments) and actions (e.g., forwarding, labeling). The admin uses this list to quickly identify any filters that might be forwarding sensitive emails or misclassifying messages, allowing them to take action to ensure compliance with internal email policies.