Drupal 8 Workflow Notifications with Rules Part 3

In previous posts I’ve covered enabling and editing a Workflow and then sending an email when a new content moderation state has been saved.

In this post we will complete the loop by sending emails when a content moderation state has been updated.

In this example an editor will publish the node and the rule will email the node creator to tell them it has been published.

Head to the Rules admin page /admin/config/workflow/rules and click Add reaction rule

This time we want to choose After updating content moderation state from the React on event select.

Adding a rules event for updating content moderation state

This time round we will need two conditions.

  1. Check the unchanged moderation state
  2. Check the new moderation state

Click the Add condition button and then choose Data comparison from the select.

For the data to compare value you can either use the data selection or enter


Then for the data value enter review

This is the moderation state the node was in before it was saved.

Now click save.

Moderation state unchanged data comparison condition

Add another data comparison condition then this time enter the following

Data to compare value


Data value


New moderation state data comparison condition

Next we need to fetch the entity so we can use it’s values in our email.

Back on the edit page for this rule click Add action and choose Fetch entity by id from the select.

For Entity type enter node and for the Identifier value enter


Then click save.

Now we can send an email to the node creator.
Click Add action and choose Send email.

In the Send to field use direct input and enter


This is a token that gets replaced with the users email address.

For subject we can just enter something appropriate such as Published Notification

For the message we will use the direct input mode an a token that provides the entity title

Your content {{entity_fetched.title.value}} has been published.

Email action

Save that and then save the rule.

As is often the case with Drupal it’s worth clearing your cache before testing.

Rules is still in it’s infancy for Drupal 8 but I feel it provides enough functionality and is well enough supported that it can be included in production site.

3 thoughts on “Drupal 8 Workflow Notifications with Rules Part 3”

  1. Hi Ian, thank you for your tutorial. One last rule is missing for my setup and I can`t get it. How can I inform the author via a reaction rule, if the last revision he made is deletet and the content stays on his published state?

    Maybe this isn`t possible with rules, but its worth a question to a pro 😉

  2. Hi Kay,

    Not sure off the top of my head. Hopefully I’ll have a bit of time later in the week to see if it can be done.



  3. Hi Kay,

    I’ve been looking at the rules and I don’t think this is possible at the moment.

    There are two reactions that I looked at but neither were triggered when I deleted a revision

    After deleting content
    After deleting content moderation state

    It would probably be possible to write some custom code using hook_entity_revision_delete

    Hope that confirms your thoughts.


Leave a Reply

Your email address will not be published. Required fields are marked *