Using AI agent node to add attachment to Gmail node

Describe the problem/error/question

I am trying to build a customer service chatbot where the chat can allow users to upload 1 or 2 attachments (pdf, jpg, png) and the AI agent node will include the attachment(s) in an email when escalating the issue to a customer service email through the Gmail node (which is connected to the AI agent node as a tool).

There are 2 entry points for the chatbot – via webhook and also direct chat on n8n.

So far I have been able to build the customer service chatbot using the AI agent node and the Gmail node and it has successfully escalated reported issues to the customer service email, now I want to know how to add the feature to include attachments.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Cannot read properties of undefined (reading ‘0’) (item 0)

Information on your n8n setup

  • n8n version: 1.122.4 (Cloud)
  • Database (default: SQLite): Simple memory
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud

Hi @izadimrantan,

Im not aware of how to pass binary data to an AI Agent tool call directly, but you can try and convert the binary to a base64 string first and then passing that to a sub-workflow tool.

The sub-workflow tool will then reverse the base64 string to a binary again and then send the email.

This example below is very basic and will require some work to support sending multiple files, however I hope this gives you an idea of the direction of thinking I applied.

Main Workflow (Agent):

Sub Workflow (Used as tool):

Results: