I Built a Team of Research Agents for Newsletter Automation in n8n (No Code)

Dr. Violet Howard builds a no-code newsletter automation system in n8n using five AI agents: one crafts a table of contents, another splits it into sections, six research agents gather and cite sources for each section, an editor formats everything, and a title generator creates the headline. The finished newsletter goes straight to Gmail.
Chapters
Today I'm going to be walking through a super cool multi-agent framework that does all aspects of creating a newsletter for you. All you have to do is enter a topic, a tone, and a target audience, and then it's going to do everything as far as planning it out, doing the research, writing the actual newsletter, and then sending it over an email. As you can see, we have 5 AI nodes here. We've got a newsletter expert, a project planner, a research team, an editor, and then a final node to create the title before it sends it off. And so in this build, we're using something called a sequential agent framework. As you can see, we have 5 different agents and the process starts with the form trigger and then it goes through sort of in that chronological order all the way to the end. Unlike something like some of my personal assistant builds or other AI agent builds on this channel where we have like a main agent and then that agent has sort of child agents where this agent takes an input and decides which tool to use based on the input. It's gonna be variable. It may not be the same order every single time, but in this case, This framework, it's always going to be the same because this newsletter expert sort of plans out the table of contents, then this one plans the different sections to split out to the different research agents, and then the editor gets it at the end, formats it together, gets all of the links and the sources correct, and then finally we create the title. So each agent specializes in a specific task, which is going to help us get more consistent results over time because it happens in that specific order every single time, and that's sort of fixed. So they work together and they're able to produce some really cool outcomes. As you can see here is a finished product. The title of this newsletter is The Critical Role of Mental Health in Enhancing Business Success. So I entered in the form response here that the topic was going to be mental health, the tone is professional, and the target audience was business owners. So as you can see, we've got 1, 2, 3, 4, 5 main sections here. There's different sources within each section. It's referencing different information, so we can click into here We can see exactly where this information is coming from, which is really cool. And then at the bottom, we've got a sources section with all of the sources that it listed that we can once again click into if we want more information, which is just super cool. But anyways, if we were to read through all of this, we'd see that it's really tailored towards business owners. That way they could sort of scan each of these headers, and if they wanted more information, they would be able to click into one of the sources that we have right there. Super, super easy. And yeah, super helpful if you want to just be able to send out some quick stuff maybe to your employees or to your team. So there's a lot going on here. Obviously, there's like pretty much 4 different prompts that we have baked into this workflow. So, um, I think the best way to dive into it is really just to submit a form and then watch the process go through from start to finish. So before we do that, I just wanted to say, if you want to download this workflow for free, you can go ahead and do that with the link in the description. You'll join my free school community, click on YouTube resources, and then you're able to get in here and click on the post associated with this video. And then you can click on the JSON right here to download. And all you have to do is import it right up here from file into your N8N environment. And if you're looking to take your skills with N8N and AI automation a little farther, a little more hands-on approach, feel free to check out my paid community. We've got a great community here, people always asking questions about N8N, sharing resources, a great classroom section with different deep dive topics, as well as a calendar with 5 live, live calls per week. Make sure you always get your questions answered. You can get unstuck. So love to see you guys in these calls. And finally, if you're looking for AI consulting or you want me and my team to help you deliver a project for you or your business, then please go to my website and book a call there and we can chat. Anyways, like I said, the best way for us to actually understand what's going on here is by doing a live example. So we're gonna hit test workflow, the form submission is gonna start listening, and then the form pops up for us to fill out. Like I said, we have topic, tone, and target audience. So what we're gonna do here is for topic, I'm gonna go with health and fitness. For the tone, let's just go with professional again. I played around with a few funny ones and it throws in some jokes and stuff there, but let's keep this one professional. And And for target audience, we're gonna make this one targeted towards teenagers, or actually let's say young adults. Okay, so we're gonna send this off and we should start to see the workflow taking place. So the first thing it's doing is hitting the Newsletter Expert. So this uses a combination of Tavily and GPT-4o Mini. And what the Newsletter Expert is doing is it's looking at that form response and it's going to basically create a table of contents. It's gonna structure the newsletter very well. And then it hands off that table of contents to the project planner. The project planner then takes that table of contents and splits out different items— or sorry, different titles and descriptions for the different sections of the article. Looks like it did 6 of them. As you can see, 1 item left the project planner and then it split out 6. And so what's going on here is we basically have 6 different agents doing research because right here, as you can see, we got 6 titles and description pairs. And then basically each research agent is going to grab one of those and then use Tavily as well as Anthropic Claude 3.5 to do research on those different title description pairs. Um, so right now they're doing research, they're hitting Tavily to pull back articles, get the URLs, and it's going to then merge back with the original title description pairs. So in this merge node, once the research agent team is done, we're going to have 6 items of article content with URLs, title, description, which is then going to get aggregated and fed back into— not back into— fed into the editor. And the editor's job is to pretty much put it all together in a newsletter structure, make sure it all flows nicely. It's going to make sure that we have our inline citations that are clickable. It's going to put everything in sort of like the HTML format, so then the section headers are bold and all that kind of formatting stuff. It's going to add a sources section at the bottom like we saw in that demo. Where we'll be able to click on all the sources that are mentioned in this newsletter. But, um, yeah, so because the research team— each agent has to focus on just one section of the article rather than the entire newsletter, they're able to do a better job because they have just a specialization and they're not worrying about the prompting of how does the newsletter get structured, how does all this happen. All it has to do is get content, and then the editor worries about that, and then finally we pass off the final version to the creating title node, and then it gets sent off in Gmail. So let's go look at the finished product from this run. Okay, here we go. So we got the Future Fitness Trends, Nutrition and Health Insights for Young Adults. So we've got 1, 2, 3, 4. So it looks like the editor only decided to keep 4 of the 6 sections. The Shifting Landscape of Fitness Trends Young Adults Should Know. So if you're interested in that, you probably scan this. You may be able to see, oh, Amazon's offering up to 40% off on treadmills and walking pads. That's pretty cool. You can click onto that if you want more information. Nutrition 101: Superfoods for Optimal Health. According to a Consumer Report, this green superfood can help combat oxidative stress. Okay, mental health and fitness spotlight on emerging health risks. Let's say we wanted to click into this research report by Business Insider where it's talking about— looks like it was talking about colon cancer in young adults. That's not fun. And then, you know, we've got another one down here with This Italian evening ritual has major health benefits. Here's why you should try it. So as you can see, we've got our links that we're able to click into, which is super cool. We've got our bold headers right away so we can sort of scan and see what articles we actually want to read. And yeah, that's pretty much how this one's gonna look. I also changed the sender name in Gmail to Daily Newsletter. Obviously it's just one of my emails, but just a taste of if you were wanting to set up some sort of automated newsletter and you wanted to be able to send out to lots of people. You could even set it on some sort of schedule. You could have the trigger be a database where you just have a ton of rows of topics, tones, and target audiences, stuff like that. So it's really, really going to be flavored here towards the stuff you put in, but you don't even have to put in too much information, which I think is super, super cool. So yeah, let's go back into AnyDen and let's actually look through each of these nodes now, and we'll talk about the prompting a little bit. You may feel like I'm going through this stuff really fast, and I apologize for that, but definitely the best way to actually really understand what's going on here is to download this workflow. Like I said, you can get it for free on my FreeSchool community, link in the description. Download the workflow, test out a few form responses, and then just look at each node and see how information is passing through, just like we're about to do here. That's the best way you can sort of learn what's going on. So obviously for Tavelly, we're sending that off to a different tool. We, we see this right here. I'll dive into this in a sec, but right now let's just focus on sort of how the data's moving through sequentially through this workflow. Like we talked about, this is a sequential agent framework, and then from there we'll look at sort of like the prompting and everything. But okay, so first and foremost, like I said, this, this workflow gets triggered by a form response. Um, this is what we entered into the form. Health and fitness is the topic, professional tone, young adults is the audience. So from there, we're passing this into the newsletter expert. So real quick, if you don't understand the difference between, um, sort of a user message and a system message, system message is down here. This is the instructions that we're prompting the agent how to act, its role, its instructions. Um, this is just the way that you're doing things. And then as far as the user message, this is going to be the input that's kind of dynamic that we're feeding in based on the form response. So as you can see here, we are giving the Newsletter Expert the topic, the tone, and the target audience. And then in the system message, here's what we're saying. You're an AI agent responsible for planning the sections of a newsletter by creating an engaging table of contents tailored towards the newsletter's topic, tone, and target audience. The newsletter will vary in topic, tone, and target audience depending on your request. Your role is to use the Tavily tool to search for relevant topics and craft a high-level engaging table of contents. The table of contents should resonate with the target audience and encourage them to read the full newsletter. And then we're just giving it instructions. We have our tool, of course, different examples of what an input might look like as far as like topic, tone, all that kind of stuff. Honestly, this is probably way more information than we actually need in a prompt for this agent-specific function. It probably could have been done with like this much text, but I was just using my, my, my AI agent GPT where I just said, hey, this is an agent that's going to take these form response parameters and then create a table of contents. So that's what it spit out for me. It's Markdown. If you want to test it out, you can get it in the FreeSchool community. But honestly, I would probably shorten this because you don't need it that much. All it's going to give you is sort of this table of contents. As you can see, it gave us 6 sections. And then yeah, that was pretty much it. It used Tavily to go out and do an initial search just to see like what sections or like what's relevant that it could make sections about. So that's why we connected this tool to Tavily as well. And then it passes that information to the project planner. Um, as you can see here, we just have a system message. So this one's a little bit different. It's an OpenAI message and model node rather than using an agent because we didn't really need to hook up different tools and we didn't need like memory. Um, we're just passing one thing in. So let's take a look at this prompt. It's, it's a lot more simple. Your job is to split out the table of contents into an individual item for each section. Output section— output each section separately in a field called newsletter sections. And we just wanted to define that so sometimes it wasn't coming out as like contents or sections or headers or something like that, so that way we could reference it later, obviously. But anyways, when doing so, keep in mind that the newsletter target audience is young adults in this case, as you can see on the result side, and the tone of the newsletter should be professional. Here is the table of contents, and then we just output the output from the Newsletter Expert, which has the 6 sections right here, as you can see. So the output looks like this. We have message.content.newslettersections. So that's just sort of the JSON schema to get here. And then we have 6 items listed 0 through 5, and it's just title-description pairs. So as you can see, we're able to split that out from the input. Now we have 6 items of title-description pairs, and then what's going to happen is we're going to feed off this one to an agent and then feed off this one to an agent and feed off this one to an agent. So we're really doing a team of, in this case, 6 agents that are going to do research for us. So we're splitting that out into this team of research agents. We're giving them the title, the description, and then the target audience that it needs to tailor its post to, as well as the tone, which in this case is professional. So here is the prompt for the research team. Let's take a look at it. You are an AI agent responsible for delivering only the final content for one section of a newsletter. Your role is to produce concise, well-researched, and audience-tailored content based on the provided inputs with no prefacing statements or explanations. So for context, you have all the necessary details. You want to create engaging content. Um, your content must be supported by research with sources clearly cited using hyperlinks. So one of the toughest parts about the prompting of this and the editor was to actually get those URLs back in a way that we could actually click on them through the email and get them consistently formatted. Um, so now we kind of figured it out, right? Anyways, it's, we gave it instructions, we gave it the tool, which is just one Tavli tool. Um, and then we sort of defined right here, citation guidelines, use Tavli tool to gather information, cite sources. For each major claim or piece of information, include a hyperlinked inline citation. Format citations as HTML links with descriptive text. And then here's sort of the way you format it, HTML. And then when directly quoted from a source, use quotation marks and include the citation. So, um, that's pretty much what we're giving it here. As you can see over here on the output, it's giving us like article content. You can see like right here, here's how it references a article. So this is an article right here, and if we were to click into here, we could see that it is the page— if my computer wants to load it— there we go. So we can see this is the page that it was talking about, and it scraped the information from, and then it made this section of content because of that, that URL. Um, so real quick, let's look at the actual Tavelly request. So what's cool is this is what we're getting back. When the agent goes off and decides it needs to use Tavily, we're getting source 1, here's the URL, and then here's the content from source 1. Source 2, here's the URL, and then here's the content from source 2, and so on and so on for each of the 7 runs that it did. So that's how it's getting information. And then like I said, it's going to merge its output with the split-out titles and descriptions from that project planner. So we'll click into here, we'll see what it looks like. As you can see, we've got 6 items. and they all have an output, a title, and description, and they align. So the shifting landscape of fitness, the shifting landscape of fitness, all this kind of stuff. So this is kind of how the agent used these title and description to create this output. And as you can see, it did that for each of these 6 items. And then we're also, for the research team and for the editor, we used Anthropic Claude 3.5 rather than GPT. Okay, so then we had our 6 items and we want to aggregate them. Now they're back into one list of titles, outputs. From here, we need to give the editor these titles and outputs to actually create the content. So that's all we gave it was list of our list of titles, list of article content. As you can see, this is what it looks like. And now let's look at this prompt. So I made this one, um, I sort of hand typed this one out rather than using the GPT. Because like I said, there was a lot of testing here and it had to be pretty specific. So anyways, the prompt here is that you are an expert editor specializing in creating and refining content to output a high-quality formatted article. You're given a list of titles and outputs, and you will use these to create a newsletter tailored towards the Define's target audience. Create a section in the article for each title with a hyperlinked source in each section based on the content. So your objective, just 3 things, keep it simple. Create content for each title. Using the provided content. Simple. Each section should contain inline citations, and then I put in asterisks, don't leave any out, because before that it was maybe like some sections would have them, some wouldn't, and I wanted every section to have them. So don't leave any out. And then improve the flow of the newsletter and format it for readability. Sometimes like bullet points were being weird, so just threw that in there. As far as citation management, I put preserve all inline citations, standardize your citation format, ensure citations don't disrupt the flow of reading. For the source section at the end, create one source section at the end, format each source consistently, include the complete URL, organize all by alphabetically in alphabetical order, and then verify that all links are functional. And then the output format should be structured as HTML that will be sent through email. Do not output a title or an introduction. The output should start with, uh, the first article heading. It was sometimes outputting like, great, I was able to take your lists and here's the newsletter. And I didn't want that, obviously. Or it would say, or we create a title, but we have a node that's going to create a title. So anyways, yeah, so that's pretty much it. And then we just put important to output 1,000 words max, or else the automation breaks. Sometimes it was trying to output too much and then the sources section would get cut off and it wasn't in the output. And I was a little confused. I thought I was prompting it wrong. Then I realized there was just like a cutoff. So anyways, then I threw in today's date just in case it needed to say something current. So that's what the editor looks like. As you can see, we've got it formatted over here in sort of that, that HTML format. And then finally, we just fed it into this GPT-4o Mini message model node. It's a system prompt where we said create a title for the incoming newsletter. The tone of the newsletter is professional. The target audience is young adults. Here's the newsletter. And then we just give it the whole newsletter. and then at the end we just said output the title in plain text, no quotation marks, capitalize the first letter of each word, and then we gave it an example of how that looks, and now we're getting it like that. So that's pretty much it. Um, as far as sending it off in Gmail, I just put a fixed Gmail for now, um, rather than putting in an expression. The subject is just the title that we got from that previous node. We want to send this off as HTML rather than text, and then the message of course is going to be the output from that Editor. And then I just changed the sender name and I turned off append NNN attribution. That's basically it. So obviously there are a lot of different ways that you could really go into your— what happens to start this process and how does the process end. If you wanted to automatically post it on, you know, LinkedIn or some sort of blog website, or if you didn't want to capture it in response, like I said, if you wanted to have an Airtable with a ton of topics and every morning it would just run one, that could be super cool. So there's different ways, but this is sort of the main bulk of the logic that we have here. So now obviously the part we need to actually do the research, and we do— we're doing that using a workflow that we built in NN called Tavily. We're just saying call this tool to search the internet, and this is referencing a tool that we built called Tavily tool, as you can see. So let's go over to Tavily tool, click on executions, and let's just look at how they come through. So for that previous run that we just did, it probably, it ran 7 times, I believe. So 1, 2, 3, 4, 5, 6, 7. These are the 7 runs and we can just see real quick. The first one came through and was health and fitness trends for young adults 2023. The mistake here is that I didn't tell them, because this was sent by the newsletter, this was sent by the newsletter expert because it was trying to get some trends to make a good table of contents. And now I realize In here, we also need to give this guy the current date and time. So because as you can see, it thought it was 2023. So now that won't happen. Um, but luckily nothing really changes too much. But that's what the first query that got sent to Tably was. And then these next 6 were the research agents each sending off a request to get information. So the first agent sent off Latest fitness trends for young adults, including boutique gyms and outdoor workouts. The second one sent off superfoods for optimal health benefits for young adults. Third one sent off, um, mental health benefits of exercise. So as you can see, um, young adults, it knows how to send off very tailored queries. And then let's actually take a look at one of the examples in the editor. So let's go to this last one. Um, recent inspiring stories of young adults transforming their health and fitness with significant lifestyle changes. We'll click copy editor, so it's going to pull up that run basically within our editor environment. And now let's look at what we're doing in Tavelly. So doing a POST request to Tavelly, it's an API. Um, I think if for free you're going to get like 1,000 searches, so it should last you a while. And this is the base URL that we're accessing. As far as the configuration, all we're sending is a JSON body. So pretty cool, it's not even that in-depth. You're going to put an API key and then you're going to change the query. So this is the only thing I'm changing here. As you can see, all all we're pretty much putting in the query is the query that's coming in from the execute workflow trigger right here. So we drag that in there, we just do some formatting to make sure it always comes through as a string, as valid JSON. We're getting max results 3. I had it first set to 6. I liked 3 a lot better. It also was quicker and we're still getting lots of sources back. Of course, topic is news, all this kind of stuff. If you go to Tavalley, right here is the API documentation. You can see the other parameters you need to set up, which is pretty cool. So if we go to examples, like, there's, there's a lot more ways that you can get stuff back. And yeah, it's pretty cool. I was actually at the wrong one. So here's the endpoint. This is the base URL. We wanted to do a search because we're doing a POST request sending over information. You can choose a time range, you can choose all this kind of stuff. And I just kept mine very simple, but if you want to get more detailed in there, you can definitely go in there and play around with it, which is pretty cool. But anyways, that's all we're sending off. And then as you can see, the output— we've got our query, and then we have a list over here, which is— let's go to JSON so you can see it better, actually. So I said I want only 3 results back. As you can see, we've got 3 results. Here's URL 1, here's URL 2, here's URL 3. And then we get like raw content, title, date, content. And so from there, what we do is we're just sending over that response back to the AI agent, or yeah, sorry, back to the research team agent. And all I did here was I specified the 3 sources we're getting back, and then I just said, here's the URL and the content for source 1, here's the URL and content for source 2, and then same thing for source 3. So this is what it looks like. It's going to be super clean. It's just going to be a quick snippet because we want the newsletter to be, hey, you know, this is an article, or this is a section about this stuff. A quick blurb. If you want to learn more, click on this link. So that way you're able to scan and see a ton of stuff in shorter amount of time. Anyways, that's going to be it for this one. I hope you guys enjoy. This is a bit of a different build than some of the other ones I've done, but I really enjoyed this one. And I think that this actually could be a really cool use case, um, when you get in there and you refine a little more things and you make it a little more automated with the way that you have the workflow triggered. Um, but yeah, like I said, I really enjoyed making this one, and I know I went quick, but, um, if you can download the workflow for free, you in my school community, you can really get in there, you can read all the prompts, you can understand what's going on, you can look at the executions and see the way data's moving through each step, which truly, like I said, is the best way to learn. So as always, thanks for making it to the end of this one. If it helped you out or you enjoyed it, please leave a like, definitely helps me out. And I'll see you guys in the next one. Thanks.










