Skip to main content

Hi all – I’m running into an issue where my Zap attempts to upload email attachments (specifically PDFs) from Gmail, filter them using MIME type in a code step, and pass only the valid PDFs into the “Upload File” and “Conversation” steps for ChatGPT.

Here’s what’s happening:

  • I correctly isolate PDFs via MIME type using a JavaScript step.

  • The filtered file URLs are then passed to several “Upload File to OpenAI” steps using the “assistants” purpose.

  • The upload appears successful — the PDF shows as Ready in the OpenAI file list with the correct file- ID.

  • However, when I try to pass those uploaded file IDs into a “Create Conversation in ChatGPT” step, I receive the error:

    “Non-PDF files (downloaded_file.txt…) require Code Interpreter to be enabled…”

  • I’ve confirmed that the files I’m passing are valid PDFs, not text files — but downloaded_file.txt files keep appearing in my OpenAI storage.

  • My assumption is Zapier is somehow uploading blank or non-PDF files behind the scenes, even though I’ve filtered for MIME type.

Would appreciate any help — I’m trying to reliably extract PDF attachments from Gmail and feed them into ChatGPT for summarization, and this issue is holding up the workflow.

 

Thanks in advance!

Hi ​@lwhathaway 

Help us have true context by posting screenshots showing:

  • how your Zap steps are outlined
  • how your Zap steps are configured in EDIT mode in the CONFIGURE tab with the field mappings visible
  • any encountered errors from testing Zap steps

Thanks, Troy! Screenshots attached and the code from the code step pasted below: 

 

// Extract attachments from input

const attachments = inputData;

 

// Helper function to normalize inputs

function toArray(...items) {

return items.filter(i => i !== undefined && i !== null);

}

 

// Collect matching PDFs

let pdfUrls = [];

let pdfNames = [];

 

for (let i = 1; i <= 5; i++) {

const mime = attachments[`mime${i}`];

const name = attachments[`name${i}`];

const url = attachments[`url${i}`];

 

if (mime && mime.toLowerCase() === "application/pdf" && url) {

pdfUrls.push(url);

pdfNames.push(name || `attachment-${i}.pdf`);

}

}

 

// Return up to 5 URLs and names individually

return {

foundPdf: pdfUrls.length > 0,

fileUrl1: pdfUrls[0] || null,

fileUrl2: pdfUrls[1] || null,

fileUrl3: pdfUrls[2] || null,

fileUrl4: pdfUrls[3] || null,

fileUrl5: pdfUrls[4] || null,

fileName1: pdfNames[0] || null,

fileName2: pdfNames[1] || null,

fileName3: pdfNames[2] || null,

fileName4: pdfNames[3] || null,

fileName5: pdfNames[4] || null

};


The downloaded_file.txt issue happens because Zapier sometimes sends a text wrapper instead of the actual PDF binary when pulling Gmail attachments. Even if you filter by MIME type, Gmail often just gives Zapier a link or base64 data, so the OpenAI Upload step treats it as text. The fix is to normalize the file before upload: either use Zapier’s “Formatter Utilities → File” step on the Gmail attachment, or in your Code step explicitly return the file with .pdf as filename and application/pdf as MIME type. That way the OpenAI step sees a true PDF and won’t generate .txt placeholders.


Hey ​@lwhathaway 👋 Just came across this and wanted to check how you’re getting on, were you able to get this solved?

If not, it looks like you’ve got file object rather than file URLs mapped to the url fields on the Code action: 

838f148142a1f290da6beb1427308e72.png

Since the Gmail trigger provides the data for each of the attachments in differently numbered fields could you maybe get rid of the Code step and map those fields directly from the Gmail trigger into the relevant ChatGPT actions?

Looking forward to hearing from you!