ShareShortcuts

Create calendar events (Gemini)

Uses Gemini to parse calendar events from text (e.g

twilsonco
Fork “Create calendar events (Gemini)”

Built something new on top of this Shortcut? Share it as a fork: it becomes a Shortcut of your own, which you manage, and both pages link to each other so twilsonco gets credit.

  1. 1Get the Shortcut and change it in the Shortcuts app. Give it a name of its own.
  2. 2Share it from the Shortcuts app and copy the iCloud link.
  3. 3Come back here, paste the link and describe what is different, e.g. “Added a step that uses Apple Intelligence to personalise the text.”
Downloads
26K
Saved
0
Actions
116
Category
Productivity
Version
1.0
Language
EN

Uses Gemini to parse calendar events from text (e.g. email threads/messages) or images (via OCR)

  • Takes text (or an image/screenshot containing text), e.g. from an email client or Messages and uses Google Gemini Pro to suggest one or more calendar events from the text content
  • You can choose which identified events will be added, and edit details beforehand if necessary
  • Messages and email clients suck at suggesting events; they're always incomplete and unhelpful and require additional user input. This lets Google Gemini Pro improve the process by parsing out the necessary information automatically
  • Automatically populates
    • an appropriate event title
    • start/end time and all day status
    • location
    • url
    • an appropriate calendar
    • attendee list
    • notes with references to relevant part(s) of the text used for creating the event
  • Uses "Gemini via API" shortcut

What's New

Version 1.0

First release

Version History
1.0 Feb 9, 2024

First release

What it does

116 actions
  1. Comment
    Google Gemini event suggester. December 2023, Tim Wilson
  2. Nothing
  3. Comment
    【Auto-Update Routine】 Checks For Latest Shortcut Version ↳ https://routinehub.co/shortcut/16590/
  4. Dictionary
  5. Get Dictionary Value
  6. If
  7. Get IP Address
  8. If
  9. Get Contents of URL
    https://routinehub.co/api/v1/shortcuts/…/versions/latest
  10. If
  11. Split Text
  12. Repeat with Each
  13. Calculate Expression
  14. Set Variable
    Latest Version
  15. Split Text
  16. Repeat with Each
  17. Calculate Expression
  18. Set Variable
    Current Version
  19. If
  20. Choose from Menu
    New Version: … Release: … Whats New: "…"
  21. Choose from Menu
    Update → Result (Version)
  22. Expand URL
  23. Replace Text
  24. Open URLs
  25. Stop This Shortcut
  26. Choose from Menu
    Skip (Info (Version))
  27. Comment
    【Auto-Update Routine Ends Here】 Support → https://www.reddit.com/r/shortcuts/comments/18j4f9p/ 【⚙️】 Convert Semantic Number to Decimals ↳ https://routinehub.co/shortcut/16589/
  28. Nothing
  29. Comment
    Begin dependency check (using “Check-install dependencies (v1)” by Tim Wilson: https://routinehub.co/shortcut/17694/) Dictionary of dependencies, where each: * Key is the name fo the shortcut (used to check if install, so much match perfectly), and …
  30. Dictionary
  31. Get My Shortcuts
  32. Repeat with Each
  33. Filter Files
  34. If
  35. Show Result
  36. Get Dictionary Value
  37. Set Variable
    URL
  38. Match Text
  39. If
  40. Get Contents of URL
    https://routinehub.co/api/v1/shortcuts/…/versions/latest
  41. Expand URL
  42. Set Variable
    URL
  43. Replace Text
  44. Open URLs
  45. Stop This Shortcut
  46. Nothing
  47. Comment
    End dependency check
  48. Number
  49. Set Variable
    DebugPrinting
  50. Set Variable
    Input
  51. Get Type
  52. If
  53. Extract Text from Image
  54. Set Variable
    Input
  55. Get Dates from Input
  56. If
  57. Text
  58. Stop and Output
  59. Split Text
  60. Text
  61. Set Variable
    MessageBody
  62. Repeat with Each
  63. If
  64. If
  65. Add to Variable
  66. Combine Text
  67. Set Variable
    MessageBody
  68. Match Text
  69. Count
  70. If
  71. Choose from Menu
    Include full thread?
  72. Choose from Menu
    Use full thread
  73. Set Variable
    MessageBody
  74. Choose from Menu
    Use only current message
  75. Nothing
  76. Comment
    Enter your name so that ChatGPT can try to exlude your email from atendee lists
  77. Text
  78. Comment
    Enter the name of one of your calendars that shall be used when an appropriate calendar cannot be determined from the shortcut input text.
  79. Text
  80. Comment
    Enter one or more calendars along with descriptions that ChatGPT will use to determine which calendar shall be used for new events.
  81. Dictionary
  82. Text
  83. Text
  84. Date
  85. Text
  86. Dictionary
  87. Run Shortcut
    Gemini via API
  88. Replace Text
  89. Replace Text
  90. Get Dictionary from Input
  91. Get Dictionary Value
  92. If
  93. Show Result
  94. Show Result
  95. Show Result
  96. Show Result
  97. Repeat with Each
  98. Get Dictionary Value
  99. If
  100. Show Result
  101. Get Dates from Input
  102. Get Dates from Input
  103. Choose from Menu
    Add event: … on …?
  104. Choose from Menu
    Yes
  105. Get Dictionary Value
  106. Open Event in Calendar
  107. Add New Event
  108. Get Dictionary Value
  109. Get Emails
  110. Count
  111. If
  112. Edit Event
  113. Match Text
  114. If
  115. Edit Event
  116. Choose from Menu
    No

View as code
Beta

Every action of this Shortcut written out as Cherri, a programming language for Shortcuts. Great for learning how it works.

#include 'actions/web'
#include 'actions/network'
#define color teal
#define glyph calendarPlus

/*
Google Gemini event suggester. 

December 2023, Tim Wilson
*/
nothing()
/*
【Auto-Update Routine】
Checks For Latest Shortcut Version
↳ https://routinehub.co/shortcut/16590/
*/
const Info = {
	"Author": "twilsonco",
	"RoutineHub ID": 17699,
	"Version": "1.1.1",
	"Version Check": true
}
const True = getValue(Info, "Version Check")

if True == "Yes" {
	const CurrentIPAddress = getExternalIP("IPv4")
	if CurrentIPAddress {
		const Result = downloadURL("https://routinehub.co/api/v1/shortcuts/{Info['RoutineHub ID']}/versions/latest")
		if Result contains "success" {
			const SplitText = splitText(Result['Version'], ".")
			for _ in SplitText {
				@LatestVersion = ((1/1000)^@RepeatIndex)*@RepeatItem+@LatestVersion
			}
			const SplitText1 = splitText(Info['Version'], ".")
			for _ in SplitText1 {
				@CurrentVersion = ((1/1000)^@RepeatIndex)*@RepeatItem+@CurrentVersion
			}
			if @LatestVersion > @CurrentVersion {
				menu "New Version: {Result['Version']}\nRelease: {Result['Release']}\nWhats New: \"{Result['Notes']}\"" {
				item "Update → {Result['Version']}":
					expandURL(Result['URL'])
					const UpdatedText = replaceText("https://www.icloud.com/", "shortcuts://", false)
					openURL(UpdatedText)
					stop()
				item "Skip ({Info['Version']})":
				}
			}
		}
	}
}
/*
【Auto-Update Routine Ends Here】
Support → https://www.reddit.com/r/shortcuts/comments/18j4f9p/

【⚙️】
Convert Semantic Number to Decimals
↳ https://routinehub.co/shortcut/16589/
*/
nothing()
/*
Begin dependency check
(using “Check-install dependencies (v1)” by Tim Wilson: https://routinehub.co/shortcut/17694/)

Dictionary of dependencies, where each:
* Key is the name fo the shortcut (used to check if install, so much match perfectly), and each value is either:
  * The RoutineHub ID (number), or
  * The URL (text type; iCloud link to shortcut or some other URL)
*/
const DependencyDict = {
	"Gemini via API": 17624
}
const FullShortcutList = getShortcuts()

for _ in DependencyDict['Keys'] {
	const Files = filterFiles(FullShortcutList, 1, "Last Modified Date", "Latest First")
	if !Files {
		show("This shortcut depends on the \"{@RepeatItem}\" shortcut, which was not found (by name) in your installed Shortcuts. Contiunue to install it now, then try this Shortcut again.")
		@URL = DependencyDict[@RepeatItem]
		const Matches = containsText(DependencyValue, "^[0-9]+$")
		if Matches {
			const Result1 = downloadURL("https://routinehub.co/api/v1/shortcuts/{DependencyValue}/versions/latest")
			expandURL(Result1['URL'])
			@URL
		}
		const UpdatedText1 = replaceText("https://www.icloud.com/", "shortcuts://", @URL, false)
		openURL(UpdatedText1)
		stop()
	}
}
nothing()
// End dependency check

@DebugPrinting = 0
@Input = ShortcutInput
const Type = typeOf(@Input)

if Type == "Image" {
	getTextFromImage(@Input)
	@Input
}
const Dates = getDates(@Input)

if !Dates {
	mustOutput(, Dates)
}
const SplitText2 = splitText(@Input)
@MessageBody = "nil"

for _ in SplitText2 {
	if @RepeatItem beginsWith ">" {
	} else {
		@MessageBody = @RepeatItem
	}
}
joinText(@MessageBody)
@MessageBody
const Matches1 = containsText(ShortcutInput, "On.*wrote:")
const Count = count(Matches1)

if Count > 4 {
	menu "Include full thread?" {
	item "Use full thread":
		@MessageBody = ShortcutInput
	item "Use only current message":
		nothing()
	}
}
// Enter your name so that ChatGPT can try to exlude your email from atendee lists

// Enter the name of one of your calendars that shall be used when an appropriate calendar cannot be determined from the shortcut input text.

const DefaultCalendar = "Tim private"
// Enter one or more calendars along with descriptions that ChatGPT will use to determine which calendar shall be used for new events.

const CalendarDict = {
	"Family": "Messages pertaining solely to more than one of Kaori, Justin, Maxwell, and myself, and our activities. ",
	"Justin": "Messages pertaining solely to my son, Justin, and his activities. ",
	"Kaori": "Messages pertaining solely to my wife, Kaori, and her activities. ",
	"Maxwell": "Messages pertaining solely to my son, Maxwell, and his activities. ",
	"Tim Work": "Messages pertaining to my work at Colorado school of mines with Mark Eberhart, Samuel Riddle, Charles Morgenstern, and Ivan Portilla. "
}
const EventFields = "all day, start, end, invitees, notes, location, url, and calendar"
const ExampleEventDict = "{\\"Look over background for new deal\\": {\\"start\\": \\"11:30 AM on Nov 1, 2023\\", \\"end\\": \\"1:30 PM on Nov 1, 2023\\", \\"all day\\": false, \\"location\\": \\"Frankfurt hall, room 302 or online\\", \\"invitees\\": \\"[email protected]\\", \\"notes\\": \\"Let's meet for two hours in Frankfurt hall, room 302 for two hours to go over background for the heme paper\\", \\"calendar\\": \\"Work\\", \\"url\\":\\"https://zoom.us/a45ca2ff735\\"}}"
currentDate()
const ChatGPTPrompt = "I want to use the content of a message/thread to create one or more calendar events in the form of a JSON dictionary where each event is a key:value pair. \n\nThe key for each event will be its title, and the corresponding value will also be a JSON dictionary with the following fields that should be inferred from the text: {EventFields}. \n\nThe notes field should concisely reference all the relevant parts of the message used in inferring the event details, with leading formatting characters such as chevrons used to indicate quote levels removed. The title should be not necessarily be a quote from the message, but rather be a descriptive title for the event. The all day field must be 1 for \\"true\\" or 0 for \\"false\\", and if true, the start field may contain only a date without a time. The invitees field should be an comma-separated list of email addresses, but may not contain my ({}) email addresses. \n\nIf no location can be inferred, use \\"TBD or online\\". If no end field can be inferred, assume a one hour duration. If no calendar can be inferred, use \\"{DefaultCalendar}\\". If no invitees or url can be inferred, use an empty string, \\"\\".\n\nThe calendars that may be used are, with descriptions to aid in inference, {CalendarDict}.\n\nHere is an example of a valid event dictionary: {ExampleEventDict}\n\nYour response should contain ONLY the event dictionary, without any text before or after it. \n\nIt is currently {}. Remember to adjust times if the time zone of the meeting is different from the local time zone: {}. For example, if the meeting time zone is PST and I am in MST, change the meeting time to one hour later.\n\nFinally, here is the message/thread that should be used to create the event dictionary as described above:\n\n{@MessageBody}"
const Dictionary = {
	"disablelogging": 1,
	"prompt": "{ChatGPTPrompt}",
	"temperature": "0.0"
}
run("Gemini via API", Dictionary)
replaceText("\\\\"", "\"", ['output'])
const UpdatedText2 = replaceText("\\"", "\"")
const Dictionary1 = getDictionary(UpdatedText2)
const DictionaryValue = getKeys(Dictionary1)

if @DebugPrinting == 1 {
	show(Dictionary)
	show()
	show(UpdatedText2)
	show(DictionaryValue)
}

for _ in DictionaryValue {
	const DictionaryValue1 = getValue(Dictionary1, @RepeatItem)
	if @DebugPrinting == 1 {
		show(DictionaryValue1)
	}
	const Start = getDates(DictionaryValue1['start'])
	const End = getDates(DictionaryValue1['end'])
	menu "Add event: {@RepeatItem} on {Start}?" {
	item "Yes":
		const AllDay = getValue(DictionaryValue1, "all day")
		showInCalendar()
		rawAction("is.workflow.actions.addnewevent", {
			"ShowWhenRun": true,
			"WFAlertTime": "30 minutes before",
			"WFCalendarDescriptor": "DictionaryValue1['calendar']",
			"WFCalendarItemAllDay": "AllDay",
			"WFCalendarItemEndDate": "{End}",
			"WFCalendarItemLocation": "{DictionaryValue1['location']}",
			"WFCalendarItemNotes": "{DictionaryValue1['notes']}",
			"WFCalendarItemStartDate": "{Start}",
			"WFCalendarItemTitle": "{@RepeatItem}"
		})
		const Invitees = DictionaryValue1['invitees']
		const EmailAddresses = getEmails(Invitees)
		const Count1 = count(EmailAddresses)
		if Count1 > 0 {
			editEvent(NewEvent, "Attendees", "")
		}
		const Matches2 = containsText(DictionaryValue1['url'], "https:\/\/")
		if Matches2 {
			editEvent(NewEvent, "URL", "")
		}
	item "No":
	}
}
Decompiled with cherri 2.3.0 (GPL-2.0). May need small fixes before it compiles.

Ratings & Reviews

Write a Review
–
out of 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Advertisement

More by twilsonco

See All

You Might Also Like

See All
Advertisement