×

VCOF0066

OmniFocus: New Appointment

Displays a form for creating a new task representing an appointment coming up in the next week.

Scope and Syntax

Language: English (United States 🇺🇸 · Great Britain 🇬🇧 · Australia 🇦🇺 · Canada 🇨🇦) • Scope: System-Wide

Command phrase variations (words in [brackets] are optional):

New Appointment Form Dialog

Requirements

Video: New Appointment
Displays a form for creating a new task representing an appointment coming up in the next week.

Installing voice commands on iOS/iPadOS

While Apple’s mobile operating systems currently do not support the Open URL action used in the voice commands files provided on this website, you can still create and use customized Omni Automation voice commands for iPhones and iPads!

To create your voice commands, we’ll use specialized Shorcuts workflows that you can “tap-to-install” from the various example pages. Simply follow these steps or view the illustrated instructions here:

  1. First, install an Omni Automation shortcut from one of the provided links. (below)
  2. Next, in the mobile Settings app, tap AccessibilityVoice ControlCustomize CommandsCustomCreate New Command… and in the forthcoming New Command interface select the installed shortcut as the value for the “Action” parameter.
  3. Enter one of the command phrases from the example’s documentation page (above) for the value of the “Phrase” property, and…
  4. Finally, set the value of the “Application” parameter to either “Any” for global access or choose the Omni app to target from the provided list of installed applications.

You can then activate Voice Control and use your voice command to trigger the shortcut to run the Omni Automation script!

Downloads

Voice Commands Code

Here’s the Omni Automation code for the commands:

New Appointment


(async () => { try { function createUtterance(textToSpeak){ AlexID = ( (app.platformName === "macOS") ? "com.apple.speech.synthesis.voice.Alex" : "com.apple.speech.voice.Alex" ) voiceObj = Speech.Voice.withIdentifier(AlexID) voiceRate = 0.4 utterance = new Speech.Utterance(textToSpeak) utterance.voice = voiceObj utterance.rate = voiceRate return utterance } var synthesizer = new Speech.Synthesizer() // CREATE FORM ELEMENTS var appointmentNameField = new Form.Field.String( "appointmentName", "Title", null, null ) var appointmentNoteField = new Form.Field.String( "appointmentNote", "Note", null, null ) var dayItems = ["Today", "Tomorrow", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] var dayIndexes = new Array() dayItems.forEach((item, index) => dayIndexes.push(index)) var dayMenu = new Form.Field.Option( "dayMenu", "Day", dayIndexes, dayItems, 0 ) var hourItems = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"] var hourIndexes = new Array() hourItems.forEach((item, index) => hourIndexes.push(index)) var hourMenu = new Form.Field.Option( "hourMenu", "Hour", hourIndexes, hourItems, 0 ) minuteItems = [":00", ":15", ":30", ":45"] minuteIndexes = [0, 1, 2, 3] var minutesMenu = new Form.Field.Option( "minutesMenu", "Minutes", minuteIndexes, minuteItems, 0 ) meridianItems = ["AM", "PM"] meridianIndexes = [0, 1] meridianMenu = new Form.Field.Option( "meridianMenu", "AM/PM", meridianIndexes, meridianItems, 0 ) var checkSwitchField = new Form.Field.Checkbox( "followingWeek", "Following week", null ) var menuLabel = "Notifications" var notificationOptionsStrings = ["Day before", "Morning of", "Hour before"] var multiOptionMenu = new Form.Field.MultipleOptions( "notificationsOptions", menuLabel, [0,1,2], notificationOptionsStrings, [0,1,2] ) // CREATE FORM var inputForm = new Form() inputForm.addField(appointmentNameField) inputForm.addField(appointmentNoteField) inputForm.addField(dayMenu) inputForm.addField(hourMenu) inputForm.addField(minutesMenu) inputForm.addField(meridianMenu) inputForm.addField(checkSwitchField) inputForm.addField(multiOptionMenu) // VALIDATE FORM ENTRIES inputForm.validate = function(formObject){ var appointmentName = formObject.values['appointmentName'] if (!appointmentName || appointmentName.length === 0){return false} return true } // DISPLAY FORM var formPrompt = "Appointment:" var buttonTitle = "Continue" var formObject = await inputForm.show(formPrompt, buttonTitle) // RETRIEVE CHOSEN FORM VALUES var dayIndex = formObject.values['dayMenu'] var chosenDay = dayItems[dayIndex] console.log("chosenDay", chosenDay) var hourIndex = formObject.values['hourMenu'] var chosenHour = hourItems[hourIndex] console.log("chosenHour", chosenHour) var minuteIndex = formObject.values['minutesMenu'] var chosenMinute = minuteItems[minuteIndex] console.log("chosenMinute", chosenMinute) var meridianIndex = formObject.values['meridianMenu'] var chosenMeridian = meridianItems[meridianIndex] console.log("chosenMeridian", chosenMeridian) var useFollowingWeek = formObject.values['followingWeek'] console.log("useFollowingWeek", useFollowingWeek) var timeValue = chosenHour + chosenMinute + chosenMeridian console.log("timeValue", timeValue) var fmatr = Formatter.Date.withStyle(Formatter.Date.Style.Full, Formatter.Date.Style.Short) var dateObj = fmatr.dateFromString(`${chosenDay} @ ${timeValue}`) if(useFollowingWeek){ var dc = Calendar.current.dateComponentsFromDate(dateObj) dc.day = dc.day + 7 dateObj = Calendar.current.dateFromDateComponents(dc) } var dateStr = fmatr.stringFromDate(dateObj) var appointmentName = formObject.values['appointmentName'] var appointmentNote = formObject.values['appointmentNote'] if (!appointmentNote){appointmentNote = ""} // CREATE NEW TASK WITH FORM DATA var task = new Task(appointmentName) task.note = appointmentNote task.dueDate = dateObj var tag = flattenedTags.byName("Appointment") || new Tag("Appointment") task.addTag(tag) var notificationIndexes = formObject.values["notificationsOptions"] notificationIndexes.forEach(index => { // day before, morning of, hour before if(index === 0){task.addNotification(-86400)} if(index === 1){ var dc = Calendar.current.dateComponentsFromDate(dateObj) dc.hour = 9 // morning hour dc.minute = 0 // morning minute var notificationDateObj = Calendar.current.dateFromDateComponents(dc) task.addNotification(notificationDateObj) } if(index === 2){task.addNotification(-3600)} }) // CONFIRMATION ALERT var alertTitle = "Form Result" var alertMessage = "Your appointment is for:\n\n" + dateStr var alert = new Alert(alertTitle, alertMessage) alert.addOption("Show") alert.addOption("OK") var buttonIndex = await alert.show() if (buttonIndex === 0){ var taskID = task.id.primaryKey var urlStr = "omnifocus://task/" + taskID URL.fromString(urlStr).open() } utterance = createUtterance("Done!") synthesizer.speakUtterance(utterance) } catch(err){ if (!err.message.includes("cancelled")){ utterance = createUtterance(err.message) synthesizer.speakUtterance(utterance) //new Alert(err.name, err.message).show() } } })();

 

 

 

LEGAL

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.