Scenario

In some cases, it is necessary for certain tickets and their associated conversations to be available in another ticket system. For example, a customer’s response to a request from the ticket could also be displayed in a parallel system. This can be enabled via a Webhook.

Solutions

To ensure that new conversations are synchronized in both systems, a webhook can be implemented. This requires the relevant email account to be selected under Settings -> Communication channels -> Email accounts. If the webhooks are not yet active for this account, the Webhooks switch must be activated so that the fields to configure the “New Email” webhook appear.

Example of customer specific code

For clarity, error handling is intentionally omitted in this code example.

The following PHP code uses the Enneo SDK to retrieve information from one ticket system and transmit it 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 with the Enneo SDK. Then extended data for the ticket and the conversations are loaded. At the end of the code snippet, the data from the current conversation is transferred to the external ticket system. A function send-to-third-party is used for this, which must be stored as a “User defined Function” in advance.