
Step 2 (The AI Step): Extracting Key Information from the Email Body
In the last section, we successfully set up a trigger, the essential starting gun for our workflow. We've essentially told Google Workspace Studio, "Hey, pay attention! A new email just arrived that matches our criteria." This is a crucial first step, but it's only half the story. The trigger hands our workflow a bundle of raw data—the entire email—and now we face the most common challenge in automation: the information we actually need is buried inside a block of unstructured, conversational text.
This is where the real power of modern workflow automation shines. We don't just want the whole email; we want specific pieces of information from it, like a customer's name, an order number, or a company name. Our Google Sheet needs clean, organized data in columns, not a messy paragraph. How do we bridge this gap? This is the AI step.
Step 2 (The AI Step): Extracting Key Information from the Email Body
The core task here is to transform unstructured data (the free-form text of an email) into structured data (a predictable format with clearly defined fields). Before tools like Workspace Studio, this required complex scripts, fragile text-parsing rules, or tedious manual copy-pasting. Now, we can achieve this by simply describing what we want to an AI model in plain English.
This process is called data extraction, and we'll accomplish it by writing a 'prompt'. A prompt is a set of instructions you give to the AI model. Think of it as briefing a highly intelligent but very literal assistant. The quality of your instructions directly determines the quality of the result.
Let's use our example of logging new sales leads. An email might arrive saying, "Hello, my name is Jane Doe and I work at Example Corp. I'd love to get a quote. You can reach me at jane.d@examplecorp.com." For our spreadsheet, we need three distinct pieces of data: "Jane Doe", "Example Corp", and "jane.d@examplecorp.com".
A well-structured prompt for this kind of data extraction typically has three parts:
-
Context & Role: Tell the AI what it is and what kind of data it's handling. For example, "You are an assistant processing a new sales lead from an email body."
-
The Task: Be explicit about what you want it to find. "Extract the full name, the company name, and the email address of the person."
-
Output Format Specification: This is the most critical part for automation. You must tell the AI exactly how to present the extracted information. The best practice is to request the output in JSON (JavaScript Object Notation), a universal standard for structured data. This ensures the output is predictable and easy for the next steps in our workflow to use.
Here is a practical example of what a complete prompt would look like inside the AI action in Workspace Studio. The {{trigger.body}} is a special placeholder, known as a variable, that Workspace Studio will automatically replace with the actual body of the email that triggered the workflow.