Scenario
In some cases, it is necessary for specific tickets and their related conversations to be available in an additional ticket system. For instance, a customer’s response to a request from the ticket can also be displayed in the parallel running system. This can be facilitated by the use of webhooks.
Possible Solution
To ensure that new conversations are synchronized in both systems, a webhook can be implemented. In Settings -> Communication channels -> Email accounts, the corresponding email account must be selected. If the webhooks on this account are not yet active, the Webhooks switch must be activated, so that the fields for configuring the “New email” webhook appear.
Example of customer-specific code
Error handling is intentionally omitted in this code example for better clarity.
The following PHP code uses the Enneo SDK to retrieve information from a ticket system and pass this on to a third system.
<?php
use EnneoSDK\ApiEnneo;
require(getenv()['SDK'] ?? 'sdk.php');
/** @var stdClass $in - contains all defined input parameters from the event */
// get agent profile
$agent = ApiEnneo::get('/api/mind/profile/' . $in->userId)->profile;
// get ticket details
$ticket = ApiEnneo::get('/api/mind/ticket/'. $in->ticketId .'?includeRawData=true');
// get conversations
$conversationData = ApiEnneo::get('/api/mind/ticket/' . $in->ticketId . '/conversation?includeRawData=true');
// find current conversation
$conversation = null;
foreach ($conversationData->conversations as $c) {
if ($c->id === $in->conversationId) {
$conversation = $c;
break;
}
}
// prepare payload
$payload = [
"ticketId" => $ticket->externalTicketId,
"enneoId" => $ticket->id,
"agent" => $agent,
"conversationContent" => $conversation->bodyPlain
];
// send data to third-party-system using predefined custom code
$result = ApiEnneo::executeUdf(
name: 'send-to-third-party',
parameters: ['method' => 'POST', 'api' => 'redirect', 'params' => $payload]
);
echo json_encode($result);
In this example, the user profile is loaded first using the Enneo SDK. Subsequently, extended data for the ticket and the conversations are loaded. At the end of the code snippet, the data of the current conversation is transmitted to the external ticket system. Here, a function send-to-third-party is used, which must be deposited as a “User defined Function” beforehand.