Skip to main content

Scenario

By default, Enneo only triggers automatic execution (dark processing) of AI agents on the first incoming email of a ticket and only when exactly one AI agent is detected. Standard dark processing does not apply in two situations:
  1. Multiple AI agents detected: A customer raises multiple concerns in a single email, e.g. a cancellation and a revocation. Enneo detects both AI agents but does not auto-execute either as a safety measure.
  2. Follow-up replies: A customer replies again to an existing ticket. AI processing runs (tags, AI agent detection, parameter extraction), but automatic execution is not triggered again.
In both cases, the ticket is assigned to a human agent instead. This behavior can be customized with an event hook.

Possible Solution

An event hook reacts to incoming tickets or customer replies, checks the detected AI agents, and triggers automatic execution for each one individually.

Step 1: Create an Event Hook

Under Settings -> Integration into Other Systems -> Events, create one or both of the following event hooks:
  • TicketCreated — triggered after a new ticket is received and AI processing is completed. Use this when multiple AI agents on the initial email should be auto-executed.
  • TicketResponse — triggered when a reply to an existing ticket from the customer is received and AI processing is completed. Use this when AI agents should also be auto-executed on follow-up replies.
The following code can be used for both events. It loads all detected AI agents (intents) with status ready and executes each one individually:
POST /api/mind/ticket/:ticketId/autoexecute?executeAgentId=:aiAgentId&allowMultipleIntents=true&allowWithReplies=true
The executeAgentId parameter is the numeric ID of the AI agent to be executed. It is set per call for one AI agent at a time.The allowMultipleIntents=true parameter allows automatic execution even when multiple AI agents have been detected on the ticket. Without this parameter, execution is rejected when multiple agents are detected as a safety measure.The allowWithReplies=true parameter allows automatic execution even when the ticket already contains inbound customer replies. Without this parameter, execution is rejected as soon as a customer reply exists on the ticket. This parameter is only relevant for the TicketResponse event.
Error handling is deliberately omitted in this code example for better clarity.
<?php

use EnneoSDK\ApiEnneo;

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

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

// Load ticket data
$ticket = ApiEnneo::getTicket($in->ticketId);

// Only process open tickets
if ($ticket->status !== 'open') {
    echo json_encode(['autoExecute' => false, 'reason' => 'Ticket is not open']);
    return;
}

// Load intents (detected AI agents)
$intents = ApiEnneo::get(endpoint: '/api/mind/intent/byTicketId/' . $in->ticketId);

// Collect all intents with status "ready"
$readyIntents = array_filter($intents->intents, fn($i) => $i->status === 'ready');

if (empty($readyIntents)) {
    echo json_encode(['autoExecute' => false, 'reason' => 'No intents with status ready found']);
    return;
}

// Optional: Additional checks, e.g. customer identification or tags
// if (!$ticket->contractId) {
//     echo json_encode(['autoExecute' => false, 'reason' => 'No contract identified']);
//     return;
// }

// Optional: Only auto-execute specific AI agents
// $allowedAgentIds = [4, 5, 12, 34];
// $readyIntents = array_filter($readyIntents, fn($i) => in_array($i->aiAgentId, $allowedAgentIds));

// Execute each detected AI agent individually
$results = [];
foreach ($readyIntents as $intent) {
    $result = ApiEnneo::post(
        endpoint: '/api/mind/ticket/' . $in->ticketId . '/autoexecute?executeAgentId=' . $intent->aiAgentId . '&allowMultipleIntents=true&allowWithReplies=true'
    );
    $results[] = ['agentId' => $intent->aiAgentId, 'name' => $intent->name, 'result' => $result];
}

echo json_encode(['autoExecute' => true, 'executedAgents' => count($results), 'results' => $results]);

Step 2: Automatic Processing by Enneo

After each call to the autoexecute endpoint, Enneo automatically performs the following steps:
  1. The response created by the AI agent is sent to the customer.
  2. The ticket is closed.
  3. The ticket is marked as fully automated (L5).
When multiple AI agents are present, each is executed separately and the results are processed sequentially.

Notes

  • The TicketCreated event is suitable for initial emails with multiple concerns. The TicketResponse event is suitable for follow-up replies. Both events can be configured simultaneously with the same code.
  • The allowWithReplies=true parameter is necessary because Enneo by default blocks automatic execution as soon as an inbound customer reply exists on the ticket. For the TicketCreated event, this parameter has no effect since there are no replies yet.
  • The allowMultipleIntents=true parameter is necessary because without it, execution is rejected when multiple agents are detected as a safety measure.
  • The executeAgentId parameter ensures that only the desired AI agent is executed per call.
  • It is recommended to maintain an allowlist (allowedAgentIds) of AI agents approved for automatic execution.