---
url: 'http://workflows-of-ai.com/blog/generate-newsletter-draft'
title: 'Generate Newsletter Draft'
author:
  name: 'Marcus Johansson'
  url: 'http://workflows-of-ai.com/about/marcus-johansson'
date: '2025-11-21T10:38:01+01:00'
updated: '2026-10-10T12:14:04+02:00'
type: article
summary: "Use the Views Automator from Drupal AI 1.2 to load last week's reviews into the AI's context and generate an HTML newsletter draft for email."
tags:
  - 'Marcus Johansson'
  - Workflows
  - 'Drupal AI'
image: 'http://workflows-of-ai.com/sites/default/files/previews/9fafd6ce038f93d1.jpg'
published: true
og:
  site_name: 'Workflows of AI'
  'image:width': '1280'
  'image:height': '720'
  'image:alt': 'Generate Newsletter Draft'
---
Drupal AI

# Generate Newsletter Draft

Let AI read a Drupal view of last week's laptop reviews and write an email-ready newsletter draft for a human to check.

  Marcus Johansson

November 21, 2025 · 2 min read

 ## About this video

In this workflow we will showcase the Views Automator that was included in the 1.2.0 release of the AI module.

In this case we have our fictional company Laptonia that makes laptop reviews, and we want to create a newsletter draft for last week's laptop reviews that should follow rules like absolute links and inner HTML that you often need for e-mails.

We will be using Drupal CMS 2.0-dev in this case and use the Views Automator that gives you a lot of flexibility in how, what and the design of the content that you load into the AI's context window. This is one of the things that makes Drupal special in terms of AI.

We will do a simple workflow where AI looks at a view of the latest laptop reviews and writes a newsletter about it.

Links
Drupal CMS: <https://www.drupal.org/project/cms>
AI Module (with Automators): <https://drupal.org/project/ai>
Workflows of AI: [https://workflows-of-ai.com/](/blog)

## Watch the video

[Watch on YouTube: Generate Newsletter Draft](https://www.youtube.com/watch?v=1xRgbAZ6yKk)

### Video chapters

- 0:00 A newsletter draft for Laptonia
- 0:36 Why the Views Automator matters
- 3:01 Laptop reviews in Drupal CMS 2.0
- 4:01 A view with a contextual filter
- 6:14 The newsletter preview content type
- 7:23 Dumping the view with Views text
- 9:35 Writing the email with LLM text
- 11:12 Generating the draft

## Transcript

YouTube's automatic captions, lightly corrected. Click a line to jump to that moment in the video.

### Transcript

- 0:01 This episode is sponsored by Freely Give. If you need help with Drupal AI, get in contact with us.
- 0:09 Hey everyone. So today we're going to showcase a super simple uh workflow. It's just going to create a newsletter preview. So something that's human in the loop based on in this case our
- 0:21 fictional website Laptonia that is laptop reviews. And it's going to create a newsletter for the last week's reviews.
- 0:29 In this case, it's going to be three reviews uh that got manually added into Drupal CMS.
- 0:36 The reason I'm showcasing this is not because this is something groundbreaking. I want to show something that's called the views automator that you can find in AI module 1.2. And this
- 0:48 is super powerful, not because of Drupal AI module, not because of AI, but because of Drupal and views. because this is such a powerful content listing module and it has two things that are
- 1:02 almost unique I think compared to a lot of other systems. So, one thing is that it allows you to create filters or arguments that are dynamic that the AI can use, which in this case we're
- 1:17 showing a workflow, but if you have a gentic AI uh later, this is crazy powerful because it actually lets the agent decide what it wants to look at.
- 1:29 uh and it does it in a safe way where you can set it up in the UI. So you're not dependent on someone writing like filters in code. You're not dependent on something even worse like uh uh you know
- 1:43 writing SQL queries or letting the AI choose the SQL queries. Uh and the other thing that's also super important, you can choose exactly the amount of context that the AI should see. And you can also
- 1:56 set this up in UI. This means that for AI where you might not actually be certain if you know if you show a whole article is it actually going to handle this or do I need to create a summary?
- 2:10 Do I need to maybe show just uh 75% of it? Uh how do I show the title? How do I show a link? You might need to experiment with this back and forth until you have the correct uh uh actual
- 2:24 output. And because of use this makes this iteration super fast. So that is the reason I want to showcase this workflow. So happy viewing. So today's tutorial will be actually very easy.
- 2:38 It's it's just a simple automator that creates like a preview newsletter based on your latest published content. So you don't have to start writing yourself. It
- 2:49 it basically simplifies a copy and paste example. But there it also showcases something that's extremely powerful which is the views automator. So what what I have here
- 3:04 is uh Drupal CMS 2.0. So it's still in development but I thought it would be fun to play around with it because it's going to be released probably uh start of next year. Uh where I have added I've
- 3:17 just based it on the basic page. So, in this case, we're the fictional uh laptop review company or laptop review web page Laptonia that creates uh laptop reviews like
- 3:29 this. And I'm just using the basic page for it. So, it's just laptop reviews uh uh with a image, a title, a description, and also some tags. And the tag laptop in this case is important.
- 3:44 It's important to know the ID of it, which is 17. And I'm going to showcase why. Because what we want to do when the newsletter gets created is that we want to look at
- 3:54 exactly the last week weeks laptops, right? So I have created a view now then that can showcase this. Uh it's very simple. It's just a title with H1 and a link. It's the featured image using a
- 4:09 specific image style I want to use in the newsletter. And it's the full content that the AI can look at. What's important then it's also we just want to show case published
- 4:20 once of course uh of the content type basic page and we want to show the last week but what's also important here we have added and this is just to showcase I could have hardcoded as a filter
- 4:33 criteria or I could create the exposed filter criteria to do the same thing that I'm showing here but I put it in contextual filter so if you scroll down to the preview we don't see anything
- 4:44 until we set which is laptop. So we we're filtering just on laptops because there is actually a terms of service that was published last week as well and we of course don't want that to be part
- 4:56 of the context of the newsletter we create. So that is and that is no so there's one more thing I've done. I've run the AI recipe as well which means that I have
- 5:08 to put put in in this case OpenAI key. So you can see I have the assistant here um uh usable because I have installed the recipe but in this case we're going to use the automators for
- 5:21 this. So this is not a agent task. This is something that's definitely automation.
- 5:27 And I I will also say I'm going to create a newsletter preview meaning that you can use something like Simplenews in in Drupal if you want but you can also use uh uh something
- 5:38 external I don't know Mandrill or whatever newsletter service you have just to create pre-create uh HTML that is uh based on AI it's I have a very weak prompt now you would have to create
- 5:51 a very good prompt to create something that is like 95% useful where you just have to scan through it and maybe change something. Uh but that's the idea. You create something that's for human in the
- 6:03 loop. It's not completely automated. That would be possible as well if you can generate something that's is on the quality level that you would want it. Uh after I've done this, I Oh, I want to go
- 6:17 to content types. That's what I want to go to and create a new content type. Uh we call it newsletter preview.
- 6:26 uh disable previewing in this case. Uh and we're just going to start recreating a plain text long. And this is what this is going to do. It's going to look at that view and just dump that information
- 6:41 into this uh text plane view. And this at first glance this might make no sense at all.
- 6:51 You might wonder why um why do you need to do this? can't you create the automator or something there there's like the views preview field you could use I think to look at it but the thing
- 7:03 is the the good thing I think with automators is that when you actually store every step it does it creates auditability so you if if the end result is weird you might go and look at like
- 7:17 what was it actually looking at at that time to understand what went wrong uh uh so we can just call this views dump or whatever you know this is just going to dump the view as it is but
- 7:29 we're going to do some uh changes to it so we're going to take enable AI automator type there's a views text this is the one that we're going to use and we're going to use then uh the laptop uh
- 7:44 latest laptops laptop uh yeah this this is in 2.0 we probably AI 2.0 Z, we probably will have a flag.
- 7:56 So, we can actually remove this because in this case, base mode and base field actually makes no sense. There's nothing it can do there. Uh, I'm going to set 99
- 8:08 and batch because so this is the weight of when it's running. We need one that actually writes the newsletter that's going to have 100. Batch means that we're going to do it in JavaScript.
- 8:19 In theory if you if you want this automated you can use ECA to trigger this and then you can use direct for instance uh we can use this also convert HTML to markdown it's just so it creates
- 8:31 less token so it's going to look at this HTML and it not using AI but in a dependent manner create markdown from it we're going to save this so there is a bug here so where I have to save before
- 8:45 I see the Ajax I saw uh so After you save, you get the argument expose filter. I'm going to create a a follow-up issue for this. Um, and in this case, we're going to say that the
- 8:59 argument of the field tags target ID, which maps to the first argument there, it's going to be 17. So, the laptop ID, right? So, this is a way where you can actually
- 9:11 uh create a view that's reusable. But not just this. This um also uses tokens from the entity which means you can have a automator that runs before this and this can be based on actual uh um it can
- 9:27 be based on dynamical things. So it t it's taking decisions on how you're going to render the view. Right? So we save this and then the next step is create a formatted text formatted long
- 9:41 that is uh newsletter preview. So this is the actual newsletter preview we want to show.
- 9:48 Uh this should be of allowed text format email but this we need to set on the automator as well. So LLM text simple.
- 9:56 Uh and in this case we take the base mode to look at the view stump. So that is what we're going to use as context.
- 10:03 I'm not going to sit here and write a long prompt. And this is still a weak prompt, right? Uh \[snorts and clears throat\] and we're working on getting context control
- 10:11 center in everywhere. So if you have a context from Context Control Center that you know has your writing guide, you should probably use that here also. How do we write newsletters maybe? Uh but
- 10:23 the the most important thing is this then the latest review laptops and that you use raw context. Raw context make sure that the HTML stays in there. Uh because HTML matters in this case we
- 10:35 want the actual image links. We uh we want the actual uh um links to the content as well, right?
- 10:45 We're going to extract the HTML. We're going to use batch and 100 meaning this runs after we have fetched the views which is important. And we're going to force the text format email.
- 10:55 Going to save this. Uh we can take in manage displays that we don't really want to show the view stump.
- 11:05 Uh, I like to keep the forms in the manage form display so we can actually see how it worked after.
- 11:12 And this should basically be it. So if we add a content newsletter preview, we can just call this 21st 11 2025. And these two should really be automatically generated.
- 11:27 So what's happening now? It's going to this views. It's adding the attribute that we want to add.
- 11:35 um dumping this into the first field and then there's a AI process that looks at the first field which is the latest laptops and writes a newsletter from this into a HTML field
- 11:49 um that has the filter format email and where we have said in the prompt that you should use typical HTML that is allowed in in the in a email which is not the same as everywhere else. So here
- 12:01 you go. Looking for an X laptop companion blah blah blah. It showcases this creates uh um creates links and as I said right now I I just used something very weak and you can try to
- 12:16 create uh something more complex and you can see it has used very you know it's using inline styles it's using absolute links to make sure that it works in a newsletter.
- 12:30 Um yeah, so that is the end product. It's this example might not help that extremely much. I mean you can copy and paste to ChatGPT every week if you want to write it. It just saves you maybe 5
- 12:45 minutes at tops. Uh but I wanted to show the views automators because there are so many use cases you can use this for.
- 12:54 Thank you for watching.

  Filed under [Workflows](/blog?category=6) [Drupal AI](/blog?category=2)

Parts of this content were produced by AI.

This site has not assessed whether a label is required for this content.

  How was AI used?The video and the introduction are Marcus's own, first published on workflows-of-ai.com. AI wrote the subtitle, the summary and the video chapters from the transcript, and corrected misheard names in YouTube's automatic captions.

   Marcus Johansson

Tinkers with AI and Drupal

 [About Marcus](/about/marcus-johansson)[Drupal.org profile](https://www.drupal.org/u/marcus_johansson)[Drupal AI](https://www.drupal.org/project/ai)

## The post in three sentences

The Views Automator, added in AI module 1.2, dumps a view of last week's laptop reviews, filtered on the laptop tag through a contextual filter, into a plain text field. An LLM text automator then writes a newsletter from that dump into a field with an email text format, using inline styles and absolute links. The draft is meant for a human to check, and storing each step keeps the result auditable.