
Connecting the Dots: How to Pass Data from a Trigger to an Action
In the previous section, we established the fundamental roles of Triggers and Actions—the "if this" and "then that" of our automated workflows. A trigger initiates a process, and an action carries it out. But this leaves a critical question unanswered: how does the action know what to do? If a new email triggers a workflow, how does the subsequent action know the sender, the subject line, or the content of that specific email? Without this connection, our automations would be like a front desk clerk who knows a guest has arrived but has no idea who they are or what they need.
This is where we bridge the gap. This section is dedicated to the single most important concept for creating dynamic, intelligent workflows: passing data from a trigger to an action. Mastering this will elevate your automations from simple on/off switches to sophisticated assistants that respond intelligently to the context of each event.
The magic behind this data transfer is a concept called the "event object." Think of it as a special data package, automatically generated and delivered by Google Workspace Studio the moment a trigger fires. This package isn't empty; it's filled with valuable, structured information about the event that just occurred. It’s the context.
For example, when you set up a workflow to trigger on every new email received in Gmail, the event object contains details like:
- The sender's email address and name.
- The recipient list (To, Cc, and Bcc).
- The exact subject line of the message.
- The full body of the email, in both plain text and HTML formats.
- A list of any attachments, including their names and file types.
- The unique ID of the message and the thread it belongs to.
Similarly, if your trigger is a new event being created in Google Calendar, the event object would carry the event's title, start time, end time, guest list, and location. Every type of trigger generates an event object tailored to its specific context, providing the raw materials your actions will use.
graph TD
A[Trigger<br/><em>e.g., New email arrives</em>] -->|Generates a| B{Event Object 'e'};
B -->|Contains data like<br/>'e.message.getSubject()'| C[Action<br/><em>e.g., Add row to a Sheet</em>];
B -->|Contains data like<br/>'e.message.getPlainBody()'| C;
style B fill:#f9f,stroke:#333,stroke-width:2px
So, how do we unwrap this data package and use its contents? In Workspace Studio (and in the underlying Google Apps Script), this event object is typically passed as an argument to your function, often named e by convention. You then access the specific pieces of information inside it using "dot notation."