Created
March 6, 2019 16:45
Star
You must be signed in to star a gist
Zendesk to Statushero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
In Zendesk : | |
- go to Settings > Extensions > Targets (Paramètres > Extensions > Cibles) | |
- add a target | |
- URL target | |
- Title : Zendesk-Statushero | |
- URL : https://DOMAIN/PATH/TO/THIS/SCRIPT?assignee={{ticket.assignee.name}}&id={{ticket.id}}&org={{ticket.organization.name}}&title={{ticket.title}} | |
- Method : GET | |
- Attribute name : value | |
- Auth : <none> | |
- click on Test / submit to test it | |
- click on Save / submit to add it | |
After that, we need to add a trigger | |
- Triggers | |
- Add a trigger | |
- Name : Add a reference in statushero | |
- Description : <what you want> | |
- Answer to ALL following conditions : "Status" "is" "solved" | |
- Actions : "Notify the target" "Zendesk-Statushero | |
- Message : {{ticket.tags}} | |
*/ | |
$statushero_ID = "YOUR STATUSHERO ID"; | |
$statushero_KEY = "YOUR STATUSHERO KEY"; | |
$assignee = strip_tags($_GET["assignee"]); | |
$id = strip_tags($_GET["id"]); | |
$status = strip_tags($_GET["status"]); | |
$value = strip_tags($_GET["value"]); | |
$date = strip_tags($_GET["date"]); | |
$org = strip_tags($_GET["org"]); | |
$file = 'log.txt'; | |
$error = file_put_contents($file, var_export($_GET, true)."\n", FILE_APPEND); | |
date_default_timezone_set('Europe/Paris'); | |
//phpinfo(); | |
$command = "curl -i \"https://service.statushero.com/api/v1/status_activities\" -X POST -H \"Content-Type: application/json\" -H \"X-TEAM-ID: ".$statushero_ID."\" -H \"X-API-KEY: ".$statushero_KEY."\" -d '{\"email\":\"".$assignee."\", \"source\":\"Zendesk\", \"source_url\": \"https://YOUR ZENDESK DOMAIN/agent/tickets/".$id."\", \"description\": \"#".$id." ".str_replace("'","'", $org)." : #".implode(" #", explode(" ", $value))." [".date('H:i')."]\"}' "; | |
exec($command, $result); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment