googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.38k stars 1.91k forks source link

Calendar - node - Can I send an event update email to new attendees only? #3310

Open EliasTouil opened 1 year ago

EliasTouil commented 1 year ago

What you're trying to do

I'm trying to create an app on which users can subscribe to an event.

My plan is to create an event, then update it every time a user wants to attend by updating or patching the event attendees.

I would like the users to receive the google email with the event details when they register.

What code you've already tried

Using this code, all the attendees will receive an email every time a new attendee is added. In this scenario, I would like only new attendees to receive the email.

//  [...] abridged auth and calendar setup

authWithImpersonation.getClient().then((auth: any) => {
 getEvent().then((ev: any) => {
  const newAttendees = ev.data.attendees
   ? [
    ...ev.data.attendees,
    {
     email: 'user@domain.com',
    },
   ]
   : [
    {
     email: 'user@domain.com',
    },
   ];

  let eventPatch = {
   attendees: newAttendees,
  };

  calendarWithImpersonation.events.patch({
   auth,
   eventId: ev.data.id,
   calendarId: GCP_CALENDAR_CALENDAR_ID,
   resource: eventPatch,
   sendUpdates: 'all', // Hello there
  });
 });
});

Is there a way to dynamically choose who gets notified?

If you have any other suggestion on how to achieve my goal I'm open to it, this is a greenfield project.

Thank you

EliasTouil commented 10 months ago

crickets noises

hao-cro-matic commented 8 months ago

Having the same issue here. I found this behavior achievable on the Google Calendar app, but not with the javascript client.

EliasTouil commented 8 months ago

@hao-cro-matic heads up I ended up manually controlling notifications and emails and all for this. It wasn't a walk in the park. If you need to handle communications and the event invitees change often, as it did in our app, I would strongly advise you to look into alternatives. If you can't I'll happily share code if you need some guidance / examples.

aparyavi commented 8 months ago

I'm having the same issue. When adding an attendee with notification set to true it sends out an update to all attendees.