-1

Users book appointments on my website. I want to send them a google calendar invite so that they can accept and have it in their calendar. How can I do that with node is and sendgrid?

IObert
  • 2,118
  • 1
  • 10
  • 17
Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

1

Gmail automatically parses attached .ics files and suggests the users in the UI to add them to their calendars. This means you need to build the right ics attachment and use the following snippet to attach it to the email you are sending:

const SendGrid = require("@sendgrid/mail");

  const attachment = {
    filename: 'invite.ics',
    name: 'invite.ics',
    content: Buffer.from(data).toString('base64'),
    disposition: 'attachment',
    contentId: uuid(),
    type: 'text/calendar; method=REQUEST',
  };

    await SendGrid.send({
      attachments: [attachment],
      templateId,
      from: {
        email: config.emailSender,
        name: config.emailName,
      },
      to: user.email,
      dynamicTemplateData: templateData
   });
IObert
  • 2,118
  • 1
  • 10
  • 17