How to Send Multiple Emails for Each Selected CV with Custom FileName from Pinecone?

Hi everyone,

I’m working on an HR assistant workflow that uses an AI Agent to select the 3 most relevant CVs from a Pinecone Vector Store, generate a tailored interview for each one, and send an individual email per candidate with their CV and interview content.

I’ve got most of the flow working, but I have two specific issues I’d like help with:


:puzzle_piece: Issue 1: Only One Email Is Sent

Even though the AI Agent returns 3 CV file names, only one email is being sent. I resolved this by properly using the SplitInBatches node:

  • Loop output goes into the rest of the flow (Google Drive → AI Agent → Gmail).
  • Next batch is connected back into the SplitInBatches node itself to loop over the next CV.

Now, 3 emails are sent — :white_check_mark: that part is solved.


:puzzle_piece: Issue 2: Pinecone File Name Mapping (Main Problem)

The metadata.fileName returned from Pinecone looks like this:

json

"metadata": {
  "fileName": "sergio_benitez_ruiz_desarrollador_full_stack_senior.pdf",
  ...
}

However, the AI Agent originally returned file names like "archivo1.pdf" which didn’t match my actual Google Drive files. I want to ensure the Agent uses only the real file names stored in Pinecone under metadata.fileName.

Here’s the updated systemMessage I used for the Agent to get the correct file names:

typescript

You are a recruitment assistant. Given a job description provided by the user, search the "Seleccion de CVs" tool and return the 3 most relevant results.

Return ONLY the file names from Pinecone’s metadata.fileName field in the following JSON format:

[
  { "nombre_archivo": "sergio_benitez_ruiz_desarrollador_full_stack_senior.pdf" },
  { "nombre_archivo": "juan_perez_react_dev.pdf" },
  { "nombre_archivo": "ana_garcia_uiux_specialist.pdf" }
]

⚠️ Do not include any text outside of the JSON.

:red_question_mark:What I need help with:

  1. :white_check_mark: Does this prompt look good to ensure proper access to metadata.fileName?
  2. :inbox_tray: Is there a better way to ensure Google Drive uses this file name to find and download the exact match?
  3. :envelope: Any best practices for validating if a file was not found, to avoid broken emails?

Thanks in advance! :folded_hands:

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi there, i think you can also use an output parser to make sure that the return response from your AI Agent node is always exactly as what you thought it would

it enforces the AI to return the response in the way that you define it in the output parser

welcome to the community btw!!!

Hi!!

I have added a split Out node after node code and before Loop, now the workflow is working!!!

Thanks for help!!!