DEV Community

Cover image for Obsidian Examples for Workflow Automation
Pieces 🌟 for Pieces.app

Posted on • Updated on • Originally published at code.pieces.app

Obsidian Examples for Workflow Automation

For many of us, the amount of information we need to read and understand is overwhelming. Even worse, when you need to retrieve what you've read, do you know where it is stored and how to find it? In this post, I share my solution—how I created an automated workflow for an Obsidian personal knowledge management system. All the software is free, and the code snippets for the Obsidian note examples are from the web.

My Personal Obsidian Use Case

I wear several ‘hats’ in my work and personal activities. First, my Ph.D. research compared six machine-learning models with categorization data collected from human subjects. That evolved into a consulting career on how to design systems that are easy to learn and use. My personal interests are physics and theology and how they relate to each other. These cross-disciplinary interests require me to find, read, and annotate large amounts of information, and they provide examples of Obsidian use cases that involve Pieces.

The Obsidian notes examples are drawn from my creating an automated workflow for information flow. I gathered Obsidian code snippets from the web as screenshots or as copies of the Markdown, CSS, YAML, or Python code. I used the Pieces Chrome extension with Pieces for Obsidian and Pieces for Desktop. Because they share a common repository, it is irrelevant which Pieces module saves an Obsidian notes code block.

My new workflow is an ongoing experiment and it has been extremely helpful. The Obsidian example vault I use for testing my process is a standard Windows folder containing “notes” as Markdown (MD) text files. The notes hold different types of information used for different tasks. For example, a file may be a document, a template for new notes, an “asset” such as an image, the results of a query across the vault, etc.

In this post, I'll overview my personal Obsidian use case for workflow automation. I describe the Obsidian examples to explain what I did, and I discuss why and how Pieces made it easier to do. Obsidian is a ‘blank slate’ to be personalized by the user, so there is no one ‘right’ way to automate your workflow. The best approach is to use Obsidian until you discover what you do and do not like, and then gather code snippets available from the web to create your preferred workflow.

A useful note in Obsidian.

Why Pieces Is Crucial to My Workflow

I often find useful content when browsing the web with different devices, such as phone, tablet, or computer. When using a computer, the Zotero browser extension extracts the metadata and stores the source document in its reference database. If the source has an interesting code snippet, I hover the cursor over the code and use the Pieces browser’s “Copy and save” button to store the snippet. When using my phone, I store a screenshot in Google Keep (local) or Google Drive (cloud) and later have Pieces extract the code and make it available for editing on my computer.

The following figure shows the tiny, blurred text in a screenshot that Pieces extracted into editable code. It is easier to have Pieces extract the text than to type it in manually, even for very short snippets. There may be a few characters misread by the OCR process, but those are easily corrected by Pieces' on-device machine learning models. Try to include only the lines of code because, in this example, including the “People” header or a lot of whitespace blocks the OCR process.

The YouTube screenshot with some code.

Pieces manages my Obsidian MD examples as well as some snippets in other languages. To each snippet, it intelligently adds a title and descriptions of what the code does, and it also saves descriptions I add manually. When my laptop is attached to an external monitor, the monitor is the visual home of the Pieces for Desktop that stays open. This allows me to move among a variety of open windows without any break in my mental focus. Also, using the Desktop module rather than the Obsidian plugin provides more screen space for my Obsidian notes.

My use of Obsidian is more complex than many users because I have multiple Obsidian vaults. Each vault is focused on a specific area of interest: (1) the usability/usefulness of software systems, (2) the text, images, and LaTeX equations for my independent research in physics, and (3) my scheduler for calendar events and tasks. There are also nested vaults with different plugins.

The Pieces for Obsidian plugin is crucial for managing the Obsidian code snippets because some snippets are used in only one vault and other snippets are used in multiple vaults. For example, my scheduler vault is designed for access from my Android phone and does not contain any imported annotations. In contrast, the two other primary vaults include annotated sources imported from my reference manager. Without Pieces, I would not remember which snippets are used in which vault. Pieces makes the snippets easily available for editing and reuse.

How I Automated My Annotations Workflow

The Zotero reference management system holds the bibliographic information for the 4K+ print books in my library plus many PDFs and other electronic documents. It is easy to add entries to Zotero with its extension for the Chrome browser. The recent release of Zotero Version 6 stores the documents with my markup annotations. The annotations could be imported into Zotero as notes, but my automated workflow imports them directly into Obsidian.

After a document has been captured by Zotero, I can use Zotero's editor to highlight text, select images, insert comments, and create other types of annotations. There are several Obsidian forum posts and YouTube videos describing how to automate importing Zotero annotations into Obsidian. However, none of them provided exactly what I wanted, so I used Pieces to gather code snippets from several sites. Then I pasted snippets into Notepad++ for editing. The final version of the code went into Obsidian and was saved in the Pieces repository.

This part of the automation took multiple tries to achieve what I wanted. The first version of the process created two notes in Obsidian in different folders, one for the markup annotations and another for my personal notes about the document and its source. A bidirectional link connected the two notes and indicated whether both notes existed. However, I quickly decided it would be better to have all the information in a single note.

Further exploration found an article on Medium that provided the complete template for a combined file. The code was saved in Pieces and then pasted into Notepad++ for editing. Because I preferred the first version’s annotation display, the new annotation section was replaced by a snippet from the Pieces’ repository.

The edited code was pasted from Notepad++ into Pieces Desktop for intelligent storage. For example, Pieces intelligently read the line "category: literaturenote" in the code and added the title "Code Snippet: Literature Note Template.” It also added the two descriptions shown in the following figure and stored my added vault name and date.

Auto-generated annotations for a code snippet in Pieces.

I more recently found an automated-workflow Obsidian example that illustrates the usefulness of Pieces when working with code for any reason. To test the GitHub example, I created a new vault and started following the instructions in the readme file. I did change the vault’s folder structure and names to my preferences rather than those shown in the readme.

However, running the code produced an error message that a comma was missing in the literature-note template. The code was already in the Pieces repository, so I asked the Pieces copilot to find and fix the missing-comma error. It displayed the corrected code shown below—and it apologized for an error it did NOT commit. The erroneous code had been pasted from GitHub.

Corrected code from the Pieces Copilot.

When I replaced the lines of old code with the Pieces’ code, it correctly imported all the information from Zotero. As the last step, I replaced the GitHub code for displaying annotations with the code snippet from Pieces that displayed my preferred style.

Programming Languages for my Obsidian Examples

Obsidian template examples are Markdown files, but other languages are also useful when modifying an Obsidian vault. For example, Python adds functionality and CSS changes the visual appearance. Other languages include HTML, JavaScript, and YAML. The more you understand Obsidian, the more you can use code snippets to create what you want.

For example, basic Obsidian does not show when a link is unresolved---when the note at the other end of the link has not been created. Clicking on the link creates an empty note that, if created by accident, needs to be deleted. Using color to flag unresolved links eliminates the accidental creation of notes by clicking links.

Changing link colors is an appearance change that requires adding CSS code to the vault. Because I am not an expert programmer, it can be difficult to visualize precisely what appearance will be created by a snippet. Consequently, I used the Pieces Chrome extension to gather several snippets from the web for testing.

It is simple to insert a snippet into Obsidian to test how it affects a vault. For CSS, the code goes into its own .css file in the snippets folder under the .obsidian folder. To easily find the snippets folder, open the Appearance settings and ask Obsidian to display the location of the snippets folder. If the folder does not exist, create it and the .css file. Then refresh the CSS snippets in the Appearance settings and enable the new CSS code.

After testing multiple CSS snippets, I kept the one that changed the font color, font weight, and background color of unresolved links. The other snippets I collected that might be useful in other vaults are also intelligently annotated by Pieces in its repository.

My workflow scope for using Obsidian knowledge management continues to increase as I gather more snippets. My next goal is to grow my vault into an Obsidian project management tool. Again, there are numerous videos and forum posts explaining how others have done it using the Obsidian code block for properties (YAML code) that can be at the beginning of any note.

My plan is to gather Obsidian example notes and test them to identify which ones produce the desired results. With help from Pieces, I am not limited to using only the languages I know. For saved snippets, Pieces provides additional information and sometimes it can be very verbose. For example:

A verbose response from the Pieces Copilot.

Some code snippets have the language identified within the Obsidian note code block. In those cases, there is a language indicator after the first set of triple backticks. For example, the “js” in the previous figure identifies its language as JavaScript. However, Pieces can automatically detect the language when it is not identified.

Conclusion

Oleksandr H. on LinkedIn has a great article that discusses seven reasons why "Obsidian is a great tool for managing code snippets." The Pieces Obsidian plugin supports all his reasons to use Obsidian for code snippets. In addition, it (1) makes the AI intelligence of Pieces available within Obsidian, while (2) it provides a common snippet repository accessible from applications such as JupyterLab and VSCode notebooks and for sharing with Microsoft Teams.

Automating my annotation workflow required organizing how I extracted and stored information from source documents, especially PDFs. The coding challenge was the import of annotations, standalone notes, and bibliographic information from Zotero into Obsidian.

The multiple Pieces modules made it easy to gather the snippets I needed when I was browsing the web on my phone, tablet, or computer. There is a recent video by Bryan Jenks (November 6, 2023) that includes every step in his automation process, and the Pieces Obsidian plugin can be added to that.

There are numerous creators on the web who provide examples and code for other types of workflow automation in Obsidian. These include task management, project management, periodic notes for days, weeks, months, etc., habit tracking, and many others. However, be aware that Obsidian introduced properties earlier in 2023 and Zotero released version 6 in March, 2022. Consequently, older workflow descriptions may or may not work correctly.

The general process in this Obsidian knowledge base example can be applied to any Obsidian vault example that requires gathering and curating information from source documents. Also, all software discussed in this post is free unless multiple people are using an Obsidian vault to generate revenue. Even then, the cost is relatively small for the benefits provided when Pieces is integrated into your Obsidian vault(s).

Top comments (0)