Difference between revisions of "Configuring Notifications with Slack"

From WHMCS Documentation

m
(Creating an App for Slack)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
Configuring Notifications with Slack allows you to receive notifications in your Slack channels when events occur within WHMCS.
 
Configuring Notifications with Slack allows you to receive notifications in your Slack channels when events occur within WHMCS.
 
For more information on Notifications, please refer to the [[Notifications|Notifications Documentation]].
 
  
 
==Configuring Slack Notifications==
 
==Configuring Slack Notifications==
Line 11: Line 9:
 
===Creating an App for Slack===
 
===Creating an App for Slack===
  
1. Begin by visiting https://api.slack.com/
+
To create a Slack app:
  
2. Click the '''Start Building''' button to start the process of creating a new app. You will need to login if you haven't already.
+
# Log in to your Slack Workspace.
 +
# Go to <tt>https://api.slack.com/</tt>.
 +
# Click '''Create an app'''. You will need to log in if you haven't already.
 +
# Select ''From scratch''.
 +
# Enter a name for the app. We recommend something like <tt>WHMCS</tt>.
 +
# Choose the workspace you wish to add the app to and click '''Continue'''.
 +
# Under '''Add features and functionality''', select ''Permissions''. <br/>[[File:Slack_features.png|500px]]
 +
# Scroll down to '''Scopes: Bot Token Scopes'''.
 +
# Click '''Add an OAuth Scope''' and assign the following permissions:
 +
#* '''channels:join'''
 +
#* '''channels:read'''
 +
#* '''chat:write'''
 +
#* '''groups:read''' <br/>[[File:Slack_scopes.png|500px]]
 +
# Click '''Install App to Workspace'''. <br/>[[File:Slack_install_to_workspace.png|500px]]
 +
# Confirm authorization for the permissions for the app that you just configured.
 +
# Copy the Bot User OAuth Access Token value. You will need this to enter in WHMCS. <br/>[[File:Slack_oauth.png|500px]]
 +
# 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'''.
 +
# Under the Slack notification provider, click '''Configure'''.
 +
# Paste the Bot User OAuth Access Token that you copied into '''OAuth Access Token'''.
 +
# Click '''Save Changes'''. <br/>[[File:Whmcs_slack_oauth.png|500px]]
  
3. Enter a name for the app.  We recommend something like 'WHMCS'.  Also choose the workspace you wish to add the app to. Then click continue.
+
WHMCS will attempt to verify the OAuth Access Token provided and automatically join your App.  
  
4. Under the '''Add features and functionality''' heading, select the '''Permissions''' option.  
+
* 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.
  
[[File:Slack-permissions.png]]
+
You are now ready to [[Notifications#Creating_a_Notification_Rule|Create Your First Notification Rule]].
 
 
5. On the following screen, scroll or auto-search to the Scopes section and add the following two scopes:
 
 
 
* Access information about user’s public channels (''channels:read'')
 
* Send messages as WHMCS (''chat:write:bot'')
 
* Access information about user's private channels (''groups:read'')
 
 
 
[[File:Slack-scopes.png]]
 
 
 
6. Click Save Changes
 
 
 
7. Now navigate to '''Install App''' in the sidebar.
 
  
[[File:Slack-install.png]]
+
WHMCS will attempt to automatically join your Bot to a Slack channel when one is defined in a Notification Rule.
  
8. Click the Install App button.
+
====Private Channels====
  
9. Confirm you authorize the permissions for the app that you just configured.
+
To send notifications in private channels, follow these extra steps:
  
[[File:Slack-authorize.png]]
+
# Open the Slack app,
 
+
# Navigate to your private channel
10. You will now be presented with the '''OAuth Access Token''' you need for WHMCS integration. Copy this value.
+
# Invite the app to the channel with the command:<div class="source-cli">/invite @app_name</div>Replace <tt>app_name</tt> with the name of your app. For example:<br/><br/>[[File:Slack invite app.png]]<br/>
 
+
# Send the message
[[File:Slack-oauth-token.png]]
+
The app will join the private channel, and now be available for selection in WHMCS when [[Notifications#Creating_a_Notification_Rule|creating a notification rule]].
 
 
11. Now return to WHMCS and navigate to '''Setup > Notifications'''.
 
 
 
12. Under the Slack notification provider, click '''Configure'''
 
 
 
13. Enter the OAuth Access Token you copied in step 10 into the OAuth Access Token input field and hit '''Save Changes''' to complete the process.
 
 
 
WHMCS will attempt to verify the OAuth Access Token provided. 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 [[Notifications#Creating_a_Notification_Rule|Create Your First Notification Rule]].
 

Latest revision as of 16:32, 19 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.
  6. Choose the workspace you wish to add the app to and click Continue.
  7. Under Add features and functionality, select Permissions.
    Slack features.png
  8. Scroll down to Scopes: Bot Token Scopes.
  9. Click Add an OAuth Scope and assign the following permissions:
    • channels:join
    •  channels:read
    •  chat:write
    •  groups:read
      Slack scopes.png
  10. Click Install App to Workspace.
    Slack install to workspace.png
  11. Confirm authorization for the permissions for the app that you just configured.
  12. Copy the Bot User OAuth Access Token value. You will need this to enter in WHMCS.
    Slack oauth.png
  13. In WHMCS, to go Configuration () > System Settings > Notifications or, prior to WHMCS 8.0, Setup > Notifications.
  14. Under the Slack notification provider, click Configure.
  15. Paste the Bot User OAuth Access Token that you copied into OAuth Access Token.
  16. 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. For example:

    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.