Processor of unwanted threads as scrap
Based on incoming emails, unwanted threads are discarded.
+3
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
GmailMesageComponent-2262z[<div><img src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Mensajes]
style GmailMesageComponent-2262z stroke:#a170ff
ParseData-dkr4x[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Datos 1]
style ParseData-dkr4x stroke:#a170ff
Prompt-qroxz[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Consulta 1]
style Prompt-qroxz stroke:#a170ff
OpenAIModel-iocjj[<div><img src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-iocjj stroke:#a170ff
GmailThreadComponent-siyju[<div><img src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Declarar hilo como deshecho]
style GmailThreadComponent-siyju stroke:#a170ff
ParseData-9csmb[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Obtener Datos 2]
style ParseData-9csmb stroke:#a170ff
Prompt-k0mn8[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Consulta 2]
style Prompt-k0mn8 stroke:#a170ff
OpenAIModel-544uh[<div><img src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI2]
style OpenAIModel-544uh stroke:#a170ff
ChatOutput-aamor[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-aamor stroke:#a170ff
TextInput-qers6[<div><img src="/_astro/type.Dy26vmDy.svg" style="height: 20px !important;width: 20px !important"/></div>Tema a comprobar]
style TextInput-qers6 stroke:#a170ff
GmailMesageComponent-2262z -.- ParseData-dkr4x
linkStyle 0 stroke:#a170ff
ParseData-dkr4x -.- Prompt-qroxz
linkStyle 1 stroke:#a170ff
Prompt-qroxz -.- OpenAIModel-iocjj
linkStyle 2 stroke:#a170ff
GmailThreadComponent-siyju -.- ParseData-9csmb
linkStyle 3 stroke:#a170ff
ParseData-9csmb -.- Prompt-k0mn8
linkStyle 4 stroke:#a170ff
Prompt-k0mn8 -.- OpenAIModel-544uh
linkStyle 5 stroke:#a170ff
OpenAIModel-544uh -.- ChatOutput-aamor
linkStyle 6 stroke:#a170ff
OpenAIModel-iocjj -.- GmailThreadComponent-siyju
linkStyle 7 stroke:#a170ff
TextInput-qers6 -.- Prompt-qroxz
linkStyle 8 stroke:#a170ff
📄 Processor of Unwanted Threads as Scrap
🧩 Overview
This workflow automates the detection and disposal of unwanted Gmail conversation threads.
It first identifies threads that match a user‑defined subject, marks them as trash, and then produces a concise list of the discarded threads for review.
⚙️ Main Features
- Allows the user to specify a keyword or subject fragment to search for.
- Uses a language model to extract the thread ID that matches the query.
- Deletes or moves the identified thread to the trash label.
- Retrieves all inbox messages, formats them into plain text, and parses the data.
- Generates a human‑readable summary of the threads that were discarded.
- Presents the summary in a chat‑style output for quick review.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Tema a comprobar | Receives the subject keyword or phrase to filter emails. | Text input from the user. | Text containing the search keyword. |
| Consulta 1 | Builds a prompt that requests the thread ID for the specified subject. | Text from Tema a comprobar and list of emails. | Prompt message for the language model. |
| OpenAI | Executes the prompt, returning the thread ID in plain text. | Prompt message. | Thread ID (text). |
| Declarar hilo como deshecho | Uses the thread ID to move the corresponding thread to the trash. | Thread ID from OpenAI. | Confirmation of thread action. |
| Obtener Mensajes | Pulls messages from the Gmail inbox (up to the defined limit). | No external input; operates on Gmail account. | Raw message data. |
| Obtener Datos 1 | Formats the raw messages into a readable string according to a template. | Raw message data. | Structured text representation of emails. |
| Consulta 2 | Builds a prompt to list the emails that were discarded. | Structured text from Obtener Datos 1. | Prompt message for the language model. |
| OpenAI2 | Processes the prompt and returns a formatted list of discarded threads. | Prompt message. | Summarised list of discarded threads (text). |
| Chat Output | Displays the final summary in a chat‑style interface. | Summarised text from OpenAI2. | Visible chat message to the user. |
🧠 Notes
- The workflow requires valid Gmail and OpenAI credentials; these must be configured in the respective components.
- The thread deletion step will only succeed if the extracted thread ID corresponds to an existing conversation.
- The parsing template in Obtener Datos 1 assumes that email fields such as
sender,subject, andthread_idexist; adjust the template if Gmail returns different field names. - The language model is invoked twice, once for ID extraction and once for summarisation; token limits and cost should be monitored.
- The chat output is purely for display; it does not alter any data in Gmail beyond the thread deletion step.