Skip to content

Set up Slack notifications

If you’d like to receive cPFence v4+ on Enhance alerts on your desktop or mobile via Slack, follow the steps below. This guide uses the Slack desktop app.

You need access to your Slack workspace and permission to add an app. In cPFence, you need Manage Notification Settings for each server you configure.

If you don’t already have it, download the Slack apps for both PC and mobile, then sign in to the same workspace on both devices.

  1. Open the Slack desktop app.
  2. Click + Add channels in the left sidebar and choose Create a channel. In layouts that put this under the + button, select Channel instead.

Slack sidebar with Add channels highlighted.

Open the channel creation menu. Select the image to enlarge it; use your browser’s Back command to return.
  1. Choose Blank channel if Slack offers templates, then click Next.

Slack Create a channel dialog with Blank channel selected and Next highlighted.

Start with a blank alerts channel. Select the image to enlarge it; use your browser’s Back command to return.
  1. Name your channel, for example cpfence-alerts. Choose its visibility and click Create.

Slack Channel details with cpfence-alerts entered and Create highlighted.

Use a channel your alert recipients can access; the screenshot shows a public channel. Select the image to enlarge it; use your browser’s Back command to return.

Step 3: Create a Slack app with webhook access

Section titled “Step 3: Create a Slack app with webhook access”
  1. Visit Slack’s app dashboard and log in to the intended workspace.
  2. Click Create an App. If you already have an app for these alerts, open it and continue with Step 4.

Slack app dashboard with Create an App highlighted.

Create the app that will deliver your alerts. Select the image to enlarge it; use your browser’s Back command to return.
  1. Choose From a manifest.

Slack Create an app dialog with From a manifest highlighted.

Use the manifest method from the original setup guide. Select the image to enlarge it; use your browser’s Back command to return.
  1. Pick your workspace and click Next.

Slack workspace selection dialog with Next highlighted and workspace identity concealed.

Select the workspace containing your alerts channel. Select the image to enlarge it; use your browser’s Back command to return.
  1. Select the JSON tab and paste the following manifest. Replace Your Hosting Co with the name you want for the app:
{
"display_information": {
"name": "Your Hosting Co"
},
"settings": {
"org_deploy_enabled": false,
"socket_mode_enabled": false,
"is_hosted": false,
"token_rotation_enabled": false
}
}

Slack JSON manifest editor with the app name location and Next highlighted.

Enter your app name in the manifest, then select Next. Select the image to enlarge it; use your browser’s Back command to return.
  1. Click Next, review the app summary, then click Create. If your workspace requires app approval, ask its administrator to approve the app before continuing.

Slack app review summary with Create highlighted.

Review the selected app configuration before creating it. Select the image to enlarge it; use your browser’s Back command to return.

The manifest creation method is also covered in Slack’s app-manifest instructions.

  1. In your app settings, open Incoming Webhooks and turn Activate Incoming Webhooks on.

Slack Incoming Webhooks page with Activate Incoming Webhooks switched On.

Enable incoming webhooks for this app. Select the image to enlarge it; use your browser’s Back command to return.
  1. Click Add New Webhook to Workspace (shown as Add New Webhook in the original screenshot).

Slack Incoming Webhooks page with Add New Webhook highlighted.

Add a webhook for the channel you created. Select the image to enlarge it; use your browser’s Back command to return.
  1. Choose #cpfence-alerts and click Allow or Authorize, depending on the dialog. Check that the selected workspace and channel are correct.

Slack authorization dialog with cpfence-alerts selected and Allow highlighted.

Authorize this app to post in the selected alerts channel. Select the image to enlarge it; use your browser’s Back command to return.

Slack returns you to Incoming Webhooks and shows a new entry under Webhook URLs for Your Workspace. Click Copy beside that webhook URL.

Slack webhook list with the Copy button highlighted and the webhook secret concealed.

Copy your own webhook URL privately; the example’s secret is concealed. Select the image to enlarge it; use your browser’s Back command to return.

For workspace approval or webhook issues, see Slack’s incoming-webhook instructions.

  1. In your cPFence WebUI, open System Settings.
  2. Choose the intended Server scope, then select Notification Settings. Settings are saved for one server at a time.
  3. Type Slack in Search settings to find the switch and webhook connection.
  4. Turn Slack notifications on and click Save changes. Check the save result before continuing.
  5. Under Delivery connections → Slack webhook, paste the URL you copied. Click Save changes again. Saving a webhook while Slack is enabled sends a test notification.

cPFence v4+ Notification Settings filtered to Slack, showing the enabled switch and masked saved webhook connection.

The current WebUI has Slack enabled and a configured connection on Local scope. The empty input keeps the saved URL; this screenshot does not show a submitted change or delivered test. Select the image to enlarge it; use your browser’s Back command to return.
  1. Open your Slack channel and confirm that the cPFence test message arrived. A saved setting or submitted request alone does not confirm delivery.
  2. Clear the search and review the event switches you want enabled in Notification Settings. The related protection module must also be enabled for its events to occur.

For secondary servers, repeat the setup on each intended server, or use Apply to servers…. Review the selected destinations and changed fields before applying. Check each server’s result and test message; one successful server does not establish success for the whole cluster.

As root on the server you want to configure, run these commands in order:

Terminal window
cpfence --slack-notifications-on
cpfence --set-slack-webhook

Enter your webhook URL at the interactive prompt, rather than putting it in the command. Check the command result and confirm the test message in Slack. Repeat on each intended server; these commands configure the server where you run them.

To stop sending Slack alerts later:

Terminal window
cpfence --slack-notifications-off

To receive mobile push alerts, open Slack and configure its notification preferences:

  1. Click your profile picture, then Preferences.

Slack profile menu with Preferences highlighted and account identity concealed.

Open your own Slack notification preferences. Select the image to enlarge it; use your browser’s Back command to return.
  1. Open Notifications and choose your notification schedule and sound preferences.

Slack Notifications preferences showing notification schedule and sound controls.

Choose the hours when you want notifications; the example schedule is a user choice, not a cPFence default. Select the image to enlarge it; use your browser’s Back command to return.
  1. Open the alerts channel and check its notification preferences so new alerts notify you.
  2. On your phone, sign in to the same workspace, enable Slack notifications in the phone’s settings, and check Slack’s mobile notification preferences. If messages appear in the channel but your phone is silent, check paused notifications and the notification schedule.

If you prefer to keep your email inbox clean and manage alerts in Slack:

  1. Confirm that the Slack test arrived first.
  2. In System Settings → Notification Settings on the intended server, clear Notification email and click Save changes.
  3. Leave Slack notifications on and keep the intended event switches enabled.

If you prefer the configuration-file method from the original guide, set this line in /opt/cpfence/config.conf on the intended server:

EMAIL_RECIPIENT=""

Use the configuration file editor and check the save result. Preserve all other settings. To receive email again, follow email and SMTP setup and confirm delivery.

  • Cannot create the app or authorize the channel: check workspace app approval and your membership of a private channel.
  • No test message: check the save or command result, server connection, Slack enablement and whether the URL belongs to the intended workspace/channel. Do not disable email until Slack delivery is confirmed.
  • Webhook refused: check whether the webhook was revoked or its channel archived. Create a replacement and save it privately.
  • Test arrives but an event does not: check the owning module, event switch and notification cooldown. A test does not trigger every event.
  • Message arrives but there is no mobile alert: check Slack’s channel preferences, notification schedule and your phone’s notification permissions.

Need further assistance? Open a support ticket through your client portal.