Unread Messages Processor
Mark as read the emails that are required.
+3
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
ParseData-ptp7g[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Datos]
style ParseData-ptp7g stroke:#a170ff
Prompt-7qn0s[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Consulta]
style Prompt-7qn0s stroke:#a170ff
LanggraphReactAgent-1wsn2[Agent]
style LanggraphReactAgent-1wsn2 stroke:#a170ff
OpenAIModel-kx9h5[<div><img src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-kx9h5 stroke:#a170ff
ChatOutput-ugeve[<div><img 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 src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Mensajes]
style GmailMesageComponent-riqjp stroke:#a170ff
GmailMesageComponent-1gc2u[<div><img 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 src="/_astro/type.Dy26vmDy.svg" style="height: 20px !important;width: 20px !important"/></div>Tema a comprobar]
style TextInput-1cb9o stroke:#a170ff
Prompt-7qn0s -.- LanggraphReactAgent-1wsn2
linkStyle 0 stroke:#a170ff
OpenAIModel-kx9h5 -.- LanggraphReactAgent-1wsn2
linkStyle 1 stroke:#a170ff
LanggraphReactAgent-1wsn2 -.- ChatOutput-ugeve
linkStyle 2 stroke:#a170ff
GmailMesageComponent-riqjp -.- ParseData-ptp7g
linkStyle 3 stroke:#a170ff
GmailMesageComponent-1gc2u -.- LanggraphReactAgent-1wsn2
linkStyle 4 stroke:#a170ff
ParseData-ptp7g -.- Prompt-7qn0s
linkStyle 5 stroke:#a170ff
TextInput-1cb9o -.- Prompt-7qn0s
linkStyle 6 stroke:#a170ff
📄 Unread Messages Processor
🧩 Overview
The workflow automates the detection and marking of Gmail messages as read based on a user‑defined topic. It pulls recent emails that match a specified query, formats the email content for the assistant, and then lets a language‑model‑powered agent decide which messages to mark. The process is fully automated and requires no manual intervention beyond providing the topic.
⚙️ Main Features
- Topic‑driven email retrieval – fetches recent Gmail messages filtered by a search query.
- Data formatting – transforms raw email data into a readable text list for the assistant.
- Prompt construction – builds a dynamic instruction that includes the email list and topic.
- LLM reasoning – a pre‑built Langgraph React Agent interprets the prompt and determines which messages to mark.
- Gmail action tool – the agent can invoke the Gmail tool to update message labels (mark as read).
- Chat‑style output – the final decision is displayed as a chat message in the playground.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Text Input | Provides the topic that the assistant should look for in the inbox. | Topic text (e.g., “LinkedIn”) | Text string “LinkedIn” |
| Gmail Message Component (Get Messages) | Retrieves recent emails from Gmail that match the query and label. | Gmail credentials, query string, number of emails to read | Raw email data (Data) |
| Parse Data | Converts the raw email data into a plain‑text list using a template. | Raw email data | Formatted email list (Message) |
| Prompt | Builds a dynamic instruction that contains the email list and the topic. | Email list, topic | Prompt message (Message) |
| OpenAI Model | Supplies the language model that the agent will use. | LLM configuration (model name, credentials) | Language model instance |
| Langgraph React Agent | Orchestrates the conversation, interprets the prompt, and calls the Gmail tool when needed. | Prompt message, LLM instance, Gmail tool (Mark as Read) | Agent response (Message) |
| Chat Output | Presents the agent’s final answer in a chat‑style interface. | Agent response | Chat message displayed to the user |
🧠 Notes
- The workflow relies on Gmail API credentials and OpenAI API credentials that must be provisioned beforehand.
- Only the latest 20 emails (or the number specified) are retrieved; older messages are ignored unless the query changes.
- The agent is limited to the “Mark as Read” tool; it cannot modify other labels or delete messages.
- The system handles up to a maximum of 10 iterations per agent run, preventing runaway loops.
- The prompt template is static; any changes to the instruction format require updating the Prompt component.
- Error handling is built into the agent’s fallback model, ensuring graceful degradation if the primary model fails.
- This workflow is intended for use in a playground environment where chat outputs can be visualised; it can be adapted to other interfaces by replacing the Chat Output component.