Enneo

Events & Webhooks

Example: Synchronization with another Ticket System

Synchronization of conversations for tickets with another ticket system as an example

Scenario

In some cases, it's necessary for specific tickets and their associated conversations to be available in an additional ticket system. For instance, a customer's response to a ticket request can also be displayed in the parallel running system. This can be enabled by using a webhook.

Solution

To ensure that new conversations are synchronized in both systems, a webhook can be implemented. Under 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

Info

In this code example, error handling is deliberately omitted for better clarity.

The following PHP code uses the enneo SDK to retrieve information from a ticket system and send it to a third-party system.

<?php

use EnneoSDK\ApiEnneo;

require(getenv()['SDK'] ?? 'sdk.php');

/** @var stdClass $in - contains all the 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);
tbd

In this example, the user profile is first loaded using the enneo SDK. Afterwards, extended ticket data and 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 previously stored as "User defined Function".