Difference between revisions of "Configuring Notifications with Slack"

From WHMCS Documentation

(Creating an App for Slack)
Line 15: Line 15:
 
2. Go to https://api.slack.com/.
 
2. Go to https://api.slack.com/.
  
3. Click '''Start Building'''. You will need to log in if you haven't already.
+
3. Click '''Create an app'''. You will need to log in if you haven't already.
  
4. Enter a name for the app. We recommend something like ''WHMCS''. Choose the workspace you wish to add the app to and click '''Continue'''.
+
4. Select '''From scratch'''.  
  
5. Under the '''Add features and functionality''' heading, select the '''Permissions''' option.
+
5. Enter a name for the app. We recommend something like ''WHMCS''. Choose the workspace you wish to add the app to and click '''Continue'''.
 +
 
 +
6. Under the '''Add features and functionality''' heading, select the '''Permissions''' option.
  
 
[[File:Slack_features.png|500px]]
 
[[File:Slack_features.png|500px]]
  
6. Scroll down to '''Scopes: Bot Token Scopes'''.
+
7. Scroll down to '''Scopes: Bot Token Scopes'''.
  
7. Click '''Add an OAuth Scope''' and assign the following permissions:
+
8. Click '''Add an OAuth Scope''' and assign the following permissions:
  
 
* channels:join
 
* channels:join
Line 38: Line 40:
 
[[File:Slack_install_to_workspace.png|500px]]
 
[[File:Slack_install_to_workspace.png|500px]]
  
9. Confirm authorization for the permissions for the app that you just configured.
+
10. Confirm authorization for the permissions for the app that you just configured.
  
10. You will now be presented with the Bot User OAuth Access Token you need for WHMCS integration. Copy this value.
+
11. You will now be presented with the Bot User OAuth Access Token you need for WHMCS integration. Copy this value.
  
 
[[File:Slack_oauth.png|500px]]
 
[[File:Slack_oauth.png|500px]]
  
11. In WHMCS, to go '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Notifications]]''' or, prior to WHMCS 8.0, '''Setup > Notifications'''.
+
12. In WHMCS, to go '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Notifications]]''' or, prior to WHMCS 8.0, '''Setup > Notifications'''.
  
12. Under the Slack notification provider, click '''Configure'''.
+
13. Under the Slack notification provider, click '''Configure'''.
  
13. Enter the Bot User OAuth Access Token you copied in step 10 into the OAuth Access Token input field.
+
14. Enter the Bot User OAuth Access Token you copied in step 10 into the OAuth Access Token input field.
  
14. Click '''Save Changes'''.
+
15. Click '''Save Changes'''.
  
 
[[File:Whmcs_slack_oauth.png|500px]]
 
[[File:Whmcs_slack_oauth.png|500px]]

Revision as of 13:09, 14 December 2022

Configuring Notifications with Slack allows you to receive notifications in your Slack channels when events occur within WHMCS.

Configuring Slack Notifications

To enable WHMCS to communicate with the Slack API, WHMCS requires an OAuth Access Token.

You can create an OAuth Access Token quickly and easily by following the steps below.

Creating an App for Slack

To create a Slack app:

1. Log in to your Slack Workspace.

2. Go to https://api.slack.com/.

3. Click Create an app. You will need to log in if you haven't already.

4. Select From scratch.

5. Enter a name for the app. We recommend something like WHMCS. Choose the workspace you wish to add the app to and click Continue.

6. Under the Add features and functionality heading, select the Permissions option.

Slack features.png

7. Scroll down to Scopes: Bot Token Scopes.

8. Click Add an OAuth Scope and assign the following permissions:

  • channels:join
  •  channels:read
  •  chat:write
  •  groups:read

Slack scopes.png

9. Click Install App to Workspace.

Slack install to workspace.png

10. Confirm authorization for the permissions for the app that you just configured.

11. You will now be presented with the Bot User OAuth Access Token you need for WHMCS integration. Copy this value.

Slack oauth.png

12. In WHMCS, to go Configuration () > System Settings > Notifications or, prior to WHMCS 8.0, Setup > Notifications.

13. Under the Slack notification provider, click Configure.

14. Enter the Bot User OAuth Access Token you copied in step 10 into the OAuth Access Token input field.

15. Click Save Changes.

Whmcs slack oauth.png

WHMCS will attempt to verify the OAuth Access Token provided and automatically join your App.

  • If the verification fails you will receive an error message. Check the Access Token is entered correctly, has all the required scopes and try again.
  • If successful, the modal will close and you will now be able to send notifications to Slack.

You are now ready to Create Your First Notification Rule.

WHMCS will attempt to automatically join your Bot to a Slack channel when one is defined in a Notification Rule.

Private Channels

To send notifications in private channels, follow these extra steps:

  1. Open the Slack app,
  2. Navigate to your private channel
  3. Invite the app to the channel with the command:
    /invite @app_name
    Replace app_name with the name of your app, eg:

    Slack invite app.png
  4. Send the message

The app will join the private channel, and now be available for selection in WHMCS when creating a notification rule.