I need help fixing an n8n AI agent workflow

I need help fixing an n8n AI agent workflow.

Current setup:

  • Chat trigger
  • Anthropic Claude LLM
  • Google Docs create/update
  • Google Sheets memory
  • Content is created and saved to Google Docs
  • Project memory is partially built in Google Sheets

Goal:
When I type “rate it,” “continue,” “improve it,” or “repurpose it,” the workflow should retrieve the most recent Google Doc from AI_CURRENT_PROJECT, read the content, and send it to Claude for analysis.

Need someone who can:

  • Diagnose the current workflow
  • Fix routing without overcomplicating it
  • Connect current project memory correctly
  • Make the agent remember last outputs
  • Keep workflow simple and stable

That sounds like a state-pointer issue, not a Claude problem. Keep it to one field that tells the workflow “the current doc for this project is X” and one field for the last generated output; otherwise “continue” and “improve it” will keep guessing from Sheets history.

Before anyone rewires it, what does AI_CURRENT_PROJECT look like right now: one row per project with a Google Doc ID, or a running log of every output?

+1 to oimrqs_ops - this is a state/routing problem, not a Claude problem. Two fixes will make it simple and stable:

  1. Make AI_CURRENT_PROJECT a single-row pointer, not a log. One row per project with columns like: project_name, current_doc_id, last_output. Don’t store a running history here - that’s what keeps making it “guess.” When you generate a new doc, you OVERWRITE current_doc_id; when Claude responds you OVERWRITE last_output. That’s your whole memory.

  2. Route with a Switch node, not the LLM. Right after the Chat Trigger, add a Set/Edit Fields node that lowercases the message, then a Switch on keywords (rate / continue / improve / repurpose). Deterministic routing = no more guessing. Use Claude only for the analysis step, never for deciding what to do.

Clean flow:

Chat Trigger → Set (parse command) → Switch (by keyword)

→ Google Sheets: Get row (read current_doc_id + last_output)

→ Google Docs: Get document (by that id)

→ Anthropic Claude (analyze / improve / repurpose, fed the doc text + last_output)

→ Google Docs: Update (or create new) → Google Sheets: Update row (write new current_doc_id + last_output)

Key points:

  • “continue” and “improve” should read last_output from the pointer row, not re-scan history.
    • If you create a brand-new doc, update current_doc_id in the same run so the next command points at the right one.
      • Keep the Sheet to one authoritative row per project; if you want history, log it to a SEPARATE sheet the agent never reads.
    • That removes the ambiguity entirely - the agent always knows “the current doc is X” because there’s exactly one place that says so.

Hey @Julio1

I’ve fixed almost the same setup recently — n8n agent with Claude, Google Docs output, and Sheets-based project memory that needed proper command routing and document retrieval logic

  • Diagnose the current workflow and pinpoint where routing/memory breaks

  • Wire trigger commands (“rate it,” “continue,” “improve it,” “repurpose it”) to the correct branches

  • Pull the most recent Google Doc from AI_CURRENT_PROJECT and pass full content to Claude

  • Fix Sheets’ memory so the agent remembers last outputs across sessions

  • Keep the workflow lean — no unnecessary nodes, stable and easy to maintain

    Let’s schedule a call to discuss the details further.

@Julio1 Managing complex state-pointer issues and memory integration in n8n can be tricky, but keeping your workflow architecture modular—especially when syncing with Google Sheets and Docs—is the key to long-term stability. If you’re struggling to simplify this flow or need an optimized, production-ready version, feel free to reach out; I specialize in building stable, memory-efficient AI agents for agencies.

Thanks. I was able to get it done.

Hi, I saw the n8n AI agent workflow issue. This looks like a good fit for a contained first milestone: not rebuilding the whole system, but fixing the current routing and memory behavior so the agent can reliably work with the latest Google Doc.

A practical first step would be to diagnose the existing workflow, confirm how AI_CURRENT_PROJECT and Google Sheets memory should behave, then fix one proof path around “rate it”, “continue”, “improve it”, or “repurpose it” before expanding anything else.

Happy to share a scoped first-milestone quote after confirming two details:

1. Which exact workflow should the first milestone automate end to end?
2. What systems, access, and success criteria should be confirmed before implementation?

For context, my LinkedIn profile is here: https://www.linkedin.com/in/karimgamal-dk/