Moving a PDF ie for Invoices to Google Drive

Describe the problem/error/question

After I move an email through an AI Agent (separating sales leads, client questions, invoices etc), I’m told the PDF from the email will not pass through. When it flows through the switch node to where I need to extract the PDF, I see the binary file, can download it, but when I extract PDF node it says the file is not available or called attachment_0. I see the binary file in the input of the extract PDF node, its called attachement_0, however the node does not recognize it. If tried a merge node, code node, filter, all the same result. Any thoughts?

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

Code in JavaScript1
2 items
attachment_0
File Name:
invoice_17088034.pdf
File Extension:
pdf
Mime Type:
application/pdf
File Size:
80.7 kB
Parameters
Settings
Operation
Extract From PDF
Input Binary Field
attachment_0
The name of the input binary field containing the file to be extracted
Options
No properties
Add option
I wish this node would…
Output
1 item
This operation expects the node’s input data to contain a binary file ‘attachment_0’, but none was found [item 0]
Make sure that the previous node outputs a binary file
Asked
Error details
Other info

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 @Brian_Magladry, welome back!

As you know, debugging n8n issues with text only is quite difficult, especially if you are seeking a genuine human answers,

Help me to help you :), could you share a screenshot showing the logic/error or even the Workflow for the specific part you’re having trouble with?!

1 Like

1 Like

thanks,

giphy
ohh :smiley:

okay, to understand the error and how to fix it: the problem is that the node has two input items, but no binary data is found in one of them, probably the first item:

In this case, use a Merge node with the following settings:

Then place it here:

Also, I noticed that the lower branch is not linked to the Switch node, you may need to link it, as I explained in the screenshot..

hope this is what you looking for..

1 Like

Your new logic created two duplicate attachments called attachment_0 and I still cannot pull either of them through the workflow, I get the same error code. Basically, this workflow runs my email. I’m trying to have this particular path be my ‘Invoice’ path. The email comes through get labeled ‘Invoice’ in Gmail, the pdf is extracted, an AI Agent labels it how my invoices are setup in Quickbooks and gets saved in my Google Drive folder, the message is slacked to me saying I have a new invoice received/to pay and them removes the item from my Gmail Inbox. Maybe my whole setup is incorrect? Would you set it up differently? Hope this clarifies what I’m trying to accomplish.

Hello @Brian_Magladry ,

In the input panel of your Extract from File node (top left), it says “2 items”. The error message says none was found [item 0].

Most likely, your previous nodes (probably the Merge or Code node) produced two items:

  1. Item 0: Contains only JSON/Text (no binary).
  2. Item 1: Contains the actual attachment_0.

Since the node tries to process every item, it hits Item 0, fails to find the binary, and errors out immediately.

Try this:
Add an “If” Node just before the Extract node.
• Set the condition to check if the binary field exists: {{ $binary.attachment_0 }}Is Not Empty.
• Connect the True output to the Extract node.
Alternative: In your Code/Merge node, ensure you are merging the binary into the single item rather than appending it as a second item.

Let me know if filtering out the empty item fixes it.

regards,

That’s very good, i think we’re almost at the solution!

The idea is that I’m not exactly sure what you have inside the code node, so I can’t suggest the most suitable fix yet,

But now I have a general understanding of what’s happening,
You can try add an Aggregate node before the Merge here:

The idea I’m trying to explain is to output only one single item, so that this is the only one used in the next node,

It’s okay, if it works for you that’s fine,

Once we fix the issue you can improve it later, especially the Code nodes,
Most of the time, it’s not necessary to use them, You can often use other nodes instead, like the Set node, even when working with binary data..