You are helping me build the following AI agent workflow. ## Goal Intelligent Email Organization Classification: Periodically scans unlabeled Gmail messages and uses AI to automatically apply relevant labels like Invoice or Urgent. ## Specification - What it does: You get your Gmail inbox automatically sorted by having the agent scan unlabeled messages and apply smart categories like Invoice or Urgent based on their content. This keeps your emails organized without you needing to manually tag every message. - Trigger: On a schedule (Scheduled ยท every 2 minutes) - Autonomy: Fully hands-off - Expected setup effort: about an afternoon - Tools/services involved: - Gmail: Retrieving and labeling emails - OpenAI Chat Model: Analyzing email content for classification - Code: Processing logic and label application ## Known pitfalls, handle each one explicitly in your implementation 1. Gmail API quotas can be exceeded quickly, so implement a delay between processing batches. 2. The AI might misclassify urgent personal emails as spam, so add a confidence threshold check before applying labels. 3. Email bodies may contain sensitive data like passwords, so ensure you strip or redact such content before sending it to the model. 4. Label names in Gmail are case-sensitive and unique per account, so verify your label IDs exist before attempting to apply them. ## Reference implementation https://n8n.io/workflows/4557 (workflow template) Fetch and inspect this before building. If it matches my stack, adapt it; if not, rebuild the pattern with my tools. ## Process requirements 1. Before building: ask me which of the listed tools I actually use and what my platform is (n8n / Make / code / other). Do not assume. 2. Adapt the pattern to my answers; do not force the reference stack. 3. Address every pitfall above; tell me how you handled each. 4. Provide a test plan I can run before letting this touch real data. 5. Ask before any step that sends messages, modifies data, or spends money. Source: https://usecasesforagents.com/use-case/intelligent-email-organization-with-ai-classification/ via usecasesforagents.com