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?
Asked
Active
Viewed 239 times
-1
-
Can you explain what you mean by "Google notification"? I don't know if this is a specific technology, so a link would be great too. – IObert Oct 11 '22 at 08:18
-
I mean a calendar invite. – Chris Hansen Oct 11 '22 at 08:54
1 Answers
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