Forum Discussion
GeorgiaArrowsmi
10 months agoCommunity Member
Add meeting invite to Calendar
I'm wanting to add Teams meetings into my Story for participants to attend, and I'm trying to find a way where the participants can add the meeting invite into their calendar.
I believe there migh...
CaryJenkins
10 months agoCommunity Member
You can indeed create a feature to add Teams meetings to participants' calendars using JavaScript. One approach is to generate an iCalendar (.ics) file dynamically on your server and provide a link for participants to download it. When they click the link, their browser will prompt them to open or download the .ics file, which can then be imported into their calendar application.
Here's a basic example of how you can generate an .ics file dynamically in JavaScript:
javascript
function generateICS(meetingDetails) {
const { title, description, location, startDate, endDate } = meetingDetails;
const startDateUTCString = startDate.toISOString().replace(/-/g, '').replace(/:/g, '').slice(0, -5) + 'Z';
const endDateUTCString = endDate.toISOString().replace(/-/g, '').replace(/:/g, '').slice(0, -5) + 'Z';
const icsContent = `BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Company//Product//EN
BEGIN:VEVENT
UID:${generateUID()}
DTSTAMP:${startDateUTCString}
DTSTART:${startDateUTCString}
DTEND:${endDateUTCString}
SUMMARY:${title}
DESCRIPTION:${description}
LOCATION:${location}
END:VEVENT
END:VCALENDAR`;
return icsContent;
}
function generateUID() {
// Generate a unique ID for the event
// You can use any method to generate a unique ID here
return 'your-unique-id';
}
// Example usage:
const meetingDetails = {
title: 'Team Meeting',
description: 'Discuss project updates',
location: 'Teams Meeting',
startDate: new Date('2024-02-16T09:00:00'),
endDate: new Date('2024-02-16T10:00:00')
};
const icsContent = generateICS(meetingDetails);
const blob = new Blob([icsContent], { type: 'text/calendar;charset=utf-8' });
const url = window.URL.createObjectURL(blob);
// Create a link for participants to download the .ics file
const link = document.createElement('a');
link.href = url;
link.download = 'team_meeting.ics';
link.click();
This code will generate an .ics file for the given meeting details and initiate a download for the participant. They can then import this file into their calendar application.