jundis / cwslack-slashcommands Goto Github PK
View Code? Open in Web Editor NEWRetrieve ConnectWise information into Slack channels and DMs
License: GNU General Public License v3.0
Retrieve ConnectWise information into Slack channels and DMs
License: GNU General Public License v3.0
I don't need to get notifications for "> Closed" statuses and would like to filter them out, like BadBoard.
Asked for via LTG Slack by shawnsack
Saved us a streamline license / month we were using for notifications
Thank you!
Per: https://www.reddit.com/r/msp/comments/4v8skr/connectwiseslack_api_integration_xpost/d5wzerz
Most likely requires incoming webhooks, may spin this into its own repo.
Internal suggestion
Internal suggestion.
Suggested by shawnsack in LTG Slack.
Restricted to having slack name and CW name the EXACT SAME
Internal suggestion
We use configurations in CW that pull data on endpoints from Kaseya. I have modified our cwslack-config.php to pull in the data, including model, warranty, etc. Is there anyway to do a wildcard search in configs? Or at least search all configurations based on the name? I am looking through the code now but I am not as versed in CW.
for example, instead of having to type out /config name of client here|server123FS.root.cnd, I'd like to be able to type /config server12* and still allow the config to be found.
Internal suggestion.
Effectively:
This would all be controlled by a variable such as $posttime and allow for variable time if you want it to alert at 1.0 hours or maybe 1.5 hours.
All other integrations seem to be working fine, but when I try a config, I get the following. This is after adding
var_dump($answerTData);
to line 90 of cwslack-configs.php. Command given was: /config client|sales05
client name and my URL changed to protect the innocent.
string(2272) "HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
x-server-name: CWSERVER
Link:
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sun, 25 Sep 2016 20:10:08 GMT
Content-Length: 1979
[{"id":11757,"name":"sales05.root.client","type":{"id":18,"name":"Managed Workstation","_info":{"type_href":"https://cw.MYCOMPANY.com/v4_6_release/apis/3.0/company/configurations/types/18"}},"status":{"id":1,"name":"Active","_info":{"status_href":"https://cw.MYCOMPANY.com/v4_6_release/apis/3.0/company/configurations/statuses/1"}},"company":{"id":923,"identifier":"client","name":"client","_info":{"company_href":"https://cw.MYCOMPANY.com/v4_6_release/apis/3.0/company/companies/923"}},"contact":null,"site":{"id":1109,"name":"Main","_info":{"site_href":"https://cw.MYCOMPANY.com/v4_6_release/apis/3.0/company/companies/923/sites/1109"}},"locationId":null,"businessUnitId":null,"deviceIdentifier":"KHJGHGJKH","serialNumber":"LKJKJGK","modelNumber":"7518E1U","tagNumber":null,"purchaseDate":null,"installationDate":"2015-09-24T13:30:00Z","installedBy":null,"warrantyExpirationDate":null,"vendorNotes":"","notes":null,"macAddress":"CC-52-AF-41-ED-B8","lastLoginName":"Sales06","billFlag":true,"backupSuccesses":null,"backupIncomplete":null,"backupFailed":null,"backupRestores":null,"lastBackupDate":null,"backupServerName":null,"backupBillableSpaceGb":null,"backupProtectedDeviceList":null,"backupYear":null,"backupMonth":null,"ipAddress":"192.168.4.165","defaultGateway":"192.168.4.1","osType":"7","osInfo":"Professional x64 Edition Service Pack 1 Build 7601","cpuSpeed":"1581 MHz x 4","ram":"8016 MB","localHardDrives":" Free Total \r\nC: 287386 MB 465437 MB \r\nQ: 1026 MB 9999 MB \r\n","parentConfigurationId":null,"vendor":null,"manufacturer":{"id":12,"name":"Lenovo","_info":{"manufacturer_href":"https://cw.MYCOMPANY.com/v4_6_release/apis/3.0/procurement/manufacturers/12"}},"questions":null,"activeFlag":true,"managementLink":"341741014418654","remoteLink":null,"sla":null,"mobileGuid":"2b45f62e-fc0e-4ee5-b2be-d6735ce29ac3","_info":{"lastUpdated":"2016-09-24T08:07:53Z","updatedBy":"Kaseya"},"customFields":null}]"
<?xml version="1.0"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>0</int></value></member><member><name>faultString</name><value><string>Warning:Invalid argument supplied for foreach() in E:\PHP\CWSlack\cwslack-configs.php on line 112</string></value></member></struct></value></fault></methodResponse>{
"parse": "full",
"response_type": "in_channel",
"attachments": [
{
"fallback": "Configuration Info for client\\sales05.root.client",
"title": "Configuration: sales05.root.client",
"pretext": "Configuration for: client",
"text": "*_Notes_*:\nNone\n*_Vendor Notes_*:\nNone\n*_Questions_*:\n",
"mrkdwn_in": [
"text",
"pretext"
]
}
]
}
CW version is v2016.5 (42287)
From internal discussion.
The "latest note" field in incoming updates does not always appear to show the latest note. Appears to possibly be an issue with the API as calls to /notes?orderBy=id%20desc do not show latest note.
Internal suggestion.
Would be using /note command, adding more to /t just makes it too cluttered and combined which is unlike how the rest of the scripts were created.
/note 431823 internal This is an internal note!
/note 443723 external Hello, external note!
vs
/t 512377 note internal "This is an external note!"
/t 412384 note external "Hello, external note!"
Internal request.
Need to have the /note command be able to e-mail clients with external status. Set optional with possibly an e-mail function?
Not even sure if the API allows for e-mailing with notes.
I'm getting the following when I browse to cwslack-incoming.php and new tickets aren't being posted.
Notice: Trying to get property of non-object in D:\home\site\wwwroot\cwslack\cwslack-incoming.php on line 29
A lot of people ando companies won't touch code unless it's licensed, whether it be contributing or using, so it's something to consider. The MIT license is the friendliest for a lot of companies and people.
Internal suggestion, to split the time notifications and firm alerts.
Suggested from LTG slack.
I just noticed that the fallback is missing more detail (like who posted). It might be an idea to examine all of the outputs for -incoming and see what information can be added to the fallback, without making it look cluttered.
I'll probably get onto this myself over the next few days!
This was asked in #33 but that has been closed. If people are not aware wildcards can be used for most rest calls including configurations like so
example ../company/configurations?conditions=name like "PSA*"
Goal would be to allow for the choice between flat file and MySQL/MariaDB/etc to allow for much better management. Future modules would rely 100% on database but existing modules would keep flat file compatibility.
Looking for feedback on this from users before diving into.
Pros:
Cons:
Initial MySQL config required for config.php, in case people do not use the install.php.
Probably can move this to a better spot, or require install.php or provide .sql files. Bad to have it run literally every call.
Users receive error starting at line 195 if their Connectwise URL is incorrect in config.php. Need better error catching so it is understandable what the problem is.
Add follow commands
in <b>/var/www/html/cwslack.php</b> on line <b>193</b><br /> <br /> <b>Warning</b>: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
If I have a contact in CW, with a phone number type of "Site Phone" (the default company phone # i assume?) it does not pull that into the info returned into Slack. If that contact happens to not have an email set in CW, I get markup returned (I am guessing because $text is blank?)
]
string(2121) "HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
x-server-name: CWSERVER
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 29 Sep 2016 20:37:01 GMT
Content-Length: 1836
[{"id":6758,"firstName":"Dick","lastName":"smithS","type":null,"company":{"id":81,"identifier":"CCCDP","name":"CompanyName","_info":{"company_href":"https://cw.url.here/v4_6_release/apis/3.0/company/companies/81"}},"site":{"id":83,"name":"Main","_info":{"site_href":"https://cw.url.here/v4_6_release/apis/3.0/company/companies/81/sites/83"}},"addressLine1":null,"addressLine2":null,"city":null,"state":null,"zip":null,"country":null,"relationship":{"id":0,"name":"","_info":{"relationship_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/relationships/0"}},"department":null,"inactiveFlag":false,"defaultMergeContactId":null,"securityIdentifier":null,"managerContactId":null,"assistantContactId":null,"title":null,"school":null,"nickName":null,"marriedFlag":false,"childrenFlag":false,"significantOther":null,"portalPassword":null,"portalSecurityLevel":null,"disablePortalLoginFlag":false,"unsubscribeFlag":null,"gender":null,"birthDay":null,"anniversary":null,"presence":null,"mobileGuid":"42a66a98-af5a-4017-82a5-cadeb6ad4f06","facebookUrl":null,"twitterUrl":null,"linkedInUrl":null,"communicationItems":null,"_info":{"lastUpdated":"2016-09-29T20:36:07Z","updatedBy":"MyName","communications_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/6758/communications","notes_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/6758/notes","tracks_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/6758/tracks","portalSecurity_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/6758/portalSecurity","image_href":"https://cw.url.here/v4_6_release/apis/3.0/company/contacts/6758/image?lastModified=2016-09-29T20:36:07Z"},"customFields":null}]"
<?xml version="1.0"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>0</int></value></member><member><name>faultString</name><value><string>Warning:Invalid argument supplied for foreach() in E:\dokuwiki\CWSlack\cwslack-contacts.php on line 104</string></value></member></struct></value></fault></methodResponse>{
"parse": "full",
"response_type": "in_channel",
"attachments": [
{
"fallback": "Contact Info for Dick smithS",
"title": "Company: CompanyName",
"pretext": "Contact Info for Dick smithS",
"text": "",
"mrkdwn_in": [
"text",
"pretext"
]
}
]
}
This is with var_dump($answerTData); added to line 91 of cwslack-contacts.php
From internal discussion.
Updates in slackbot messages appear to be sent twice on occasion.
I just recently installed this and was trying to get it working and realized the URL for the CW side is different. We use Hosted CW.
From the looks of it it changed from /v4_6_release/ to /v2016_6/
Now I tried to update the code and I still get an error inline in Slack saying:
"Array not returned in line 195. Please check your connectwise URL variable in config.php and ensure it is accessible via the web at https://api-na.myconnectwise.net/v2016_6/apis/3.0/se....."
I did try the other way also and get same error.
"Array not returned in line 195. Please check your connectwise URL variable in config.php and ensure it is accessible via the web at https://api-na.myconnectwise.net/v4_6_release/apis/3.0/service/tic....."
Sorry if this is not a place for this, the only comment section I found.
I'm getting the following error:
Parse error: syntax error, unexpected 'APIKEYSHOWNHERE*' (T_STRING) in /var/www/html/CW/config.php on line 27
Is this an API configuration error, or a webserver issue ?
Appreciate any advice.
This project seems relatively easily portable for use with other services that use a REST API, two services of particular interest, in my mind, are Office Planner and Trello. Half of the leg work is already done via facilitating HTTP requests to Connectwise and returning the JSON object.
Integrations such as these eliminate the need for tools like Kanbanize.com to bring Agile methodologies to the Connectwise PSA and would put forth a lot of value.
Need to catch authorization error codes that appear in call to CW in cwslack.php
This is a concept issue. May not actually make it into the final 2.0 release, but depending on how useful I can make it we'll see.
Just notes on how the database will be laid out.
I can't be in front of CW all day, so I use the Slack integration mostly to avoid getting a million emails about ticket updates. The updates are a good start, but I'd love to see the message in the alert so I could see what the user has updated with to know if it's something I need to deal with now or can table till later.
Looks to be site=null issues, may need to just add a null catch to 131.
Report by reddit pm.
Internal suggestion.
Need to create a new PHP script which will allow searching for contacts in ConnectWise. This will only pull contacts by last name OR first name last name.
Per internal suggestions.
Hi,
In the Slack notification, NO FALLBACK DEFINED is displayed. If I can figure out how to pull/push whatever to Github I will, but the fix is to add:
"fallback" => "Info on Ticket #" . $dataTData->id,
to the first line of each attachment in the array:
$return =array( "parse" => "full", "response_type" => "in_channel", "attachments"=>array(array( "fallback" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number. "title" => "<" . $ticketurl . $dataTData -> id . "&companyName=" . $companyname . "|#" . $dataTData->id . ">: " . $dataTData->summary, //Return clickable link to ticket with ticket summary. "pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number. "text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string "\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string "\n" . $dataTData->resources, //Return assigned resources "mrkdwn_in" => array( "text", "pretext" ) )) ); }
I guess you could add whatever you wanted, I only wanted the Ticket #
Need to setup a new script to run based on cron or scheduled tasks for Windows, that when called will check all firm appointments for the next hour, and check each to see if there is a reminder set on them. If so and the reminder threshold has been reached, send a reminder to Slack towards a specific channel or the user themselves.
I've updated to 1.6 and the cw-contact seems to not be working on my system, but I'm sure it's just a misconfiguration on my end somewhere. When I perform "/cwcontacts Smith", I get the follow returned:
<br />
<b>Notice</b>: Undefined property: stdClass::$communicationItems in <b>/var/www/html/cwslack-contacts.php</b> on line <b>100</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/var/www/html/cwslack-contacts.php</b> on line <b>104</b><br />
<br />
<b>Notice</b>: Undefined property: stdClass::$name in <b>/var/www/html/cwslack-contacts.php</b> on line <b>115</b><br />
{
"parse": "full",
"response_type": "in_channel",
"attachments": [
{
"fallback": "Contact Info for John Smith",
"title": "Company: ",
"pretext": "Contact Info for John Smith",
"text": "",
"mrkdwn_in": [
"text",
"pretext"
]
}
]
}
Suggested by scubes13 on LTG slack
Similar to what cwslack-follow is currently doing except instead of initiating the follow from Slack, I receive notifications if I "Follow" a ticket in CW. This I believe will require some way to map users in CW to users in Slack.
Due to a null issue with $posttext. Need to add a null check to see if there even is notes available to post.
A lot of people ando companies won't touch code unless it's licensed, whether it be contributing or using, so it's something to consider.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.