n8n Sanity Nodes
To enhance The Magic Porridge Poet project, I wanted to fully automate the generation and publishing of new AI poems. To do this, I used workflow automation tool n8n, self-hosted on cloud platform DigitalOcean.
To automate the publishing part of the workflow, I created two n8n Community Nodes to interact with Sanity.io, a headless Content Management System (CMS).
These nodes are designed to create, edit, and delete documents in a Sanity Content Lake, as well as to transform data generated by an LLM (or any other data source) to match a Sanity CMS Document Schema.
The nodes are:
SanityMutation
- Creates, edits, and deletes documents in a Sanity Content Lake (User Guide)SanitySchemaMapper
- Transforms data to match a Sanity CMS Schema (User Guide)
The package, named n8n-nodes-sanity-mutation
, can be installed from npm.
To install these n8n Community Nodes and use them in your own n8n projects, follow instructions in the n8n documentation.
Automated Workflow
Here's what the nodes look like in action in The Magic Porridge Poet:

n8n workflow (left-to-right):
- Schedule Trigger: Executes the workflow on a schedule (e.g. every 2 hours)
- Date & Time: Provides the current date and time
- HTTP Request: Makes a call to Sanity CMS to get information about previously generated poems
- Basic LLM Chain: Sends prompt, output schema, and context to LLM and returns a new poem, including title, author's note, and reflective insight
- Code: Converts poem title into a slug
- Sanity Schema Mapper: Transforms the LLM output to match the provided Sanity CMS Document Schema
- Sanity Mutation: Creates a new document in the Sanity Content Lake with the transformed data