Unread Message Processor
Mark as read the emails that are required.
+3
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
ParseData-ptp7g[<div><img alt="logo" src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Datos]
style ParseData-ptp7g stroke:#a170ff
Prompt-7qn0s[<div><img alt="logo" src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Consulta]
style Prompt-7qn0s stroke:#a170ff
OpenAIModel-kx9h5[<div><img alt="logo" src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-kx9h5 stroke:#a170ff
ChatOutput-ugeve[<div><img alt="logo" src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-ugeve stroke:#a170ff
GmailMesageComponent-riqjp[<div><img alt="logo" src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Mensajes]
style GmailMesageComponent-riqjp stroke:#a170ff
GmailMesageComponent-1gc2u[<div><img alt="logo" src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Marcar como leído]
style GmailMesageComponent-1gc2u stroke:#a170ff
TextInput-1cb9o[<div><img alt="logo" src="/_astro/type.Dy26vmDy.svg" style="height: 20px !important;width: 20px !important"/></div>Tema a comprobar]
style TextInput-1cb9o stroke:#a170ff
AdvancedAgent-csduv[Agent2]
style AdvancedAgent-csduv stroke:#a170ff
GmailMesageComponent-riqjp -.- ParseData-ptp7g
linkStyle 0 stroke:#a170ff
ParseData-ptp7g -.- Prompt-7qn0s
linkStyle 1 stroke:#a170ff
TextInput-1cb9o -.- Prompt-7qn0s
linkStyle 2 stroke:#a170ff
Prompt-7qn0s -.- AdvancedAgent-csduv
linkStyle 3 stroke:#a170ff
AdvancedAgent-csduv -.- ChatOutput-ugeve
linkStyle 4 stroke:#a170ff
OpenAIModel-kx9h5 -.- AdvancedAgent-csduv
linkStyle 5 stroke:#a170ff
GmailMesageComponent-1gc2u -.- AdvancedAgent-csduv
linkStyle 6 stroke:#a170ff
🧩 Unread Message Processor
Overview
The Unread Message Processor streamlines the handling of unread emails by automatically retrieving messages that match a user‑defined query, parsing their content into a readable format, and leveraging an AI agent to decide which messages should be marked as read. The workflow uses a GPT‑powered agent that can interact with Gmail via a dedicated tool, finally presenting the agent’s decision in the Playground chat interface.
⚙️ Main Features
- Retrieves Gmail messages that satisfy a user‑defined query.
- Converts raw email data into structured plain text using a custom template.
- Builds a prompt that contains the email list and the user‑specified topic.
- Employs a GPT‑4 language model to determine which messages to mark as read.
- Calls a Gmail tool to mark the selected messages as read.
- Displays the AI’s final response in a chat‑style output.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Text Input | Captures the topic to filter emails (e.g., “LinkedIn”). | Text (topic) | Text message containing the topic |
| Gmail Message Component | Fetches Gmail messages that match the query and returns raw email data. | Query string (“LinkedIn”), Gmail credentials, number of emails | Raw email data (Data) |
| Parse Data | Formats each email into a plain‑text representation based on a template. | Raw email data | Structured text of emails |
| Prompt | Constructs the prompt that will be fed to the agent, embedding the list of emails and the topic. | Structured email text, topic | Prompt message |
| OpenAI Model | Provides the language model that powers the agent’s reasoning. | Model selection (e.g., GPT‑4.1), API credentials | LanguageModel instance |
| Advanced Agent | Executes the main decision logic, using the prompt, the language model, and the Gmail tool. | Prompt, LanguageModel, Gmail tool | Response message |
| Gmail Message Component | Marks the chosen emails as read via the tool exposed by the agent. | List of email IDs to mark, Gmail credentials | Confirmation data |
| Chat Output | Displays the agent’s response in the Playground chat window. | Response message | Chat message shown to the user |
🧠 Notes
- The workflow requires valid Gmail API credentials for both the retrieval and marking tools.
- An OpenAI API key is mandatory for the language model component.
- The prompt template expects a list of emails; if no emails match the query, the agent will handle the empty case gracefully.
- The agent’s decision logic can be tuned via the system prompt and the structured output schema, if needed.
- The Gmail marking tool operates only on the emails returned in the retrieval step; it does not affect other messages.
- The chat output component displays the agent’s final decision in a conversational format, suitable for immediate review.