Events & Webhooks
Example: Data Export for Reporting
Transmission of data to a reporting system using an example
Scenario
Assume that there is a reporting system in which the status information for tickets from Enneo are to 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 as input parameters when calling the interface, the sender of the ticket and the status of the ticket.
Possible Solution
Each status change of a ticket triggers a "TicketUpdated" event. To configure this process, go to Settings -> Integration into Other Systems -> Events and create a new event hook by selecting the "TicketUpdated" event. The configuration process can then 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, further data can be loaded in the customer-specific code with the help of the Enneo SDK.
Configured input parameters are loaded by Enneo and are available in the Input variable. A valid JSON_object is expected as output, which is displayed after execution in the technical details of the activity log on the ticket.
Info
Error handling is deliberately omitted in this code example for better clarity.
<?php
use EnneoSDK\Api;
use EnneoSDK\ApiEnneo;
require(getenv()['SDK'] ?? 'sdk.php');
/** @var stdClass $in - contains all defined input parameters from the event */
// Load the necessary data from enneo
$ticket = ApiEnneo::getTicket($in['ticketId']);
$sender = $ticket->sender;
// Call the third-party system with the required 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);TBD