Parse Email Attachments with Gemini!

Ever need to extract specific information from a PDF attached to an email? You can easily parse and summarize the content of your Gmail attachments using the Generate Text with Gemini Action in zenphi!

This is the quick guide to setting up powerful document parsing directly from your inbox using a Zenphi flow:



Step 1: Set Up Your Gmail Trigger

Start by setting up your Gmail Trigger as you normally would, selecting the account you want to monitor.

When an email is received, the trigger output will include a field called Attachments. It's important to note that this field is a collection—it contains all the attachments from the email. You will notice it appears as a suggested token when you click on the token picker!


Step 2: Filter Your Attachments (Optional, but Recommended)

If you directly select the entire Attachments collection in the Gemini action's Files field, the System Instructions and Prompt will be applied to every single attachment.

To ensure you only process the files you care about (e.g., PDFs, invoices, audio files), you should add a Query Collection Action immediately after your Gmail Trigger.

  • How to Filter: Use the Query Collection action to filter the Attachments collection. For example, to select only PDF files, you can filter for files where the Mime Type property is equal to application/pdf. You can also filter by File Name, lets say only files that contain the word Invoice!


Step 3: Add the Generate Text with Gemini Action

Now, add the Generate Text with Gemini Action to your zenphi flow.

In the action's Files field, make sure to select either:

  1. The output of your Query Collection action (if you filtered the files).

  2. The Attachments field from the Gmail trigger (if you want to process all files).

Gemini will then analyze the content of the attached file(s) based on your instructions!


✨ Pro Tip: Crafting the Perfect Prompt for Parsing

The key to successful parsing is a properly curated System Instruction and Prompt text. Be specific about the output format you need (e.g., JSON object, a summary, a collection).

For best practices on how to get the most accurate results using System Instructions and Prompts for your parsing tasks, refer to our previous post: Zenphi Tip: Mastering the Generate Text with Gemini Action.