Simplifying Document Classification Logic in n8n with Google Drive

Hello everyone,

I’m currently working on an n8n workflow that integrates Google Drive and an AI agent (ChatGPT model).
The goal is to automatically identify the type of a document (e.g., invoice, contract, CV, etc.) — this part is already working well thanks to the AI.

The next step is to automatically classify these documents into about twenty specific folders on Google Drive based on their identified type.

Problem:
I’m facing the following issue: how can I efficiently associate each document type with its corresponding Google Drive folder without using a cascade of “IF” blocks, which quickly becomes unmanageable and hard to maintain?

Question:
What structure or approach would you recommend to make this step clean, maintainable, and scalable?
Are there any best practices in n8n for this kind of “mapping” or classification task?

Thank you very much for your suggestions!

Moved the topic to the right category

hello @Abdel_UNK13

Have you tried to use the switch node? Another approach is to use the code node and create a mapping there

May I ask how the system successfully classifies each document into its respective category after upload? I’d like to understand the mechanism behind how the classification works.

Hi, just with an AI agent to identifie kind of doc and a short script to organize the upload in the right location

1 Like