Skip to main content

Scenario

In some cases, it is necessary for certain tickets and the accompanying conversations to be available in another ticketing system. For example, a customer’s response to a request from the ticket can also be displayed in a system running in parallel. This can be facilitated through the usage of webhooks.

Solution Possibility

To ensure new conversations are synchronized in both systems, a webhook can be implemented. In the Settings -> Communication Channels -> Email Accounts, the appropriate email account must be selected. If the webhooks are not yet active on this account, the Webhooks switch must be activated so that the fields for the configuration of the “New Email” webhook appear.

Example of customer-specific code

Error handling is deliberately omitted in this code example for better readability.
The following PHP code uses the Enneo SDK to retrieve information from a ticketing system and transmit it to a third-party 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 Enneo SDK is initially used to load the user profile. Subsequently, advanced ticket data and the conversations are loaded. At the end of the code snippet, the data of the current conversation is transferred to the external ticket system. A function send-to-third-party is used, which must be stored previously as a “User defined Function”.