Building a shortcut to automate link dumps

I’ve wanted to get into the habit of sharing link-dumps on my blog for a while; sharing any interesting, useful or just straight up random links in the hopes that someone finds something that they also enjoy. Lots of other people are doing it and I enjoy reading them, so I thought I’d do my best to contribute to the community.

The problem was, I didn’t have a workflow that made this straight forward.

My setup

My website is built using Framer, which unfortunately means I don’t have a simple way of automating link submission, instead needing to manually publish a CMS item. A link-dump is the most efficient way of doing this; collecting several links at the end of a month and publishing one roundup blog post

I use Bear notes for writing blog posts. I’ve used it for ages and because I like the way it uses tags and nested tags for organising content. It’s also got really good support for Shortcuts which makes automating content creation much easier

And I use Anybox for saving links. I started using it a couple of months ago and it’s been a game changer for saving and recalling links. Amongst other things, it uses tags and nested tags to organise content, much in the same way as Bear. It’s got handy "quick" actions, support for shortcuts, works on all Apple devices and has an option for a one-off purchase rather than a subscription. It ticks all of my (Any)boxes

Getting the appropriate links out of Anybox and into Bear in a nicely formatted structure was a bit too manual of a process for me to get into a habit of doing it regularly. f my previous endeavours are anything to go by, if all the stuff that comes with writing a blog (formatting, publishing etc) takes any amount of effort, I simply won’t write the post in the first place

Investigation

Knowing that Bear and Anybox supported Shortcuts, I knew there would be a way to automate this process. I was comfortable with the Bear side of things as I’d made several shortcuts in the past, but I’d never done anything with Anybox.

I jumped in to Shortcuts and started with a Get Links action and left the source as All. I added Text afterwards, and added the Links in JSON Format variable, and then followed this with a Show Result action so I could see what Links in JSON Format actually looked like. I didn’t know anything about JSON before this although it’s structure did seem pretty self-explanatory. I found this article though that did a good job of explaining what I was looking at in Lehmans terms (as well as helping with a few bits later on)

Each link that I was pulling from Anybox contained lots of bits of information; a title, a URL, a date added, comments, stars etc. and these are represented in JSON as a key and a value. And this collection of keys and values is known as a dictionary. It looks a bit like this

`key` = "title" `value` = "YouTube"
`key` = "url" `value` = "www.youtube.com" 

These keys are important later, so if you’re following along, I’d recommend repeating the steps above and familiarising yourself with the names of the keys you’re working with

I didn’t know specifically what I was going to do with this JSON but based on what I’d found so far, I was happy that there’d be a solution in Shortcuts

Setting up my Apps

I first needed to set up Anybox so that I was ready to pull out the appropriate links. I’d already got a tag called link-dump that I’d use to tag anything I thought was worth sharing. Because I plan to publish a link-dump at the end of the month, I set up a Smart List called link-dump-current-month that, you guessed, displays links with the link-dump tag that were added this month. (Something to note, 'added this month' actually means added to Anybox this month, not that the link-dump tag was added this month. I found an old link and applied the tag, but it doesn’t show up in this Smart List. Not a big deal but it took me a minute to get to the bottom of it)

After that I thought about what tags I wanted to use in Bear so that the post would be nested where I want it to be. I’m currently restructuring Bear to use the PARA framework (more on that soon) so I’ve got a top-level tag for Projects followed by website followed by CMS, where the link-dump post would be housed. It looks like this 1-projects/website/cms/link-dump

Building the Shortcut

The first action was Date that grabbed the Current Date, followed by a Text that I’d use to create the Bear note title later on. When you insert a date variable, if you click on it and change the Date Format to Custom, you can display the date and time in any format you can think of - pretty neat

Next I added the Get Links action for Anybox and changed All to the my Smart List link-dump-current-month. This grabs all the links currently in that list

Next I added Get Dictionary from Input. Input autofills to Links in JSON Format as it connects to the action before it. This creates a dictionary of every key and value that exists for a single link

Because I want this to happen for all of the links in my List, I needed to set up a Repeat action. I added a Repeat with Each action. Items autofills with Dictionary from the step above

In between the Repeat and End Repeat actions, I added Text where I could pull the specific pieces of data I wanted for each link (the JSON for each link includes a lot of data so I wanted to filter out the stuff I didn’t need here, rather than doing it later, manually, in Bear.)

This is where knowing the names of the keys is important

I added a variable into the Text box and selected Repeat Item. I clicked on that variable set the Type to Dictionary, set Get to Dictionary and in the Get Value for Key field, entered the name of the key for which I wanted to pull a value, starting with title and url

After the End Repeat action I added Combine Text which autofilled with Repeat Results and New Lines. This would take all of the data from Text, and repeat it for every link in my Smart List, separated by a line

The next phase was to set up what would be sent into Bear, so I added another Text box, and added the text that I wanted to appear at the top of my Bear note, namely the tag, and a Created On date which pulled the current date from the beginning of the shortcut. I added a variable for Combined Text and was then ready to set up the Bear side of the shortcut

I added a Create Bear Note action and set the title to Text that I’d created at the beginning. To avoid confusion by having lots of Textvariables, if you click on that variable within the action you can rename it to something more useful. The input is automatically filled with Text from the step above, and I then switched off 'Return to Shortcuts'.

Finally I added an Open Bear Note action and set the note to Bear Note from the action above. This way after I run the shortcut, the note will automatically open, ready for me to edit and publish to my Framer CMS

And that’s about it! I’m going think more about which pieces of data I want to pull through, and I’m going to look at whether I can add extra tags like 'Resources' or 'Interesting articles' etc so that I can further categorise my links, and have each link appear under the corresponding heading in the Bear note. But I’m probably getting ahead of myself though. At least now I’ve not got any excuses for not posting a link-dump on the regular, right?…