Automatic Newsletter Using Drafts

In my day of automation post I mentioned a simple newsletter automation. It’s grown since then. Some background:

A year ago, we were using Monday.com to post status updates on hard-to-see work streams for executives. Monday.com didn’t catch on, but I thought there was value in having a historical log that stakeholders could check to stay current.

In addition, I spammed links to “good to read” blog posts in Slack… at all hours of the day. This was an excusable habit when I was just a colleague, once I became a manager I realized that it was very disruptive. 🤦

I started using the blog system in Confluence for both the stakeholder statuses and collect all my links and commentary for the week. At first I manually typed up each “issue,” occasionally copy/pasting the format of the previous week’s entry, and finding links out of Instapaper’s archive and making commentary by hand. Like an animal.

Until now.

As I read throughout my week, I save little snippets using my snip tool in Hammerspoon or the Share API on iOS, and tag them link and dayjob. This forms the a queue of the links to share.

On Monday I’m greeted by a prompt in my Task Manager with a URLscheme link to Drafts that runs the following action:

let template = Draft.find("uuid-of-my-template-draft").content;

let today = new Date();
let week_ago = today.getDate() - 7;

let workspace = Workspace.find("Day Job");
let drafts =
  workspace
   .query("inbox")
   .filter(d => d.tags.includes("link") && d.createdAt > week_ago);

let links =
  drafts
    .map(function(d) {
      let content =
        d.content
          .trim()
          .split("\n");
      content[0] = "### " + content[0];
      return content = content.join("\n");
    })
    .join("\n\n")

drafts.forEach(function(d) { d.isArchived = true; d.update() });

let newsletter = Draft.create();
newsletter.content = `${template}\n${links}`;
newsletter.update();

app.setClipboard(newsletter.content);

Short and sweet! After I’ve clicked the link from my Task Manager, I open Confluence, type c to create a page, choose the Blog template in the sidebar1, type ,,weekly in the title field that Alfred.app text expands to “UXWEEKLY (2020.51)”, and then I paste the newsletter since the last line of my Drafts action copied the draft to the system clipboard. Voila!

Just what is in my clipboard? The contents of my template Draft! Let’s take a (redacted) peek.

# ProctorU Weekly Template

## 👷‍♂️ In Progress

[UX Kanban Board](link to our kanban board)

### Project #1: Fictional Title

📁: http://linktoprojectpageonconfluence.com/project-1
💬: [#proj-1-ux](https://dayjob.slack.com/archives/L337)
📈: [Link to dashboard or metrics associated with UX outcomes](http://fakelink.com/)

### Project #2: Fictional Boogaloo

📁: http://linktoprojectpageonconfluence.com/project-2
💬: [#proj-2-ux](https://dayjob.slack.com/archives/nicetry)
📈: [Link to dashboard or metrics associated with UX outcomes](http://fakelink.com/)

## 🔗 Links

That’s it! I’ll write my tweet-length update in-between the header and the links of the projects, @mention anyone who needs to see it, and the links magically appear below the ## 🔗 Links section of the newsletter.

Projects don’t change that much, so as they come and go I’ll add them and their pertinent information to the Draft Template.

This simple automation has cut down the time it takes to provide this “hub” for our work from 45 minutes per week to around 3 minutes… and that makes me happy. I’m sure there’s a bunch of ways to automate this, but keeping it all in Drafts makes it cross platform and easy to change the template on the fly if I get new information.


  1. Honestly, this is the step I mess up every week and I should automate. 


Changelog
  • 2020-12-16 22:32:18 +0000

    Just making code more readable on smaller screens

  • 2020-12-15 15:07:51 +0000

    I don't replace MMD metadata

  • 2020-12-15 14:01:09 +0000

    Add images

  • 2020-12-15 13:47:08 +0000

    Automatic newsletter using drafts