Create Customizable Text Inserts Using Automator

While you can use text replacements to insert reusable blocks of text, it is sometimes necessary to customize the text for various situations. You can build an Automator service to trigger a series of prompts and then create a block of text based on your responses. In this example, we'll build a way to quickly respond to support email messages.

Here are the JavaScript elements to save you from typing them from scratch:

function run(input, parameters) {
	app = Application.currentApplication();
	app.includeStandardAdditions = true;

	var choices = ["continue to wait", "try contacting us again", "try calling"];
	var selection = app.chooseFromList(choices, {withPrompt: 'Otherwise?', multipleSelectionsAllowed:false});
	
	return selection;
}
function run(input, parameters) {
	
	var response = "Thanks for your inquiry "
	+ input[0] 
	+ ". We will respond within "
	+ input[1]
	+ " days. If you do not hear from us by then, please "
	+ input[2]
	+ ".";

	return response;
}

Comments: 3 Responses to “Create Customizable Text Inserts Using Automator”

    Sony Cohen
    4 years ago

    Is there a shortcut that returns date ?

    4 years ago

    Sony: A simple script like this would do it:

    function run(input, parameters) {
    	var now = new Date();
    	return datestring = (now.getMonth()+1)+"/"+now.getDate()+"/"+ now.getFullYear();
    }
    Spencer Stead
    4 years ago

    Hi,

    I followed this script & it works until the last "Get Value of Variable". It appends each get value of variable in the results, then, once getting to the last get value of variable, it removes all of the other get value variables & sets the result to only the last get value of variable.

Comments Closed.