Rules

Prerequisite: Tutorial: How to AutoTweet from Joomla in 5 minutes

If you are looking for a way to simply publish content from some categories or exclude some categories, most plug-ins have a "Filter" to define included/excluded categories. Firstly, check the associated plugin, "Filter" tab, to filter by category. Moreover, this option avoids any further processing, not generating new requests.

You can access this feature by clicking on Rules in the toolbar links area of AutoTweetNG or Joocial.

Out of the box, AutoTweet is set up to publish Posts into all Social Channels. However, this is not what most users would like. These are some classic examples:

  • Only publish posts from certain categories
  • Publish messages to certain channels
  • Conditional publishing, for example, publish posts containing some keywords

Some cases can be solved just with a filter at content plugin level, but in this section, solutions based on rules are presented.

Rules allow selecting plugins and channels to post by category, text terms, author and more. Rules are only needed when you will do particular posts. If you will post messages to all channels there is no need to add rules.

The rules engine works processing requests from the list to create posts, when they are on the way to the social channels.

Available operations:

  • New: operation to create a new rule.
  • Edit: a rule can be edited to modify its attributes.
  • Publish / Unpublish: operations to either publish or unpublish rules. Unpublished rules are not executed.
  • Copy: a rule can be copied, to be duplicated. For example, to create a similar rule for each channel.
  • Delete: a rule can be deleted to avoid any further processing.

AutoTweetNG and Joocial - Control Panel

Each rule has the following options:

  • Rule name *: only informational.
  • Source *: which integration plugin this rule applies. Autotweet as source refers to manual posts created by Autotweet itself.
  • Type *: rule type to be applied in the execution.
  • Condition: some rule types require an additional parameter. For example: category: IN requires a list of category IDs 11,22,33,44.
  • Channel: which channel this rule is applicable in. If empty (the "- Select -" pseudo-option of the channel list) it applies to all channels.
  • Status: if set to Yes, the Rule will be applied. Otherwise, it will be ignored (as if it weren't set at all)

The following rule types are executed only if the article attribute is either included or not in the associated list of values.

  • access: IN
  • access: NOT IN
  • author: IN
  • author: NOT IN
  • category: IN
  • category: NOT IN
  • language: IN
  • language: NOT IN
  • featured: IS
  • featured: IS NOT
  • media: HAS
  • media: HAS NOT

Additionally, "Only Featured" filter allows restricting the rule to featured content.

These rule types are oriented to solve cases where a word or sentence has to be matched to execute the rule:

  • term: AND: apply when ALL terms from the list are included in the message text
  • term: NOT IN: apply when NONE of the terms from the list are included in the message text
  • term: OR: apply when ONE of the terms from the list is included in the message text
  • word term: AND: apply when ALL words from the list are included in the words from the message text
  • word term: NOT IN: apply when NONE words from the list are included in the words from the message text
  • word term: OR: apply when ONE words from the list is included in the words from the message text
  • regular expression match: apply when a match to the given regular expression is found in message text

  • channel scope: IS Site: rule to be applied to site channels
  • channel scope: IS User: rule to be applied to user channels
  • channel owner: IN Group: rule to be applied to channels owned by a user of certain groups
  • channel owner: NOT IN Group: rule to be applied to channels not owned by a user of certain groups

More information: User activities are published into User Channel AND Site-Wide Social Channels, why?

  • catch all: always apply the rule for the detailed plugin and channel
  • catch all not fits: apply the rule when there is no matching rule for the plugin

These are the parameter than can be controlled and modified by a rule.

  • Autopublish: to choose if the message has to be auto published (Yes) or not. If not, Off sends the Posts to Pending state, waiting for manual publishing, or Cancel to prevent any further processing.
  • Show URL: to choose if the Url has to be either included in the message or not, and where, beginning of message or end of message.

Message format: a pattern to customize how the message is created. These tags can be implemented in a message pattern:

  • [title]
  • [author]
  • [hashtags]
  • [author-name]
  • [text]
  • [fulltext]
  • [maincat]
  • [maincat-lit]
  • [lastcat]
  • [lastcat-lit]
  • [allcats]
  • [allcats-lit]

[xxxxx,99]: it is a special operator to restrict the length of title, text, or fulltext. For example: [introtext,45]

[message] / #Joomla - [fulltext,60]

Extly: [introtext,45] #Joomla #AutoTweetNG [maincat]

Static text can be introduced, or removed if it was previously introduced, in the message.

  • Show static text: to choose if the message has included a static text (beginning of message or end of message) or not (Off).
  • Static text: a static text that is inserted into the message. You can use this also for hashtags.

This is one of most powerful AutoTweet features. It provides a flexible way to replace strings in the message

  • Regular expression: enter a regular expression to remove or replace parts of the message text. PHP preg_replace function is used. The expression can be a JSON array.
  • Replacement text: Enter the replacement text for the regular expression. PHP preg_replace function is used. If the field is empty, the text parts are removed from the message text.

Reference: Regular Expressions (Perl-Compatible)

The word autotweetng is always replaced with #AutoTweetNG, ignoring case.

/ autotweetng/i

\#AutoTweetNG 

Similarly to the previous example, but for two words.

["/ autotweetng/i","/ jomsocial/i"]

[" #AutoTweetNG"," #JomSocial"]

For example, a regular expression to create hashtags:

["/ AutoTweetNG/i","/ Jomsocial/i"]

[" @AutoTweetNG"," @JomSocial"]

Reference:

In this case, the rules help to route the content between two channels. Each channel must receive and publish only the articles from its associated category.

  • Article: A new article for Channel 1

    • Category: 81 - Category for Channel 1
    • Channel Test Mail Channel 1
  • Article: A new article for Channel 2
    • Category: 82 - Category for Channel 2
    • Channel: Test Mail Channel 2

By default, AutoTweet broadcasts the content Requests to all Channels. So, the rules must publish the articles from a category to its channel, and discard everything else received in the channel.

  • Rule 1: Channel 1 - Category: 81
  • Rule 2: Channel 2 - Category: 82
  • Rule 3: Channel 1 - Catch all / Cancel
  • Rule 4: Channel 2 - Catch all / Cancel

The final result and the rules can be checked in the following screenshots:

In the image, the post for Channel 1 was successfully processed, and the post for Channel 2 was canceled.

Processed Posts

Rules created for two excluding channels

Rule for Channel 1 and a specific category

Rule for Channel 2 and a specific category

Rule for Channel 1, to cancel everything else

Rule for Channel 2, to cancel everything else

In case, you are wondering if there is a way to avoid the "canceling" rules, YES, there is. You can enable DENY ALL mode. In this mode, no post will be published unless you define specific rules to publish posts.

In this example, we are going to show how to setup two rules, one for each language, to show the power of the Rules. In this way, for example, you can define a channel for Twitter in Spanish, Facebook in English, and LinkedIn for all the site languages:

  • A rule for Articles in English (en-GB)
  • A rule for the rest of the languages (In Joomla terms: "*" or "all")

These are the rules:

How to create Rules for content in different languages

A rule for Articles in English

A rule for the rest of the language

To avoid any processing of other languages content, the DENY ALL can be enabled

When we publish articles in different languages, they are routed according to the selected language.

Languages rules processing results

In this example, we are going to show how to setup two rules, one for each access level. For instance, you can define a Public Channel to publish news to a Facebook page and a Members Only Channel:

  • A rule to publish Public Articles
  • A rule to publish "Members Only" articles

These are the rules:

How to create Rules for content in different Access Levels

A Rule for

A Rule for Public Content

When articles are published by different access level, they are routed according to the target audience.

Results

Rule to cancel publication of Special-Level Articles

By default, the rule engine works in ACCEPT ALL mode, accepting all posts and applying specific rules to the source-channel combination.

On the other hand, if you want to publish content under very specific conditions, more content has to be canceled than published. In this case, DENY ALL is the most convenient option.

The advanced mode DENY ALL works in the other way, rejecting all and accepting only rule-specific posts. A rule must be created to publish content in a source-channel.

In Control Panel / Options / Advanced Settings / Rule Engine Mode:

AutoTweetNG-Rules_Engine_Mode-Deny_All_Mode

For more information: http://www.extly.com/docs/autotweetng_joocial/installation/faq#rules