Accessing Email Data and Attachments in Agent Triggered by Email

I can trigger an agent via email, but I can’t figure out how to access the email’s data inside the agent. I'm unable to find it in the docs, and the copilot doesn’t seem to know this trigger method even exists. :sweat_smile:

Additionally, I want to attach files to the trigger emails and have the agent process them. Is that possible? Does the agent have access to email attachments?

For context, my goal is to:
Build an agent that checks the contents of a few files (ideally provided via email, as attachments), makes some API calls to pull extra data, and—if everything looks good—uploads the files to an endpoint.

Thanks!

1 Like

Hi there @Piny,

From what the Retool team has told me, the agent is not able (yet) to parse documents neither from the email nor the chat. The suggested workaround now is to work with retool storage.

I too had as a first use case an agent that analyzes files from emails... but I'll guess we will have to wait for retool to release this.

Hi @MiguelOrtiz :wave:

I really appreciate the reply! I guess until Retool ships this functionality, I'll have to go with a workaround.

Cloudflare + Workers it is then :smiley:

Thanks!

The first part of my question remains though: How do I access the text content inside the email? Is that possible?

I'd like to be able to reference the email body, sender details, etc.

Thanks!

Hey @Piny - when you invoke an agent via email, the body and sender are all passed into the first message to the agent:

From: {emailData.from}
Cc: {emailData.Cc} (if present)
To: {other recipients} (if present, excluding the agent email)
Subject: {emailData.subject}
Message-Id: {emailData['Message-Id']}

{emailData['stripped-text']}

In your agent instructions you could reference these things, and the agent will have them in context. Here's an example of me emailing an agent and asking what it was invoked with:

Let me know if you have additional questions!

Thank you, Kent! That is super helpful (especially the trick about asking the agent what data it got)

Please consider adding this info to https://docs.retool.com/agents/guides/trigger-with-email or https://docs.retool.com/agents/reference

Thanks again!

A post was split to a new topic: How can I ensure an agent sends a response when triggered by email