Start the year off right with Dynamic Prompts using n8n, Baserow and Airtable. I explain how you can introduce Dynamic Prompts to simplify data extraction workflows!
Hey there I’m Jim and if you’ve enjoyed this article then please consider giving me a “like” and follow on Linkedin or X/Twitter . For more similar topics, check out my other AI posts in the forum.
Last week, I had the opportunity to talk about the Dynamic prompts design pattern on n8n Studio with Max Tkacz (@maxT). If you’re new to the pattern, it’s just a really cool way to move instructional prompts out of a template and into the hands of your users. It’s also quite challenging to describe using just words so definitely check out the n88 studio episode with a full demo here - https://www.youtube.com/watch?v=_fNAD1u8BZw
The Challenge
The example I chose to demonstrate this pattern with was LLM-powered data extraction, where I use LLMs to identify and extract attributes and values from a Resume/CV eg. Name, Address and so on. By now, this type of workflow is quite straightforward and accomplished using n8n’s Information Extractor node however, there are a few issues that can arise…
- The template can become brittle to change - if requirements never change, this isn’t such a big deal but when there is a need to add another attribute or criteria, the template must be amended which introduces a maintenance burden. With enough of these workflows, the cost can be quite high and user satisfaction suffers because of slow rate of updates.
- The template isn’t reusable - though simple to build, building a separate template for each new extraction job request (even if they are slight variations) can quickly become a lot of work to manage and keep track of. Users are typically dissatisfied when hearing how simple changes occur huge costs and time.
When you really dig down into these issues, you’ll realise the main challenges to solve can boil down to “self-service” and “automation”. Well, for “automation”, there really is nothing better than n8n! But where n8n is just the tool, Dynamic Prompts is the design pattern we can use to solve for “self-service”.
Dynamic Prompts to the rescue!
The gist with Dynamic Prompts in our context, is rather than defining attributes and prompts ahead of time and hardcoding them into our n8n template, we allow them to be set externally and inject them into our LLM agent at the last moment instead. I feel the simplicity is this pattern’s greatest strength!
Users get to retain full control of the prompts and output without the needing the intervention of the developer or need to edit the template. Developers also get an easier time as Dynamic Prompt templates can be context-agnostic meaning one used for Resumes/CVs can also be used for Bank Statements and Invoices.
Ok, that’s fine and dandy but “storing prompts externally”?
“What the heck does that even mean?” I hear you say. Right on time, the last piece of the puzzle is where do we propose to store these prompts and what possible user interface would even work well for Dynamic Prompts. The answer may (or may not) surprise you… spreadsheets.
Yes! Spreadsheets. Well, technically not any old spreadsheet. I’m taking about the new kids on the block, Baserow and Airtable!
The key reason why these tools work for Dynamic Prompts is kinda unexpected - they both support Field Descriptions. Field descriptions are metadata fields which are intended for team documentation purposes but they also make for perfect containers for storing field “prompts”. The “field” (aka column) then follows to be the attribute to extract and the “record” (aka row) can serve as the context to extract from.
If you’re not entirely following, don’t worry - here’s the example Airtable for a visual explanation: https://airtable.com/appAyH3GCBJ56cfXl/shrXzR1Tj99kuQbyL
Of course, these other features of Baserow and Airtable add other why they are the preferred user interface tools,
- Record/Field Update Webhooks - needed to trigger our automation when the user updates data or submits column changes
- Table Schema, Record, Field REST API - required to “read” the table so nothing is hardcoded and makes for a reusable template
Beyond Data Extraction
Dynamic Prompts aren’t limited to just data extraction and can used to handle a variety of other scenarios. Every time you’re given a lengthy prompt or finding frequent prompt changes in your AI workflows, I hope you’ll consider Dynamic Prompts as a powerful design pattern in your AI templating toolkit. Here are some other use-case ideas - a few I’ve actually implemented already!
Structured Content generation - Instead of a PDF, just let the user use simple text context and use fields to generate partial content around a subject. Near the end of the n8n studio episode, I demonstrate this with cat breeds.
Flexible Web Scraping - Let users define URLs as rows and extraction values or questions as fields directly in the spreadsheet - where typically the data lands anyway. Doing it this way, cuts multiple steps out of a traditional web scraping workflow.
Comparing Items ie. Product SKUs - Need to allow users to a breakdown and compare attributes of items but don’t want to spec out what 5 different colleagues need from the data? Let them define their own columns!
Templates
Finally, I’m pleased to be able to share my free Dynamic Prompt templates so the n8n community can use them today. I have one for Airtable and one for Baserow (re: Baserow, should work for self-hosted and cloud versions). Here’s how to get your copy:
- Go and give my n8n Studio episode a like on LinkedIn and Youtube - your support means I can keep sharing more of these templates! Also follow @maxT (https://www.linkedin.com/in/maxtkacz/) while you’re at it!
- Give this post a like and comment if you’ve used this pattern before or if you’d like to but need help in figuring out how.
- Choose your template below
1. Dynamic Prompts with N8N and Airtable
Link: AI Data Extraction with Dynamic Prompts and Airtable | n8n workflow template
2. Dynamic Prompts with N8N and Baserow
Link: AI Data Extraction with Dynamic Prompts and Baserow | n8n workflow template
Conclusion
Many thanks to @maxT for having me on n8n studio for the chance to talk about Dynamic Prompts. If you’re looking for ways to bring AI workflows into your organisation, definitely give this n8n template a try - your team are guaranteed to be impressed (I hope!)! Need help setting this template up for your 50+ employee firm? Definitely reach out and let’s chat!
if you’ve enjoyed this article then please consider giving me a “like” and follow on Linkedin or X/Twitter . For more similar topics, check out my other AI posts in the forum.
Still not signed up to n8n cloud? Support me by using my n8n affliate link .
Need more AI templates? Check out my Creator Hub for more free n8n x AI templates - you can import these directly into your instance!