Make Title Current Appointment

With massive help from @sylumer, I created an action to get your most recent or current calendar event and add to the title of your current draft. This is to aid in referencing your drafts later when you are taking notes in a meeting.

I created this after searching the Drafts directory and coming up short. I’m honestly surprised no one has thought of this one before, as it seems like such a common use case.

A couple of things I’m hoping to add:

  • A better title (this one’s a mouthful, but at least it’s accurate?)
  • Add attendees

Anyway, here it is. Happy for feedback!

https://actions.getdrafts.com/a/1ib

2 Likes

There isn’t currently an option to get attendee information from events in Drafts. You would have to rely on an external option for now (perhaps varying by platform) to get such information.

Yeah, I did notice that in the documentation after posting this. I thought there might be a hidden function in there regardless, but none of the obvious ones seemed to work.

Maybe @agiletortoise can implement the world’s most niche feature request to enable this.

Well, it isn’t quite the first time it’s been requested :wink:

I expanded your script a little bit to be able to select the event of several ones are found.
I also changed the behavior to get events from all your calendars, not just the default one.
If somebody finds it useful here is the adapted script. I did not make an action out of it, since I maybe add some meeting template function into it - but I have a running solution at the moment so don’t expect something in the near future :smiley:

// Initialise

let allCalendars = Calendar.getAllCalendars()
const timeWindowMinutes = 180

let foundAppointments = [];
let eventsCount = 0

// Grab events from last 3 hours (based on current time) and append them to an array
for(cal of allCalendars){
let aev = cal.events(Date.today().addMinutes(-timeWindowMinutes), Date.now());
aev.map(ev => foundAppointments.push(ev.title));
}
for (const foundAppointment of foundAppointments){
	eventsCount = eventsCount +1;
}

// Get the latest event found and add to drafts with a markdown title
if(foundAppointments.length > 1)
{
	// select event
	let p = new Prompt()
	p.title = "Select Event"
	for(appntmnt of foundAppointments){
		p.addButton(appntmnt)
	}
	if(p.show()){
	
	draft.prepend ("# " + p.buttonPressed + "\n");
	draft.update();
	
	} else {
	
	 app.displayWarningMessage("No event selected");
	
	}
} else if (foundAppointments.length == 1){

	draft.prepend ("# " + foundAppointments [eventsCount-1] + "\n");
	draft.update();

} else {
	app.displayWarningMessage("No events found");
}
3 Likes