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).
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.
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â
}
]âââ
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
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.
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.