Send email to attendee when google calendar event is created, but don't send to organizer

:bullseye: What is your goal?

My clients have an appointment slot on their Google Calendars so clients can self-schedule. When a new appointment is made, I want Gmail to send an email to the person who created the appointment with appointment information and a link to an intake form, but I don’t want to also send that email to the event organizer (my client).

:thinking: What is the problem & what have you tried?

When I set this up for the first client, the event organizer (my client) was in the attendees array at index one, so I just had gmail send the email to attendees2.email and that worked great. When I set this up for my second client, the person self-scheduling the appointment ended up in array index 1 and my client in array index 2, so that won’t work. Knowing that it’s not predictable who will be in which array location, I want to send to all attendees excluding the organizer. I used the AI generator to build the function, and it gave me this:
‘’‘{{map(remove(1.attendees; 1.organizer.email); “email”)}}’‘’

As you can see below, it still sent to both email addresses.

:clipboard: Error messages or input/output bundles

Input bundle (I’ve redacted some personal information)

‘’‘[
{
“to”: [
“(redacted - email of person who created event)”,
“(redacted - email of my client, the event organizer)”
],
“from”: “"(redacted - my client)" <(redacted - my client’s email address)>”,
“content”: “

Dear Parent or Guardian,

\r\n\r\n

(redacted - email body content)

”,
“subject”: “Welcome to (redacted) — Please Complete Your Intake Form”,
“bodyType”: “rawHtml”
}
]’‘’

I’m replying to add that I just also tried this, but maybe the syntax is wrong.

’’’{{if(1.attendees[1].email + “=""email1@email.com”“”; 1.attendees[2].email; 1.attendees[1].email)}}’’’

So email1@email.com is my client’s email. I want this expression to evaluate whether the first email address in the array is email1@email.com. If it is (so the expression is true) I want it to send to the second email. If it is not (so the expression is false) I want it to send to the first email.

This feels like it should work, but I might need to format it slightly differently

Hi @Jenifer_Miller

The most important question is how these email addresses end up in this array.

Could it be a structured Collection like {“organizer”:”xuz@..”, “atendees”:[…]} instead?

Can you share some screenshots of how this scenario is set up?

@damato

I’m not sure I understand why that’s important. What’s important is knowing that I can’t predict whether the organizer or the attendee will be in array position 1, so I need to use logic to determine that.

I’ve solved it by using this expression:

{{if(1.attendees[1].email = “organizer-email@email.com”; 1.attendees[2].email; 1.attendees[1].email)}}

It’s important because if you don’t know in which order they entered the array, you can’t predict who is in which position when you need to use the values. You’re focusing on the wrong issue.

That was my whole point, though. I don’t know how they’re entering the array, so I want to use logic to send an email to whichever person isn’t the event organizer. My if statement asks whether the first email address is my client’s. If it is, it sends to the second email, and if it’s not that must mean it’s the person who booked the appointment and it sends to them.

That’s why I asked if you could share the scenario. But if you managed to get it to work, that’s good news.