---
title: "Pre-moderate content"
video_id: WsgKVJw3Dvc
url: https://www.youtube.com/watch?v=WsgKVJw3Dvc
workflow_page: https://workflows-of-ai.com/workflow/pre-moderate-content
language: en
captions: generated
---

0:00 this episode is sponsored by uh freely
0:02 give if you need help with Drupal n Ai
0:04 and consultancy around it just get in
0:06 contact with
0:08 us so hey there Marcus here uh what I'm
0:12 going to show today is how you can use
0:15 the Drupal buil in moderation State and
0:17 have AI Control it automatically so you
0:20 can do a pre-screening of content where
0:23 basically AI can tell that okay this
0:26 should probably be flagged or this
0:28 should probably be allowed to be
0:31 published um so you can you know put
0:34 your content in the hands of unior
0:36 editors or even the the actual end
0:40 user uh to be able to do this we're
0:42 going to use the AI module as usual
0:45 we're going to use automats as it's
0:47 called now so this if you have followed
0:50 my channel you have seen a lot of videos
0:51 about the ai interpolator ai automator
0:54 is just the basically AI interpolator
0:58 2.o uh with a lot of new functionality
1:01 and I'm going to show one piece of that
1:04 new functionality here so you need to
1:07 get that uh the thing I added here is
1:10 still not in uh the Alpha version so you
1:13 would have to get the dev currently
1:15 until Alpha 9 uh exist and you would
1:19 need this file base field override UI so
1:22 I'm going to show you what this does the
1:24 the cool thing with this is that you can
1:25 use the automats on builtin fields like
1:29 the moderation stat this you also need
1:31 the token module for the AI automator to
1:35 work uh so the only thing I've done on
1:37 this website I've logged into it I've
1:39 added a key for open AI I'm going to use
1:42 open AI in this case you can use any
1:44 provider that you want uh but I'm going
1:46 to Showcase this with open a and I have
1:50 added admin toolbar as you can see and
1:52 that's it so I'm going to start adding
1:55 stuff here so what we need is the AI
1:57 Core we need the AI automats we don't
2:00 need any plugins for the AI automats
2:02 just the core one is will be able to
2:04 handle this open AI provider uh and then
2:09 we also need to add the base field
2:12 override UI and that's it so if we
2:15 install all those that is going to be
2:18 enough oh no of course we need to
2:21 actually install the content moderation
2:23 module that takes care of the moderation
2:25 State as well so this is just a standard
2:28 installation it comes with a article um
2:32 article right so what we're going to do
2:35 is we're going to go to
2:37 workflows and we're going to change the
2:39 editorial workflow and first of all
2:43 connect it then to our
2:47 article but then we're also going to add
2:50 two new
2:51 States so we're going to add one that's
2:54 called flagged that's not going to be
2:57 published of course that basically means
2:58 that AI has flag this because of
3:03 whatever criterias you set it to flag on
3:07 uh and when it's flagged basically an
3:10 admin should have to go in to put it
3:12 into pre-published as we're going to
3:14 call the new
3:17 State uh because of course AI doesn't
3:20 always get stuff right sometimes it's
3:22 wrong and then it's good that a human
3:24 eye goes in and looks at it but it's at
3:27 least good to get uh initial View
3:30 uh of what's working and what's not
3:33 working so it's going to it's still
3:35 going to start at draft but directly on
3:37 draft it's going to either be
3:38 pre-published or be
3:40 flagged uh and to be able to do that we
3:43 have to add some transitions here which
3:46 means that uh when it's adding a
3:50 draft it's not allowed to go published
3:53 draft goes to
3:55 draft uh and then published only comes
3:59 from
4:01 pre-published uh in this case so it has
4:04 to be pre-published before it can be
4:07 published uh and uh archive can still be
4:12 published to Archive restored to
4:15 draft Yeah archive could go to draft
4:19 archive could go to publish all that is
4:22 okay we're going to add a new transition
4:24 how it becomes pre-published and that
4:27 comes from draft
4:32 uh and add the same for flag
4:38 then so flagged can come from draft as
4:44 well and uh let's see here
4:48 from from flagged we need to be able to
4:52 push it to pre published as well so in
4:55 the pre-published we're also going to
4:57 say that it can come from the flagged
5:00 can be uh given back from published of
5:04 course as
5:05 well uh and we have the draft as the
5:08 default so we set all
5:10 this go to our content
5:14 type
5:16 um
5:18 and uh here we have our Fields but
5:21 because we added the base field over
5:23 right we get the extra tab here with
5:25 actual field overwrites of Base Fields
5:28 you can do and this is what we're going
5:30 to work with so we're going to use the
5:31 moderation State here we click add
5:33 meaning that we want to take over this
5:36 after we have added it we can click edit
5:38 and then the automator will show
5:41 up
5:43 um
5:45 oh okay I I should actually fix this
5:48 error message so the problem is this I
5:51 actually forgot something we need to
5:53 actually uh set up the provider of
5:57 course so I'm going to select the key
6:00 open AI key connect that save and this
6:04 now sets a lot of defaults if you're on
6:06 new site where basically takes over a
6:09 lot of operation types now if we go back
6:13 here and go to the base field overrides
6:16 hopefully there's no error message
6:18 anymore can enable the AI
6:21 automator and now we can basically
6:25 either you know use a lot of fields but
6:27 in this case we just use the body field
6:29 so we're saying if uh the body field
6:34 contains something that we don't like so
6:37 I'm just going to take a very uh weird
6:41 example now I can't think of anything
6:43 but if the text you see is about Lord of
6:49 the
6:50 Rings make sure it
6:54 gets flagged right so you can copy this
6:58 uh placeholder
7:00 otherwise it
7:02 can
7:04 be pre-published so we want it to go to
7:08 pre-published
7:10 and uh we just use text we do like
7:15 this
7:17 separation and we copy the context so
7:21 it's going to read this text that is the
7:23 body of the article if it's about Lord
7:26 of the Ring it should get flagged
7:28 otherwise it can be pre-published
7:32 right uh and we can just keep all this
7:36 as it is what is is important are these
7:40 settings so I'm just going to start with
7:43 uh not going through these two I'm just
7:45 going to set that it triggers when it's
7:47 draft that's important so normally a
7:51 automator is triggered when it's uh the
7:54 value is empty but this value is never
7:56 empty so you have to tell it when should
7:58 you trigger it and you always trigger it
8:00 when it's a draft so if you actually
8:03 want draft you should probably add a
8:05 pre-draft or something like that so you
8:07 actually can have a draft as
8:09 well um so I save this now and I just go
8:15 to create the article and uh my new
8:21 article uh yesterday yesterday I ate
8:26 pudding this shouldn't be flagged right
8:29 so if I save it
8:34 now uh you can see it becomes
8:38 pre-published so we try the same thing
8:40 again here um yesterday I met
8:46 colon so you can see I don't use the
8:48 word Lord of the Rings AI is SM to
8:51 understand
8:52 context
8:54 uh and save it and now it should then be
8:59 flagged because this was talking about
9:03 uh Lord of the
9:04 Rings so that that is a initial way you
9:07 can set this up but there is actually
9:10 more to it
9:11 because uh as I said it might not always
9:15 be perfect and you might wonder why did
9:17 it do what it did so what you can
9:19 actually do is create a new plain text
9:21 long it has to be a plain text
9:24 long uh and call it uh uh State
9:27 moderation reasoning or or something you
9:29 can call it whatever you want of course
9:33 reasoning uh you just save this this
9:37 field of course you should hide for from
9:39 the end users I can't do it here just to
9:41 show you how you do it so they don't see
9:44 it it should just be part of the uh
9:47 actual uh forms you forms you see right
9:53 um and when you have added that you can
9:55 go back to the moderation State and you
9:57 can actually tell it in the bottom that
10:01 you want to store the explanation and
10:04 you get all the long text field so we
10:05 just say we want to store this in state
10:07 moderation
10:09 reasoning and I will showcase this again
10:13 now then so I create another article
10:15 oops
10:18 colum uh I met colum yes
10:24 day uh and you can see you see this
10:27 field it might be that if you don't want
10:29 to expose this to the editors that you
10:31 know you have to have like uh for uh
10:34 field
10:35 permissions but I mean you get the idea
10:38 behind this so now it got flagged if I
10:40 click edit now you can also read here
10:44 the text mentions gum a character from
10:46 Lord of the Rings therefore it should be
10:48 flagged so you get a
10:51 reasoning uh and that is it I will
10:56 explain the last thing that actually
10:59 exist there that might also be
11:01 interesting
11:03 because uh I mean this is fine when you
11:06 actually want AI to read through
11:09 something very nuanced and uh have a
11:13 deep understanding of the text you know
11:15 then open AI anthropic CLA uh llama gem
11:20 llama you know 45b or gemini or
11:22 something are great for this right but
11:25 they send the data so if you're if if
11:29 you have other reasons why you want to
11:31 stop this like this has personal
11:34 information of course you don't want to
11:35 send this to open AI because that's
11:38 personal information right
11:41 so there is another mode in here uh so
11:45 usually the automats are pretty complex
11:48 they create complex Json so they need a
11:51 model that is mediumsized at least
11:54 um but there is this thing you can do so
11:57 you can do use small mod
12:00 model uh and basically look for these
12:04 states so you're looking now for
12:05 pre-published and
12:07 flagged uh and
12:10 what's and you can actually still store
12:12 the explanation so what's going to
12:13 happen now is that you can use a like a
12:17 local model like gamma 2B or v um V3 2B
12:23 V3
12:25 1B that are so small that they can even
12:28 run on a Raspberry p I they are not
12:31 super good at creating Json they are not
12:35 super good at answering exactly as you
12:37 want but they are fairly good at
12:40 understanding text and what you want to
12:42 have read out of the
12:44 text uh so what is happening here when
12:48 you say that it should be looking for
12:50 flagged or pre-published what it's going
12:52 to do it's going to take the whole
12:54 answer that might be something like uh
12:57 yes I can look for this
12:59 it seems like they mention golum that is
13:02 part of the uh Lord of the Rings
13:04 therefore this is flagged and when you
13:08 when you use this it's basically going
13:10 to look for the word flagged anywhere
13:12 and if it finds the word flagged it's
13:14 going to flag it same with pre-published
13:16 word then uh and that way you can have a
13:20 a first screening that actually runs
13:23 locally that's not sent to some third
13:25 party which means that you can uh you
13:28 know know check for pis and stuff like
13:31 that without having any privacy
13:34 concerns um yeah so that's how the state
13:38 moderation automator works thank you for
13:41 watching
