Post to Slack with Classic UI#

This guide shows you how to create a content rule that posts a message to Slack, using Classic UI. As an example, the rule reports every user login to a Slack channel.

Prerequisites#

Create the content rule#

  1. Open Site Setup ‣ Content Rules.

    The Content Rules control panel in Classic UI
  2. Select Add content rule.

  3. Enter a Title, such as User Logged In, and an optional Description.

  4. In Triggering event, select User Logged in.

  5. Select Save.

    The form to add a content rule, with the User Logged in event selected

Add the Slack action#

  1. On the page of the new rule, select Post a message to Slack in the Action list, and select Add.

    The page of the content rule, with the list of actions
  2. Fill in the form. The Slack action describes every field.

    The empty form to add a Slack action

    Use ${...} variables to include details about what triggered the rule. The table at the bottom of the form lists the available variables. This example uses the full name and email of the user who logged in.

    The Slack action form, filled in with variables such as user_fullname and user_email
  3. Select Save.

The action appears under Perform the following actions.

Assign the rule#

A rule runs only in the places it is assigned to. Select Apply rule on the whole site to run it everywhere.

The page of the content rule, with the Slack action and the Apply rule on the whole site button

To run the rule only inside a folder, go to that folder, open its Rules tab, and add the rule there.

Check the result#

Log in to the site in another browser. A message appears in the Slack channel.

The message posted to Slack after a user logged in

If no message appears, check the Plone log for errors from the contentrules.slack logger. Python API lists the messages it writes.