How to filter a Google Calendar event trigger for a specific attendee

  • 18 November 2020
  • 3 replies
  • 190 views
How to filter a Google Calendar event trigger for a specific attendee
Userlevel 4
Badge

Hi there, this is Erin Oz from the Zapier Support Team with a workflow idea to share. 

Have you ever wanted to trigger on a specific calendar event in Google Calendar, but only in cases where a specific person is attending the event? 

For example, let’s say you’re an executive assistant, and you want to trigger on all Google Calendar events that the executive has marked “attending”. 

Or, let’s say you are working from a shared calendar and only want the Zap to trigger on events you are attending!

You can use a Code Step to search the list of event attendees for your target email address, and add a filter that only allows the Zap to continue if that person has marked “attending”.

Example

I've created a code step solution that will find a specific attendee by email address and return their response.  

Start by mapping the Attendees Email and Attendees Response Status fields from Google Calendar as values into keys "attendeesEmails" and "attendeesResponses" as shown below:

sQSNvKaMN8boxoOb37NSkAwGLaf8dS2hirgrYVRaqWg8l5rXk85ZCxdOm2LCH6Kmq5tVpGAesT7RoDeeQa80mhcSP4cTp2A0zNeUjSEdYq07yeQ3n3w-IALznBfgb_54NC_oAHXV

Then copy and paste this code into the Code field:

// Create arrays from stringified input data

var attendeesEmailArray = inputData.attendeesEmails.split(','); var attendeesResponsesArray = inputData.attendeesResponses.split(',');

// Find index of erin.ozolins@zapier.com

var targetPosition = attendeesEmailArray.indexOf("erin.ozolins@zapier.com");

// Return corresponding response

var targetResponse = attendeesResponsesArray[targetPosition] output = [{target_response: targetResponse}];

nOGbVxPIBM0v4kYntlKXd9z8FYxNyjcpAiWy08w0get1PBmIpWgn5kCPO-02Xx39Ra8YSUFl6STVVJboUQFlHoJlE2WoV8cAmjq55I9TJ_qLJxcFyV4Fp32d2ClXwrr23Mkku07O
The expected output will contain the response status for your target attendee: 

92Ic4CPbaQkhvPgTL6NE_u0L6EiblLLfZwmsx1ypIX4FbfPh4eANYENG1o73wvzH5Dv0j4OE2pds80uVxxniolNX0uh6PRvRGaH5NJUksPcw_YzjYVtj8ASOF_JvFhOhOGFrz7HX

That way, you can filter on the output field Target Response from the Code Step to only allow the Zap to continue if the status contains "accepted":

ThhSiTsFQJrLYctSN2qX8gbFFU2ecJfQp42k-Pf51dt8YxYc9RJ2J2y448xD_pMSlplHR2OaPKnf2Vxb3iAPSd0xlpw9IgkSsAPttcNqOlQB9qysXVib-5ru5Zy7TUPJsbIE_T-2

Now the following steps in the workflow will run for every event that erin.ozolins@zapier.com is attending! 

Do you have any other ideas for how this code could be adapted to a different scenario? Let me know in the comments! 


3 replies

Userlevel 7
Badge +10

Thanks @erinoz - this is really useful!

Hi Erin,

This is great, thanks a lot!

I have a quite similar, yet different thing to solve: I’d like to send emails (gmail) triggered by an event (google calendar), e.g. 24h before the event starts. This is easy. However, I’d like event invitee 1 to receive a different message than event invitee 2. The invitees (1 and 2) will be different from event to event. Is there a possibility to do this with zapier?

Thanks a lot!

Hi @erinoz , thank you for the input, it is a very interesting scenario! 

 

I am right now playing with a different variant of this scenario, but I am not so gifted (yet) with js. 

I would like to send participants of a meeting a follow-up email, but only if their status is not “declined”. This means that those with “accepted”, “tentative” or “needsAction” would receive an E-Mail.

 

I’ve been able to set all the triggers, but just the part where I can make sure that the attendeesEmails is filtered to only the selected few, is puzzling me. Can you help me with that? 

Reply