Logic for "Search-First" Google Drive folders & Human Intervention check (fromMe)

Hello everyone,

I’m building a legal automation workflow and I need help structuring two specific logic gates:

1. “Search-First” Google Drive Logic: Before creating a new folder for a client, the workflow must search for an existing folder by the client’s name in two specific parent directories (IDs: 1q_UXjaA-_N60YtoXgZdLEUWxjYo21Edi and 1dIsiCuhMpPxaNhetz-10GwLmfsaCttxo).

  • If found: Extract the folderId.

  • If NOT found: Create a new folder and get the folderId.

  • Next Step: Update/Insert a Google Sheet row with the client name and the correct folderId.

2. Human Intervention Shield (Evolution API): To prevent the bot from “stepping on the toes” of the lawyer responding manually:

  • Identify if a message is sent by the user (data.key.fromMe == true).

  • If True: Update a Google Sheet cell with the current timestamp.

  • If False (Incoming): Check if the last human interaction was less than 30 minutes ago. If so, I want the workflow to Stop/Cancel execution immediately so the bot remains silent during a manual conversation.

My Setup:

  • n8n version: 2.13.3 (Self-hosted / Docker)

  • Database: PostgreSQL 16.4

  • Authentication: Google OAuth2

  • Trigger: Evolution API (WhatsApp Webhook)

Could anyone point me to the best nodes or expressions to handle the folder search across multiple parents and the time-based filter?

for the search-first logic, id use the HTTP Request node to query the Google Drive API directly rather than the built-in search node — more control over the query. hit /files?q=name='Client Name' and parents in ('PARENT_ID_1','PARENT_ID_2') and mimeType='application/vnd.google-apps.folder' and iterate through the results. if empty, create new folder via POST to /files. for the human intervention shield, set a variable with the last message timestamp when data.key.fromMe === true, then check if current_time - last_timestamp < 30min and use a Stop Execution node to halt the workflow if true. be aware the timestamp comparison needs unix time for accuracy, might need a Code node to handle that.

thank you man, really helpful!