Logic review: Gmail classification and automated response drafting (Newbie seeking advice)

:bullseye: What is your goal?

I am building an automated support workflow for my e-commerce business (car trailer spare parts) to handle incoming emails more efficiently. My goal is to use Gemini AI to classify incoming Gmail messages into four categories (Business, Private, Trash, Unknown) and then automatically prepare response drafts in Gmail based on system data retrieved from PlentyONE.

:thinking: What is the problem?

As I am new to Make.com, this scenario is currently exceeding my experience level. I am struggling with:

Data Mapping Reliability: I am unsure how to best handle cases where the PlentyONE API search returns incomplete, multiple, or no results. I want to prevent the system from saving drafts with empty variables or broken data.

Stability: How can I ensure the Gemini prompts remain robust so that the AI output always strictly adheres to the requested JSON format without breaking the flow?

Logic Structure: I want to ensure that my router logic is considered “best practice” and that I am not overlooking any common pitfalls in this type of automation.

:test_tube: What have you tried so far?

I have already created a working basic structure using Gmail modules, two Gemini AI modules (one for initial classification and one for the business logic), and a router to handle the different categories. I also implemented a JSON Parser to process the AI output. I have successfully connected PlentyONE to the flow, but I am finding it difficult to manage the data mapping and error handling properly when the API response varies.

I have attached my blueprint below (with all private API keys and connections removed). I would greatly appreciate any feedback on the logic, the mapping robustness, and the overall design.

:camera_with_flash: Screenshots: scenario setup, module configuration, errors

gmail Automatic.json (4.02 KB)

Hi @Jens_Windhausen

You can use a simple if else router. If the data is complete (suitable for creating your draft) then it passes to the AI module that creates the draft. Else it goes to the second branch and in the second branch you can use a spreadsheet like Google sheets to log all failed plentyOne fetches.

For the AI classification break your prompts into 4 key parts.

  1. Role: Tell the AI "you’re an email inbox classification system for (your company) and then add some more descriptions of this row.

  2. Tasks: Give it a task. Tell it "Your job is to classify emails into 4 main categories. Personal, business, Null, etc.

  3. Give it and execution algorithm. For example; "You will receive incoming emails and for every incoming email do the following: 1) check for email body and if it is making an inquiry for car related services or general car business inquiry then it is a business email. 2) Check if it is casual and the body is mostly talking about personal life issues then categoze it as personal. 3) If the body is null or empty categorize it as nulle. 4) check for category 4 etc.

  4. Dictate the output. Don’t let the AI generate a response freely. Tell it, "you must generate a Json response with the following information: 1) email category which should be one of the 4. 2) Sender email address, 3) etc etc. This will ensure that you have values that you can map directly into other modules.