Workflow Automation for Nostr

How to use workflow automation with Nostr, using n8n and Nostrobots, to delegate account access, set up push notifications, and more.

Rod

2. Januar 2025January 2, 2025 · 14 Min. Lesezeit14 min read

Tldr#

Inter-op All The Things#

Nostr is a new open social protocol for the internet. This open nature exciting because of the opportunities for interoperability with other technologies. In Using NFC Cards with Nostr I explored the nostr: URI to launch Nostr clients from a card tap.

The interoperability of Nostr doesn't stop there. The internet has many super-powers, and Nostr is open to all of them. Simply, there's no one to stop it. There is no one in charge, there are no permissioned APIs, and there are no risks of being de-platformed. If you can imagine technologies that would work well with Nostr, then any and all of them can ride on or alongside Nostr rails.

My mental model for why this is special is Google Wave ~2010. Google Wave was to be the next big platform. Lars was running it and had a big track record from Maps. I was excited for it. Then, Google pulled the plug. And, immediately all the time and capital invested in understanding and building on the platform was wasted.

This cannot happen to Nostr, as there is no one to pull the plug, and maybe even no plug to pull.

So long as users demand Nostr, Nostr will exist, and that is a pretty strong guarantee. It makes it worthwhile to invest in bringing Nostr into our other applications.

All we need are simple ways to plug things together.

Nostr and Workflow Automation#

Workflow automation is about helping people to streamline their work. As a user, the most common way I achieve this is by connecting disparate systems together. By setting up one system to trigger another or to move data between systems, I can solve for many different problems and become way more effective.

n8n for workflow automation

Many workflow automation tools exist. My favourite is n8n. n8n is a low/no-code workflow automation platform which allows you to build all kinds of workflows. You can use it for free, you can self-host it, it has a user-friendly UI and useful API. Vs Zapier it can be far more elaborate. Vs Make.com I find it to be more intuitive in how it abstracts away the right parts of the code, but still allows you to code when you need to.

Most importantly you can plug anything into n8n: You have built-in nodes for specific applications. HTTP nodes for any other API-based service. And community nodes built by individual community members for any other purpose you can imagine.

Eating my own dogfood

It's very clear to me that there is a big design space here just demanding to be explored. If you could integrate Nostr with anything, what would you do?

In my view the best way for anyone to start anything is by solving their own problem first (aka "scratching your own itch" and "eating your own dogfood"). As I get deeper into Nostr I find myself controlling multiple Npubs – to date I have a personal Npub, a brand Npub for a community I am helping, an AI assistant Npub, and various testing Npubs. I need ways to delegate access to those Npubs without handing over the keys, ways to know if they're mentioned, and ways to know if they're posting.

I can build workflows with n8n to solve these issues for myself to start with, and keep expanding from there as new needs come up.

Running n8n with Nostrobots#

I am mostly non-technical with a very helpful AI. To set up n8n to work with Nostr and operate these workflows should be possible for anyone with basic technology skills.

Installing n8n

Self-hosting n8n could not be easier. I followed n8n's Docker-Compose installation docs–

n8n is free to self-host but does require a license. Enter your credentials into n8n to get your free license key. You should now have access to the Workflow dashboard and can create and host any kind of workflows from there.

Installing Nostrobots

To integrate n8n nicely with Nostr, I used the Nostrobots community node by Ocknamo.

In n8n parlance a "node" enables certain functionality as a step in a workflow e.g. a "set" node sets a variable, a "send email" node sends an email. n8n comes with all kinds of "official" nodes installed by default, and Nostr is not amongst them. However, n8n also comes with a framework for community members to create their own "community" nodes, which is where Nostrobots comes in.

You can only use a community node in a self-hosted n8n instance (which is what you have if you are running in Docker on your own server, but this limitation does prevent you from using n8n's own hosted alternative).

To install a community node, see n8n community node docs. From your workflow dashboard–

Using Nostrobots

Nostrobots gives you nodes to help you build Nostr-integrated workflows–

Nostrobots has good documentation on each node which focuses on simple use cases.

Each node has a "convenience mode" by default. For example, the "Read" Node by default will fetch Kind 1 notes by a simple filter, in Nostrobots parlance a "Strategy". For example, with Strategy set to "Mention" the node will accept a pubkey and fetch all Kind 1 notes that Mention the pubkey within a time period. This is very good for quick use.

What wasn't clear to me initially (until Ocknamo helped me out) is that advanced use cases are also possible.

Each node also has an advanced mode. For example, the "Read" Node can have "Strategy" set to "RawFilter(advanced)". Now the node will accept json (anything you like that complies with NIP-01). You can use this to query Notes (Kind 1) as above, and also Profiles (Kind 0), Follow Lists (Kind 3), Reactions (Kind 7), Zaps (Kind 9734/9735), and anything else you can think of.

Creating and adding workflows

With n8n and Nostrobots installed, you can now create or add any kind of Nostr Workflow Automation.

Nostr Workflow Automations#

It's time to build some things!

A simple form to post a note to Nostr

I started very simply. I needed to delegate the ability to post to Npubs that I own in order that a (future) team can test things for me. I don't want to worry about managing or training those people on how to use keys, and I want to revoke access easily.

I needed a basic form with credentials that posted a Note.

For this I can use a very simple workflow–

Once the workflow is built, you can test it with the testing form URL, and set it to "Active" to use the production form URL. That's it. You can now give posting access to anyone for any Npub. To revoke access, simply change the credentials or set to workflow to "Inactive".

It may also be the world's simplest Nostr client.

You can find the Nostr Form to Post a Note workflow here.

Push notifications on mentions and new notes

One of the things Nostr is not very good at is push notifications. Furthermore I have some unique itches to scratch. I want–

I needed to build a Nostr push notifications solution.

To build this workflow I had to string a few ideas together–

Once the workflow was built, lists published, and Pushover installed on my phone, I was fully set up with push notifications on Nostr. I have used these workflows for several weeks now and made various tweaks as I went. They are feeling robust and I'd welcome you to give them a go.

You can find the Nostr Push Notification If Mentioned here and If Posts a Note here.

In speaking with other Nostr users while I was building this, there are all kind of other needs for push notifications too – like on replies to a certain bookmarked note, or when a followed Npub starts streaming on zap.stream. These are all possible.

Use my workflows

I have open sourced all my workflows at my Github with MIT license and tried to write complete docs, so that you can import them into your n8n and configure them for your own use.

To import any of my workflows–

To configure them–

What next?#

Over my first four blogs I explored creating a good Nostr setup with Vanity Npub, Lightning Payments, Nostr Addresses at Your Domain, and Personal Nostr Relay.

Then in my latest two blogs I explored different types of interoperability with NFC cards and now n8n Workflow Automation.

Thinking ahead n8n can power any kind of interoperability between Nostr and any other legacy technology solution. On my mind as I write this:

In fact I have already released an open source workflow for an AI Assistant, and will share more about that in my next blog.

Please be sure to let me know if you think there's another Nostr topic you'd like to see me tackle.

GM Nostr.

#creating#grownostr#n8n#nostr

Written by

Comments

No comments yet. Start the conversation.