How to Dynamically Remove Empty Attendees Field in Google Calendar Node with $fromAI()

Dynamically Excluding Empty Attendees Field with $fromAI() in Google Calendar Node

Hi everyone! I’m using n8n to automate event creation in Google Calendar, with $fromAI() dynamically filling in the attendees based on user input. The issue I’m running into is that if the user doesn’t specify any attendees, attendees still gets included in the JSON request as an empty array. Google Calendar then returns an error, saying the email is invalid.

I need to configure this workflow so that attendees is only included in the JSON if the user actually specifies attendees. I’m already logged in through OAuth and have the credentials set up in n8n, so the connection with Google Calendar is working. I also don’t understand where or how an IF function could be used here to make this conditional exclusion of attendees possible.

Here is some additional information to help you understand the setup:

  • $fromAI() automatically populates the value for attendees based on user input.
  • I’ve configured Google Calendar with OAuth credentials in n8n.

Could someone help me figure out how to conditionally remove attendees from the request if it’s empty? Any advice or examples would be greatly appreciated!

Questions that might help troubleshoot:

  1. Is there a way to use IF or another function in n8n to check if attendees is empty and exclude it from the JSON if so?
  2. Should I use a Function or HTTP node here to customize the JSON request directly?
  3. Are there any specific settings in Google Calendar’s n8n node that might allow this conditional handling?

Thanks in advance!

What is the error message (if any)?

“Invalid email address” — Google Calendar API rejects the request when the attendees field is an empty array.

my workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.66.0
  • Database (default: SQLite)
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via Docker:
  • Operating system: ubuntu

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’m using the Google Calendar node in n8n to create events. In the Additional Fields → Attendees, I dynamically pass the following expression:

Копировать код

{{ $fromAI("Attendees") }}

I want the attendees to automatically be marked as confirmed (responseStatus: "accepted") without them needing to confirm the invitation. However, I’m not sure what needs to be done in this field to make that happen.

Is there a way to configure the node or modify the attendees array to include the responseStatus property directly in the Additional Fields? If so, could you explain how to implement this?

For context:

  • n8n version: 1.67.1 (Self Hosted)
  • Node: Google Calendar (Create Event)
  • Goal: Automatically mark attendees as confirmed without sending a request for confirmation.

Thanks in advance for your guidance!

Hi @sharen1994,

Thanks for posting! I think there are two ways to go about this. If you want to use an IF conditional to check if attendees property exists or not in the request body, you can use the Workflow Tool to call another workflow that includes the IF condition before creating an event in the Google Calendar.

Another option would be to simply replace the create event Google Calendar Tool node with HTTP Request Tool and send the entire request body - that way you won’t have to filter out cases where there are no attendees.