Create an Auto Responder Automation

:discourse: This is a how-to guide for admins on setting up an auto responder using the Automation Plugin to respond to specific keywords mentioned in a post.

Given a series of keywords and associated replies, the auto responder script can respond to posts and personal messages with an automated reply.

Creating an auto responder in a Discourse forum can help automatically reply to posts that contain certain common keywords or phrases, freeing up moderators or admins to focus on more complex tasks.

For example, an auto responder could be created to respond to posts that may be against the forum rules by reminding users of the guidelines, or to guide new users by automatically responding to their first post with information about the forum.

Let’s take a look at how to setup an auto responder automation in Discourse.

Navigate to your site’s .../admin/plugins/discourse-automation page to get started.

Create a new script

From your automations page, click + Create to create a new script.

Select the Auto Responder option, and click + Create again to proceed.

Chose A Trigger

From here you will need to select which trigger you want to script the run based on, either Post Created / Edited or Personal Message Created.

These settings will control when and what your script will trigger.

Let’s take a look at what options each of these triggers has, and how they can be used to customize your auto responder script.

Post Created / Edited

This trigger will run anytime a post is created or edited.

Here are all the options available for customizing this type of trigger:

  • Action Type - (Optional) Limits the script to trigger only when posts are Created or Edited
  • Category - (Optional) Limits the script to triggering only if the post is within a specific category. Multiple categories can be selected.
  • Group - (Optional) Limits the script to triggering only if the post’s topic is a private message in a specific group’s inbox. Only one group can be selected.
  • Ignore Automated - A checkbox to skip the trigger if the sender has a noreply email or is from an automated source. This setting only applies to posts created via email.
  • Ignore Group Members - A checkbox to skip the trigger if sender is a member of the Group specified above.
  • Valid Trust Levels - Limits the script to trigger only if post is created by user in a specific trust level. Defaults to any trust level if no option is selected, and multiple trust levels can be selected.
  • First Post Only - A checkbox to limit the script to trigger only if the post is the first post a user created.
  • First Topic Only - A checkbox to limit the script to trigger only if the topic is the first topic a user created.

Personal Message Created

This trigger will run anytime a personal message (PM) is created.

Here are all the options available for customizing this type of trigger:

  • Users - Limits the script to trigger only for PMs sent to a specified user.
  • Group - Limits the script to trigger only for PMs sent to the selected group.
  • Ignore Staff - A checkbox to skip the trigger if sender is a staff user.
  • Ignore Automated - A checkbox to skip the trigger if the sender has a noreply email or is from an automated source. This setting only applies to PMs created via email.
  • Ignore Group Members - A checkbox to skip the trigger if sender is a member of the Group specified above.
  • Valid Trust Level - Limits the script to trigger only if PM is created by user in a specific trust level. Defaults to any trust level if no option is selected, and multiple trust levels can be selected.

Script Options

Once you’ve configured when and what you want your script to trigger, you’ll need to select a list of word / answer pairs for the script to use, and the answering user for the automatic reply.

The automation can also be set to trigger on every occurrence of the word or phrase, or it can be limited to only trigger once per topic using the Once checkbox. This can be useful to prevent spamming the same response in a topic where the trigger word or phrase is used frequently.

Word Answer Pairs

The word / answer pairs function as a way to set up automatic responses to certain keywords or phrases, and are an essential part of setting up an auto responder.

Click on the Configure button next to list of word / answer pairs to enter in your word / answer pairs.

Word answer pairs are a list of key/value groups, where the key is the searched term, and value is the text of the reply.

You can use the Copy icon on the upper right of each group to duplicate the group, and the plus (+) icon on the bottom right of the popup window to create a new empty group.

The key is the trigger for the automation. When this word or phrase is detected in a post that meets the When/What... requirements, the automation is triggered.

For example, if you wanted to respond to a post containing the word example you would enter in example for the key.

The key can also be left blank to respond to all triggers, regardless of content.

:person_tipping_hand: The key will be evaluated as a Regex, and special chars like . should be escaped if you actually mean a dot, eg: \.

You can test Regex expressions on https://regex101.com/ . If you do so, ensure you switch the regex flavour to ECMAScript.

The value is the response that the automation will post when the word or phrase is detected. This could be a pre-written message, a link to relevant information, or any other response you want to automate.

The value can also accept %%KEY%% as a placeholder to be replaced by the value of key detected in the reply.

The word/answer pairs are case-insensitive, which means the automation will trigger regardless of whether the words are written in lower case, upper case, or a mix.

Enable the Automation

Lastly, once you’ve finished configuring the automation, you’ll need to check the Enabled checkbox on the bottom of the screen to activate the auto responder, and click Update to save your changes to the automation script. :tada:

Automations can also be saved, and disabled for use at a later time, by keeping the Enabled checkbox unchecked, and still clicking Update.

6 Likes

Is it possible to limit the auto-response to the initial post for a topic? One might think that Once would do that, but (in obvious retrospect) that’s only correct if the topic is created after the automation.

Alternately (or additionally?), could the auto-post be back-dated to come immediately after the topic OP (and then merged in that order)?

My use case: replying to topics in a certain category with a new poll for that topic.