Invoke Proofreader

Posted by meetheverse, Last update 5 months ago

This action allows the user to get an AI-assisted response to a prompt:
1. The user is prompted to enter input, which can be pasted from the clipboard or manually entered.
2. The input is then sent to the OpenAI API, and the response is inserted into the current draft 3 lines after the cursor.
3. If there is no selected text in the draft, the user is asked if they would like to use text from the clipboard. If the prompt is canceled or the input is empty, the action cancels.
4. If there is no response from the API, the output is set to “No reply received.”

For more detailed information, the script is sufficiently comprehensive. Refer to the action steps in order to customize it to your preferences.


  • script

    // See online documentation for examples
    // For more information on using this action, visit
    // Define a function f
    let f = () => {
      // Create a new Prompt object
      let p = new Prompt();
      // Set the title of the prompt
      p.title = "Proofreader";
      // Set the message of the prompt
      p.message = "The box below contains your input, which can either be pasted from the clipboard or manually provided. The output will be inserted 3 lines after the cursor in the current draft.";
      // Define placeholder text for the prompt input
      let placeholderText = "You are a professional proofreader and I need you to check the spelling, correct the grammar and improve the overall style of this text: \n";
      // Get selected text from the editor
      let selectedText = editor.getSelectedText();
      // If there is selected text, add it to the placeholder text
      if (selectedText.length > 0) {
        placeholderText += selectedText;
      } else {
        // If there is no selected text, get text from clipboard
        let clipboardText = app.getClipboard();
        // Create a new Prompt object to ask if user wants to use clipboard text
        let cp = new Prompt();
        cp.title = "Paste from Clipboard";
        cp.message = "Would you like to use your clipboard as an input for the prompt? If so, hit ‘Yes.’ Otherwise, ‘Cancel’ to skip this step.";
        let response =;
        // If user wants to use clipboard text, add it to placeholder text
        if (response && cp.buttonPressed == "Yes") {
          placeholderText += clipboardText;
      // Add a text view to the prompt with placeholder text
      p.addTextView("prompt", "Prompt Input", placeholderText);
      // Add a button to the prompt
      // Show the prompt and return false if user cancels
      if (! {
        return false;
      // Get user input from prompt
      const chatPrompt = p.fieldValues["prompt"];
      // Return false if user input is empty
      if (chatPrompt.length == 0) {
        return false;
      // Create a new OpenAI object
      let ai = new OpenAI();
      // Get AI response using quickChatResponse method with specified model
      let answer = ai.quickChatResponse(chatPrompt, { model: "gpt-3.5-turbo" });
      // If no answer is received, set answer to "No reply received"
      if (!answer || answer.length == 0) {
        answer = "No reply received";
      // Format content with input and output
      let content = `\n\n\n\n### Output (Proofreader):\n${answer}`;
      // Insert content into editor after selected text
      editor.setSelectedText(selectedText + content);
      // Return true to indicate success
      return true;
    // Call function f and cancel context if it returns false
    if (!f()) {


  • After Success Nothing , Tags: ai-assisted
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.