Right now we're using the icalendar gem to generate an ics file that we send via email.
While this does give the user a convenient "Add to my Calendar" button through email, it does not automatically add the event to the user's calendar too, making it so the user still has to do that manual step themselves.
Is there any way to make it so that the event is automatically added to the user's calendar? This has been hard to find a solution for.
def add_calendar_event
@cal = Icalendar::Calendar.new
@cal.event do |e|
e.dtstart = start_time
e.dtend = end_time
e.summary = 'Organized Appointment'
e.organizer = organizer_email
e.attendee = user_email
e.description = 'random string'
e.status = 'CONFIRMED'
end
@ics_var = { mime_type: 'text/calendar; charset=UTF-8; method=REQUEST', content: @cal.to_ical }
end
This requires a bit more understanding of calendars.
They use .ics
files as a format for events, but calendars require users to add those events to their calendars.
For pure automation you must ask the user to "Authenticate with {Google/Outlook/ETC}" and provide "authorize read/write access to app".
Then you would be able to automatically add events to calendar.
Another way is to create a calendar RSS Feed and instruct the user to import your RSS feed into their calendars. You can make the URL unique to the user, requiring an API token or something so that its not purely public.