Making Phabricator talk to Desk with email and APIs
Purpose of this python script is to make API requests to our Desk.com account and set a label for cases which are associated with Phabricator tickets which have been resolved by our team. Basically, change the status of the case so we can easily notify a user when their issue has been resolved due to a code change.
This whole thing was essentially a Python and API requests learning experience for me. Here’s the gist of what the script does:
- Phabricator notification email gets set to Gmail address
- Script opens Pop connection to Gmail account
- Get all unread message text and squish them into a single string
- Parse the message to make a list of Phabricator Tasks that are resolved, i.e.
[T8287,T7632]
. This step is probably supposed to be done with regular expressions, but I don’t know how to do that, so instead I used.find()
to look for the"t/T”
inhttp://phabricator.domain.net/T10762
:) - Make a bunch of requests to Desk to check what cases have the Task in a case custom field and make a list of those cases.
- Make more requests to Desk that adds a label to those cases.
- After update cases with these labels, I created a rule and notification email in Desk that says something like “Hey, we recently made a change in our code that fixes the issue you reported to us! Aren’t we great? If you’re still experiencing the issue, let us know.”
Command link script output
Example email to a customer
Overall, I learned a few things about how to use:
Some more screenshots on the Disqus Blog here. Exciting!