Skip to main content
Question

Trouble Passing Uploaded PDFs into ChatGPT Conversation Step – Unexpected TXT Files & Failures

  • September 5, 2025
  • 4 replies
  • 38 views

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!

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • September 5, 2025

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

  • Author
  • Beginner
  • September 5, 2025

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

};


  • New
  • September 5, 2025

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.


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • October 2, 2025

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!