Scenario

Assume there is a reporting system in which the status information for the tickets from Enneo should be displayed. The third-party system has a technical interface (API) through which the information about the tickets can be transmitted. The third-party system requires the sender of the ticket and the status of the ticket as input parameters when calling the interface.

Possible Solution

Every status change of a ticket triggers a “TicketUpdated” event. To configure this process, go to Settings -> Integration into Peripheral Systems -> Events and create a new event hook by selecting the “TicketUpdated” event. Then the configuration can begin.

Viewing the Data in the Event

The data provided in the event can be viewed on one of the tickets. Here is an example of the data:

{
  "userId": 123,
  "changes": {
    "status": "closed"
  },
  "ticketId": 456
}

In this case, the ticket with the ID 456 was closed by the user with the ID 123.

Example of Customer-Specific Code

If the data available in the event is not sufficient, additional data can be loaded in the customer-specific code using the Enneo SDK.

Configured input parameters will be loaded by Enneo and will be available in the input variable. As output, a valid JSON object is expected, which will be displayed in the technical details of the activity log on the ticket after execution.

Error handling is deliberately omitted in this code example for clarity.

<?php

use EnneoSDK\Api;
use EnneoSDK\ApiEnneo;

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

/** @var stdClass $in - contains all defined input parameters from the event */

// Loading the necessary data from enneo
$ticket = ApiEnneo::getTicket($in['ticketId']);
$sender = $ticket->sender;

// Call of the third-party system with necessary parameters
$result = Api::call(
    method: 'POST',
    url: 'https://third-party-system/api/ticket-status-update',
    headers: [
        'x-api-key: tokenExampleHere',
        'Accept: application/json'
    ],
    params: [
        'ticketSender' => $sender,
        'ticketStatus' => $in['status']
    ]
);

echo json_encode($result);