Not able to pass the attached file in chat to AI Agent to upload to Google drive

Describe the problem/error/question

The AI Agent is not able to pass the attached file to the Google Drive integration tool

What is the error message (if any)?

Cannot read properties of undefined (reading ‘0’)

Please share your workflow

{
“nodes”: [
{
“parameters”: {
“options”: {
“allowFileUploads”: true,
“allowedFilesMimeTypes”: “application/pdf”
}
},
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.1,
“position”: [
-360,
-140
],
“id”: “8b74d1d4-1b7f-40f0-bbf8-3c04ea2d02d9”,
“name”: “When chat message received”,
“webhookId”: “76f29326-929f-4f2b-aed1-5cedc0f2d0bc”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “upload the file in the attachment using the tool called Google Drive1”,
“options”: {
“systemMessage”: “You are a helpful assistant who uploads the received attachment into Google drive folder using the available tool called "Google Drive1" please pass the binary file data0 as input parameter for this tool.”,
“returnIntermediateSteps”: true,
“passthroughBinaryImages”: true
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.7,
“position”: [
-140,
-140
],
“id”: “a9533418-4dc0-443d-ba27-59b0e255a571”,
“name”: “AI Agent”,
“alwaysOutputData”: true
},
{
“parameters”: {
“model”: “gpt-4o-2024-11-20”,
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1,
“position”: [
-120,
80
],
“id”: “9cad8319-3ca1-48ba-8bb1-e7073d72f2c2”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “SyYuiVVR2JZyzMYB”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“descriptionType”: “manual”,
“toolDescription”: “upload the attached PDF file submitted by the user in chat to specified Google Drive”,
“inputDataFieldName”: “=data0”,
“name”: “=test.pdf”,
“driveId”: {
“__rl”: true,
“mode”: “list”,
“value”: “My Drive”
},
“folderId”: {
“__rl”: true,
“value”: “1pG8l8fElEngitDUIulcs6DaZPdqlp2HW”,
“mode”: “list”,
“cachedResultName”: “resumes”,
“cachedResultUrl”: “https://drive.google.com/drive/folders/1pG8l8fElEngitDUIulcs6DaZPdqlp2HW
},
“options”: {}
},
“type”: “n8n-nodes-base.googleDriveTool”,
“typeVersion”: 3,
“position”: [
380,
120
],
“id”: “df6d0c3f-8b02-4b2d-a732-2300e5cd62ca”,
“name”: “Google Drive1”,
“credentials”: {
“googleDriveOAuth2Api”: {
“id”: “AUeuxZQHz4U1RzJt”,
“name”: “Google Drive account”
}
}
}
],
“connections”: {
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Google Drive1”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {}
}

(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:**[email protected]
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Windows

Hey Arun - Just been discussing this with the team and this isn’t possible the way the workflow is currently structured.

You could try uploading the file prior to executing the agent, but not sure if that works for your use case.

What are you planning to do? If you let me know what you’re working towards I can potentially suggest some alternatives

1 Like

Yes, i did a pre processing of the PDF to text only if the user submits a attachment and then feed to agent as recommended and it worked as expected.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.