Plug-In: Add FaceTime Task
This plug-in will create a new task with a TAP|CLICK FaceTime link in its notes. Optionally, you can choose the call to use FaceTime Audio.
On iOS devices the email keyboard will be automatically used for the email input.
Return to: OmniFocus Plug-In Collection
Add FaceTime Task
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.add-facetime-task",
"version": "1.1",
"description": "This plug-in will create a new task with a FaceTime call link in its notes.",
"label": "Add FaceTime Task",
"shortLabel": "FaceTime Task",
"paletteLabel": "FaceTime Task",
"image": "video.bubble"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
try {
callSymbol = "☎️"
textInputField01 = new Form.Field.String(
"taskName",
"Task Title",
callSymbol + "︎ FaceTime "
)
textInputField02 = new Form.Field.String(
"FaceTimeEmail",
"eMail",
null
)
if (Device.current.iOS && !Device.current.iPad){
textInputField02.keyboardType = KeyboardType.EmailAddress
}
checkSwitchField = new Form.Field.Checkbox(
"isAudioCall",
"FaceTime Audio",
false
)
inputForm = new Form()
inputForm.addField(textInputField01)
inputForm.addField(textInputField02)
inputForm.addField(checkSwitchField)
inputForm.validate = function(formObject){
var taskName = formObject.values['taskName']
if (!taskName) {return false}
var inputText = formObject.values['FaceTimeEmail']
if (!inputText) {return false}
var isEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(inputText)
if(!isEmail){return false}
return true
}
formPrompt = "Task title and eMail:"
if (Device.current.iOS && !Device.current.iPad){
formPrompt = "Title & eMail:"
}
buttonTitle = "Continue"
formObject = await inputForm.show(formPrompt, buttonTitle)
taskName = formObject.values['taskName']
textValue = formObject.values['FaceTimeEmail']
isAudioCall = formObject.values['isAudioCall']
schema = (isAudioCall) ? "facetime-audio" : "facetime"
callURLStr = schema + "://" + textValue
url = URL.fromString(callURLStr)
task = new Task(taskName)
task.note = url.string
id = task.id.primaryKey
URL.fromString("omnifocus:///task/" + id).open()
}
catch(err){
if(!err.causedByUserCancelling){
console.error(err.name, err.message)
new Alert(err.name, err.message).show()
}
}
});
action.validate = function(selection, sender){
return true
};
return action;
})();