I just talked to Martin regarding another case and i showed him, how we bring Swyx Calls to Zammad tickets,
without the Generic CTI Extension. Altough i made this setup before Zammad 2.6(with generic CTI),
so i thought nobody would need it anymore.
First of all, im not a Coder… So the code is far from perfect, but it works.
You need the Swyx Webextension and a webbrowser window in you swyxit skin. With it you can call Website URLs(in fact IE calls) on certain trigger. You can edit the trigger on the Skin. Be sure you edit only a new skin, or create a new one for the Support group Users.
The trigger is “connection established” and the URL looks like this.
https://swyxticket.yourdomain.tld/swyx.php?search=%SelLinePeernumberPublicFormat%&user=%username%&server=%ActiveServerName%&call=%SelLineCallednumber%&name=%SelLinePeername%
With this call you pass all the info to the swyx.php script, which in my case is on the same server as my zammad installation.
Here is the Swyx Web Extension Docu for all usable variables.
http://www.swyx.de/produkte/support/wissensdatenbank/artikel-details/swyxknowledge/kb3694/keywords/Web%20Extension%20/products/all/category_info/on/category_howto/on/category_problem/on/category_faq/on/category_whitepaper/on.html?tx_swyxkbase_pi1[searchform_submit]=Suchanfrage%20starten
I used the zammad php API client from github and installed it.
And here is my swyx.php
<?php
include "functions.php";
include "token.php";
// Zammad API PHP CLient
require __DIR__. '/vendor/autoload.php';
use ZammadAPIClient\Client;
use ZammadAPIClient\ResourceType;
//Debug
error_reporting(E_ALL);
// read GET parameters
// -----------------------------------------------------------
$iPhoneNumber = $_GET['search'];
$iSwyxUser = $_GET['user'];
$iSwyxServer = $_GET['server'];
$iCallDirection = $_GET['call'];
$iCallName = $_GET['name'];
// -----------------------------------------------------------
//Here i add the AD Domain to the username
$iSwyxUser = strtolower($iSwyxUser);
$upname = $iSwyxUser."@addomain.local";
// this is the hotline number. Only if this extension is called a ticket is created
$hotline = "8211";
printHeader($iSwyxUser, $iSwyxServer);
echo "Agent: ".$upname."<br>";
echo "Nummer Kunde: ".$iPhoneNumber."<br>";
echo "Nummer angerufen: " . $iCallDirection . "<br>";
// Ticket erstellen wenn CallDirection nicht leer = eingehender Anruf und nur wenn Hotline Nummer angerufen.
// if (!empty($iCallDirection)){
if (!empty($iCallDirection) and $iCallDirection == $hotline ){
echo "Eingehender Ruf an $hotline! Ticket erstellen"."<br>";
// API Connection mit Token von UserPrincipalName
$client = new Client([
'url' => 'https://deinzammad.tld', // URL to your Zammad installation
'http_token' => $tokens[$upname],
]);
// Suche mit Telefonnummer nach User, wenn Nummer mindesten 5 Zahlen
// Sonst Customer ID 1 nehmen
$cust_id = 1;
if (strlen($iPhoneNumber) > 4){
$users = $client->resource( ResourceType::USER )->search($iPhoneNumber);
// Default Customer ID, falls kein User gefunden
if ( !is_array($users) ) {
exitOnError($users);
}
else {
// Wenn mehr als ein User mit Telefonnummer gefunden, dann ID nicht setzen
if (count($users) > 1) {
print count($users) . ' User mit Telefonnummer ' . $iPhoneNumber . "<br>";
print 'Kann Customer nicht eindeutig zuordnen' . "<br>";
}
// Wenn eindeutig zuordenbar. ID setzen
if (count($users) == 1) {
$user_by_tel = array_shift($users);
$cust_id = $user_by_tel->getValue('id');
print 'Kunde mit passender Telefonnummer gefunden. ID: ' . $cust_id . "<br>";
}
}
}
$ticket_title = 'SWYX Telefonticket';
$ticket_sub = 'Anruf von ' . $iPhoneNumber;
$ticket_body = 'Anruf von ' . $iPhoneNumber;
$ticket_data = [
// Group.find_by(name: 'Your Group Name') in Zammad Rails Console
'group_id' => 8,
'priority_id' => 1,
'state_id' => 1,
'title' => $ticket_title,
'customer_id' => $cust_id,
'type' => "phone",
'article' => [
'subject' => $ticket_sub,
'body' => $ticket_body,
],
];
$ticket = $client->resource( ResourceType::TICKET );
$ticket->setValues($ticket_data);
$ticket->save();
exitOnError($ticket);
$ticket_id = $ticket->getID(); // same as getValue('id')
echo "neues Ticket erstellt. id: ".$ticket_id;
//$ticket->delete();
//exitOnError($ticket);
} else {
echo "Ausgehender Ruf! Kein Ticket erstellen"."<br>";
}
printFooter();
?>
And here is my function.php
Which is basically the html header and footer and error output.
<?php
function printHeader($pSwyxUser, $pSwyxServer)
{
header("Content-type: text/html; charset=ISO-8859-1");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
printf("<? xml version=\"1.0\" ?>\n");
printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
printf("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html: charset=ISO-8859-1\">\n");
printf("<META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\">\n");
printf("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1800; URL=http://%s%s?user=%s&server=%s&nocache=%s\">\n", $_SERVER['SERVER_NAME'], $_SERVER['SCRIPT_NAME'], urlencode($pSwyxUser), urlencode($pSwyxServer), time());
printf("<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n");
printf("<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">\n");
printf("\n");
printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
printf(" <head>\n");
printf(" <title>SPOE ITZ - Swyx Zammad Interface</title>\n");
printf(" <style type=\"text/css\">\n");
printf(" h1 {\n");
printf(" font-size:20px;\n");
printf(" font-family:Helvetica,Arial,sans-serif;\n");
printf(" margin-bottom:5px;\n");
printf(" }\n");
printf("\n");
printf(" p {\n");
printf(" font-size:16px;\n");
printf(" font-family:Helvetica,Arial,sans-serif;\n");
printf(" margin:0;\n");
printf(" }\n");
printf("\n");
printf(" p.contact {\n");
printf(" font-weight:bold;\n");
printf(" }\n");
printf(" p.footer {\n");
printf(" font-size:8px;\n");
printf(" margin-top:10px;\n");
printf(" }\n");
printf("\n");
printf(" p.small {\n");
printf(" font-size:8px;\n");
printf(" }\n");
printf("\n");
printf(" p.timestamp {\n");
printf(" font-size:12px;\n");
printf(" margin-top:10px;\n");
printf(" }\n");
printf("\n");
printf(" p.internallink {\n");
printf(" font-size:12px;\n");
printf(" margin-top:10px;\n");
printf(" }\n");
printf("\n");
printf(" </style>\n");
printf(" </head>\n");
printf(" <body>\n");
} // end printHeader
function printFooter()
{
printf(" <p class=\"footer\">(c) 2018 jr/ITZ - erstellt am:%s</p>\n", date('d.m.Y H:i:s'));
printf(" </body>\n");
printf("</html>\n");
} // end printFooter
function exitOnError($object)
{
if ( $object->hasError() ) {
print $object->getError() . "\n";
exit(1);
}
}
?>
And my token.php where i store all usrname/tokens in an array.
<?php
$tokens = [
"user11@addomain.local" => "tokenuser11fromzammad",
"user12@addomain.local" => "tokenuser12fromzammad",
];
?>
And in Zammad i created a trigger to set ticket creator to ticket owner.
And now if a connection is established and the called number is the hotline a ticket is created and the owner is set. I also search for the calling number in zammad and the set the customer if only one with this number is found.
I know its not a clean setup, but it works and maybe some other zammad/swyx users might need it.
Feel free to copy/edit and multiply.