Share Binary File between AI Agent and Tool/Call Another Workflow

Describe the problem/error/question

I am trying to have an AI Agent upload files to DropBox based on incoming Outlook email attachments. Since there is no DropBox tool but there is DropBox node I am trying to connect the AI Agent with another workflow that contains the DropBox upload node action. How can I pass the binary file from the initial Outlook trigger towards the AI Agent and over to the child-workflow?

What is the error message (if any)?

I have tried various approaches, including saving the file locally and loading the file again in the child-workflow. This doesn’t seem to work since the child-workflow is unable to locate/load the original attachment file ( I am using the Cloud version, maybe that’s the problem?)

Please share your workflow


{
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX"
            }
          ]
        },
        "filters": {
          "foldersToInclude": [
            ""
          ]
        },
        "options": {
          "attachmentsPrefix": "attachment_",
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.microsoftOutlookTrigger",
      "typeVersion": 1,
      "position": [
        -1180,
        -500
      ],
      "id": "c1ae5420-bade-4197-8ef9-c0d26720222a",
      "name": "Microsoft Outlook Trigger",
      "notesInFlow": true,
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "id": "",
          "name": "Microsoft Outlook account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.bodyPreview }}",
        "options": {
          "systemMessage": "=You are an assistant that needs to help me with reacting to various emails.\n\nIf a email comes in from a supplier, the invoice or order confirmation needs to be send towards DropBox using the Send to DropBox tool. The attachment was already saved in a previous step. Keep the original filename, {{ $json.fileName }}\n\ ",
          "returnIntermediateSteps": false,
          "passthroughBinaryImages": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        -640,
        -500
      ],
      "id": "da8d5b55-d86d-49f2-88ab-c43d9a8b8021",
      "name": "AI Agent",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "= {{ $fromAI('subject','a clear and concise email subject') }}",
        "bodyContent": "= {{ $fromAI('body','the body of the reply itself') }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.microsoftOutlookTool",
      "typeVersion": 2,
      "position": [
        -460,
        -140
      ],
      "id": "b09f5694-b840-41a0-a743-702a2412585a",
      "name": "Microsoft Outlook",
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "id": "",
          "name": "Microsoft Outlook account"
        }
      }
    },
    {
      "parameters": {
        "model": "claude-3-5-sonnet-20241022",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.2,
      "position": [
        -800,
        -140
      ],
      "id": "490e1bc1-2cac-4b08-b89c-b622ceffa8dc",
      "name": "Anthropic Chat Model",
      "credentials": {
        "anthropicApi": {
          "id": "",
          "name": "Anthropic account"
        }
      }
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "={{ $binary.attachment_0.fileName }}",
        "dataPropertyName": "attachment_0",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        -920,
        -500
      ],
      "id": "409284cf-4fc0-4e3f-900f-6027dd689f43",
      "name": "Read/Write Files from Disk"
    },
    {
      "parameters": {
        "name": "save_to_dropbox",
        "description": "Call this tool to save files to DropBox. The files were saved in a previous step and only need to be referenced by the filename.",
        "workflowId": {
          "__rl": true,
          "value": "A8UCs7m87eNkTMQ9",
          "mode": "list",
          "cachedResultName": "Save to DropBox"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "invoice_filename": "= {{ $fromAI('invoice_filename','the filename of the invoice') }}"
          },
          "matchingColumns": [
            "invoice_filename"
          ],
          "schema": [
            {
              "id": "invoice_filename",
              "displayName": "invoice_filename",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2,
      "position": [
        -180,
        -240
      ],
      "id": "4013b599-88f1-4bca-b67e-bd83394511b3",
      "name": "Save to DropBox"
    }
  ],
  "connections": {
    "Microsoft Outlook Trigger": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Microsoft Outlook": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to DropBox": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ba9da4ec35268a89fdffca52b0e3115a108b02239de2b2f8950cf65159355395"
  }
}

Share the output returned by the last node

This operation expects the node’s input data to contain a binary file ‘data’, but none was found [item 0]

Information on your n8n setup

  • n8n version:
  • Cloud / [email protected]
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • n8n cloud
  • Operating system:

Have you found this? This may be of use. I believe latest cloud defaults to the new file access mode, this is the recommended access.

Were you able to find a solution? I’m trying to figure this out too

My recommendation is to use write/read file node and pass the file name, or just pass base64 to another workflow.

Did you find the solution? I’m facing a similar issue.