Issue with Google Gemini and Gmail Integration in n8n Workflow

I’ve created this simple workflow in n8n that retrieves unread emails via the Gmail node and sends them to the AI Agent node using Google Gemini as a free alternative to OpenAI.

However, when the Gmail node is connected to the AI Agent node, I encounter the following error:

Error in sub-node ‘Google Gemini Chat Model’
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/learnlm-1.5-pro-experimental:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type

I’m not sure how to resolve this issue. Any advice or insights would be greatly appreciated!

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I have same on the latest beta 1.74.1

If i test as Chat message works okay, but if i sent same text in the {{$json.chatinput}} from set node in AI, i got the error

Any System message

Bad request - please check your parameters
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[1].parts: contents.parts must not be empty.

Gemini cannot receive content which i send to AI node.


UPDATE
I saw that in my case, if in FSh tools module is sending more information than, chatInput, sessionId,action - for example

It works like this.
[
{
{ “chatInput”: “hello”,
“sessionId": ‘342318385’,
{ “action”: “sendMessage”
}
]

But if there are more other parameters in the json, the AI module on 1.68.0 waits a few minutes and gives an unrelated error, on 1.74.1 it gives the above error immediately.

I assume that the node takes the whole array from the previous node, which in principle is good for adding special instructions to Gemini, but Gemini does not expect to see them and react to them.

Workaround
And one of my solutions was to reduce the number of nodes in the chain up to AI assistant, thus AI agent went to a separate workflow with parameters, first node is execute workflow trigger (like chat), second is AI agent, and everything worked. It wasn’t logical, but it works.

1 Like

I can confirm that i had the same problem because my item input had 3 fields then i switched to only one field and it worked.

I had the same issue for Gemini (without Gmail or any tools).

The chat input kept adding an extra empty [] to my prompt. It was driving me nuts!!

Moving the model call to a sub workflow fixed things. (I am still passing the exact same 4 parameters I previously was using in the sub workflow.)

I was constantly getting this error:

Bad request - please check your parameters
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-001:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[1].parts: contents.parts must not be empty.

It would always add this weird [] at the end of my prompt:

...
# SYSTEM PROMPT
You are currently talking to Shima. Their Telegram Username is @abcd

Human: testing flash flash baby
Human: []

Hi @Shima
I was getting the same issue of adding “Human: ” automatically and because of this, was getting the same error:

Bad request - please check your parameters
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-001:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[1].parts: contents.parts must not be empty.

Solution: Add a ‘edit fields’ node before the AI agent and fetch out the necessary keys in the ‘edit fields’ node only and then pass it to AI agent.
This worked in my case, u can also give it a try.