Skip to main content

Scenario

By default, Enneo only processes rule-based AI agents via dark processing for emails and letters, not purely prompt-based ones. This is because the reliability of purely AI-generated text is less predictable than that of a rule-based system. However, there are certain customer inquiries — e.g. password reset instructions or login issues with the Android or Apple app — that can be answered fully automatically with sufficient reliability. Instead of using standard dark processing, the smart AI agent should decide on its own whether a response is safe enough to be sent automatically.

Possible Solution

The approach consists of four steps: A custom AI tool marks safe responses, an event hook checks the marking and triggers the automatic execution.

Step 1: Create a Custom AI Tool

Under Settings -> AI Customization -> AI Tools, create a new tool, e.g. named mark_answer_as_safe. This tool is called by the smart AI agent when it is confident that the response can be sent automatically. The smart AI agent’s prompt must reference the tool, e.g.:
The following types of inquiries should be marked as safe: (a) password reset or (b) login issues with the Android or Apple app. In these cases, call the tool mark_answer_as_safe.

Step 2: Flag the Ticket as Auto-Executable in the Tool

In the code of the mark_answer_as_safe tool, the ticket is flagged as auto-executable via the API, e.g. with the following code:
<?php

use EnneoSDK\ApiEnneo;

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

ApiEnneo::patch(
    endpoint: '/api/mind/ticket/' . $in->ticketId,
    body: [
        'additionalData' => [
            'markedAsSafe' => 'true'
        ]
    ]
);

echo json_encode(['success' => true]);

Step 3: Create an Event Hook for TicketCreated

Under Settings -> Integration into Other Systems -> Events, create a new event hook for the TicketCreated event. This event is triggered after a new ticket is received and AI processing is completed. In the custom code, check whether the ticket has been marked as safe. Additional checks can be performed as needed, e.g. whether specific tags are set or the customer has been clearly identified. If all criteria are met, trigger the automatic execution:
POST /api/mind/ticket/:ticketId/autoexecute?executeAgentId=:aiAgentId
The executeAgentId parameter is the numeric ID of the AI agent to be executed. Any other potentially detected AI agents will be ignored.
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);

// Check if the ticket has been marked as safe
$markedAsSafe = $ticket->additionalData->markedAsSafe ?? null;

if ($markedAsSafe !== 'true') {
    echo json_encode(['autoExecute' => false, 'reason' => 'Not marked as safe']);
    return;
}

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

// ID of the AI agent to be executed
$aiAgentId = 123; // Adjust to the actual agent ID

// Trigger automatic execution
$result = ApiEnneo::post(
    endpoint: '/api/mind/ticket/' . $in->ticketId . '/autoexecute?executeAgentId=' . $aiAgentId
);

echo json_encode(['autoExecute' => true, 'result' => $result]);

Step 4: Automatic Processing by Enneo

After calling 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).