This script, when hosted on a PHP supported web server, will act as a bridge between the JSON requests of Slack and the JSON responses of the ConnectWise REST API.
cwslack.php, cwslack-incoming.php, and cwslack-activities.php were designed to be independent, but all rely on the config.php file.
For requesting ticket information using /ticket #, use cwslack.php.
For creating new activities, use cwslack-activities.php.
To post new tickets or ticket updates to a Slack channel, use cwslack-incoming.php
To follow tickets and get updates whenever they're updated, use cwslack-follow.php (requires cwslack-incoming.php)
- Download the cwslack.php file and config.php file.
- Place on a compatible web server
- Create a new slack slash command integration at https://SLACK TEAM.slack.com/apps/A0F82E8CA-slash-commands
- Set command to /t (or other if you prefer)
- Set the URL to http://domain.tld/cwslack.php
- Set Method to GET
- Copy the token
- Set a name, icon, and autocomplete text if wanted.
- Modify the config.php file with your companies values and timezone. Full configuration info below.
- Test it in Slack!
- Download the cwslack-activities.php file and config.php file.
- Place on a compatible web server
- Create a new slack slash command integration at https://SLACK TEAM.slack.com/apps/A0F82E8CA-slash-commands
- Set command to /act (or other if you prefer)
- Set the URL to http://domain.tld/cwslack-activities.php
- Set Method to GET
- Copy the token
- Set a name, icon, and autocomplete text if wanted.
- Modify the config.php file with your companies values, Full configuration info below.
- Test it in Slack!
- Download the cwslack-follow.php file and config.php file.
- Place on a compatible web server
- Create a new slack slash command integration at https://SLACK TEAM.slack.com/apps/A0F82E8CA-slash-commands
- Set command to /follow (or other if you prefer)
- Set the URL to http://domain.tld/cwslack-follow.php
- Set Method to GET
- Copy the token
- Set a name, icon, and autocomplete text if wanted.
- Modify the config.php file with your companies values, Full configuration info below.
- Test it in Slack!
- Download the cwslack-incoming.php file and config.php file.
- Place on a compatible web server
- Create a new slack incoming webhook integration at https://my.slack.com/services/new/incoming-webhook/
- Set a name, icon, and if wanted.
- Set channel that you want to post to and copy the Webhook URL
- Create a new integrator login in ConnectWise:
- Go to System > Setup Tables in the client
- Type "int" in the table field and select Integrator Login
- Create a new login with whatever username/password, we don't need this.
- Set Access Level to "All Records"
- Enable "Service Ticket API" and select the board(s) you want this to run on.
- Enter http://domain.tld/cwslack-incoming.php?id= for the callback URL (do not enable legacy format)
- Modify the config.php file with your companies values and timezone, make sure to set the value for $webhookurl to the value copied in step 5.
- Change the $postupdated and $postadded to what you prefer. Enabling $postupdated can get spammy.
- Test it in Slack by creating a new ticket on the board you selected in step 6!
- Login to ConnectWise
- In the top right, click on your name
- Go to "My Account"
- Select the "API Keys" tab
- Click the Plus icon to create a new key
- Provide a description and click the Save icon.
- Save this information, you cannot retrieve the private key ever again so if lost you will need to create new ones.
* Asterisk denotes required.
+ Plus denotes required for cwslack-activities.php
- Minus denotes required for cwslack-incoming.php
# Pound denotes required for cwslack-follow.php
- $connectwise * : This value needs to be set to your main connectwise URL.
- $companyname * : This value needs to be set to whatever your company name is that you use to login to ConnectWise.
- $apipublickey * : Set to your Public Key from API setup
- $apiprivatekey * : Set to your Private Key from API setup
- $slacktoken * : Set to the token you got when creating a new slash command integration in Slack.
- $timezone * : Set to your timezone according to http://php.net/manual/en/timezones.america.php .
- $slackactivitiestoken + : Set to the token you got when creating a new slash command integration in Slack for /activities.
- $webhookurl - : Set to the incoming webhook URL you got when creating a new incoming webhook in Slack.
- $postadded - : Set to 1 if you want it to post new tickets to chat.
- $postupdated - : Set to 1 if you want it to post new ticket updates to chat.
- $allowzadmin - : Set to 1 if you want posts from zAdmin to go to chat. Set to 0 by default to avoid spam in high volume environments.
- $badboard : Set this if you have a specific board that spams a lot, set to Alerts by default to hide alerts board posts.
- $badstatus : Set this if you have a status you want to ignore, set to Closed by default as tickets are rarely automatically closed.
- $badcompany : Set this if you have a company you want to ignore, set to CatchAll by default to avoid spam from unknown incoming e-mails.
- $posttext : Set this to 1 if you want to include the latest note with the Slack message. Set to 1 by default now.
- $slackfollowtoken # : Set to the token you got when creating a new slash command integration in Slack for /follow.
- $followenabled # : Defaults to 0, you need to change this to 1 if you want to enable follow.
- $dir # : Directory on the server to store files. Please note that the user running php (www-data in Linux) needs write/read access to this folder.
- $helpurl : Set to a help document explaining the slash command usage. Feel free to point to this GitHub repo, but ideally you would make it look pretty on your own internal site.
* denotes required
/t [ticket number]* [command] [option3]
option3 should be n2s/scheduled/completed
option3 should be low/moderate/critical
If $posttext=1 in config.php, shows you the latest note and the initial note. This displays to you only to avoid spam.
If $posttext=1 in config.php, shows you the initial note of the ticket. This displays to you only to avoid spam.
/act new*|[activity title]*|[assigned to]*
All are required for activities. New will be replaced with more commands in the future.
/follow [ticket number]* (unfollow)
Add unfollow to the end of the command to stop following a ticket.