Drupal Actions and Triggers

I get some comments on this site yet I was missing some since I don't check my comments "approval queue" regularly. I want to get an email when someone posts a comment. This is easy to using Drupal actions and triggers. This is built-in functionality for Drupal 6.

  1. Enable trigger module in "Core - optional" fieldset on /admin/build/modules
  2. Create new email action:
    1. Go to /admin/settings/actions/manage
    2. Select "Send e-mail" in "Make a new advanced action available" select list and click create button
    3. Fill in description, recipient, subject and message fields and click save button
  3. Associate trigger with new action:
    1. Go to trigger page: /admin/build/trigger (note that it will default to node triggers)
    2. Click on comments tab since we want to know when comments are created (/admin/build/trigger/comment)
    3. For the "After saving a new comment" trigger, select our new email action from the select list and click "assign" button
  4. Test it! In this case, create a comment for any node and see if you get the email. If not, check your email address in the new action you created. If that is correct, make sure that you receive emails for other things on the site like creating a new account (otherwise, your system may not be sending emails at all).

That's it. Getting Drupal actions and triggers configured with Drupal 6 is easy and very useful.

Comments

html tags in email

Hi Kristen,

In D6 admin/settings/actions I am using the action "send tokenised email" so that the email includes not just a notification but a copy of the comment itself. It works ok except that that the paragraph tags are not rendered so in the email the comment has no paragraph breaks but lots of open / close paragraph tags

Any idea how to fix this please?

Thanks...

Sorry for the delay!

Sorry for the delay... haven't been getting notifications of my comments :/

Have you tried an add-on html module like mimemail or htmlmail?

Is it possible to trigger an

Is it possible to trigger an action based on a date in a content record? For example, suppose I have created a content type called “Projects” that includes a Date field called “Deadline”. I want to be able to send an email when the current date is equal to the value of the date in that field — or better yet, when the current date is X days before the deadline date. If the latter isn’t possible, I could always add another field called Reminder Date and have the trigger look at that field…

Rules module

You should try the rules module as it makes it easy to do that kind of logic.

Just installed the Video

Just installed the Video Filter module with my new clean Drupal 6.1 website. Showed up fine in Site Building>module where I enabled it. Also in permissions. But no administrator tasks to set. Isn't showing up under create content or as an option under page or story. Can't find where to add my YouTube URL.
Checked help files, but no answer there.

Input formats

You need to include the video filter in your input formats... go to: Site configuration > Input formats and edit any of the input formats you want to include your video filter. For example, click "configure" for the Full HTML format and then check the checkbox for the video filter and save it. Then when you create content with that input format, you can add your [video:url] type notation.

A new comment has been posted on: [comment:site-url]

I just found other topics on other sites explaining how it's possible to use the "Trigger" and "Action" functionality built in to D6

I just set this up on my site to be notified of incoming comments and it works a charm - nice and simple too

Basically:
1. Enable the Trigger module
2. Administer > Site Configuration > Actions > "Make a new advanced action available" (bottom of built in action list) > "Send email..." from drop down
3. Fill out the form taking note of the system variables - the email address is the recipient, ie the webmaster / moderator
4. Administer > Site Building > Triggers > Comments "tab" (top of page that I completely missed for 5 mins, lol) > "Trigger: After saving a new comment" and "Trigger: After saving an updated comment" choose your action from the drop down (mine ended up under the "System" category

5. TEST!

PS Thanks for this page and all the others, there's some really useful stuff here, well explained too :D

thanks
regards,
sarah
http://page360.net/users/sarah

Thanks

I am a Wordpress user but am researching Drupal to see if it is something I want to take the time to learn and implement for some web projects this year. This is one more helpful post about Drupal and how to make it user friendly.

Thanks for the post
Bill

hey i just wanted to thank

hey i just wanted to thank you for all the useful information!!! i really needed it and this is what i needed to read. thanks again and keep on posting.

One of the few things I like

One of the few things I like about Drupal 6. The rest I don't like. Drupal almost always gives me a headache.

Customizing the trigger

I was able to set up the trigger to send emails when a new comment is posted. However, there are two places on our intranet where we use the comment feature: A suggestion box page and a project discussion page. We only want to send an email notification to the relevant group when comments are made on the project discussion page. Is this possible?

Custom triggers and actions

You could do it two ways:

1) Create a custom trigger like you suggest. I haven't created any before, but here are a couple tutorials:

http://scotthadfield.ca/2008/11/30/creating-custom-triggers-drupal
http://alexisyes.com/2008/11/19/how-write-custom-actions-and-triggers-dr...

2) Create a custom action. The action itself could be code such that it only does the action based on your requirements. After glancing at the tutorials above, this option may be simpler. Here are the hooks for that:

http://api.drupal.org/api/function/node_action_info/6
http://api.drupal.org/api/function/comment_action_info/6
http://api.drupal.org/api/function/hook_action_info/6

multiple recipients

Useful indeed. But how to send an email to more than one recipient? That would be very useful. Should I create more than one action? It doesn't work for me to enumerate different recipients...

Try commas

You should be able to put commas in between each email address in the recipient text field (not obvious but I've done this in the past and it worked).

Good luck,
Kristen

The Drupal system (6.13)

The Drupal system (6.13) won't allow it. Error message: 'Enter a VALID email address'. Not with a comma, comma-space, semi-comma... It really worked for you? No luck for me.

Tokenized email

I figured out what's up. I used it before for *tokenized* email actions. So, you'll have to enable the "token actions" module that comes with the token module and do the tokenized email action instead of the regular email action.

Good luck,
Kristen

Fabulous

Now I know when to check my site. Thanks so much.

Will I get an email?

I am posting this comment to see if I get an email sent to me. Posting (saving) this comment is the trigger. The email that is sent is the action.

is there a way...after

is there a way...after someone posts a comment, to check if the comment contains a list of keywords and if so...then send an email?

Custom action

I haven't seen a way to configure that through the UI, so you'd probably have to create a custom action for that. They are easy to do if you know how to program in PHP.

http://api.drupal.org/api/function/node_action_info/6
http://api.drupal.org/api/function/comment_action_info/6
http://api.drupal.org/api/function/hook_action_info/6

Good luck,
Kristen

Got it!

drupal actions and triggers email

Post new comment - ALL COMMENTS ARE MODERATED - SPAM WILL BE DELETED!

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.

I'm a Speaker at DrupalCon Austin

I'm a Speaker at DrupalCon Portland