Skip to main content

Scenario

By default, Enneo processes rule-based AI agents per dark processing for emails and letters, but not purely prompt-based ones. The reason is that the reliability of text produced purely by AI is less predictable than that of a rule value. However, there are certain customer inquiries – e.g. password reset instructions or login problems with the Android or Apple app – which can be fully automated with a certain level of reliability. Instead of using the standard dark processing, the smart AI agent itself should decide whether an answer is secure enough to be sent automatically.

Possible Solution

The approach consists of four steps: A custom AI tool marks safe answers, an Event Hook checks the marking and triggers the automatic execution.

Step 1: Create Custom AI Tool

Under Settings -> AI Customization -> AI Tools, create a new tool, e.g. with the name mark_answer_as_safe. This tool will be invoked by the smart AI agent when it is confident that the answer can be sent automatically. In the smart AI Agent’s prompt, there must be a reference to the tool, e.g.:
The following types of inquiries should be marked as safe: (a) Password reset or (b) Login problems with the Android or Apple app. In these cases, invoke the mark_answer_as_safe tool.

Step 2: Mark Ticket in Tool as Automatically Executable

In the mark_answer_as_safe tool’s code, the ticket is marked as automatically executable via the API, for example 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 Event Hook for TicketCreated

Under Settings -> System Integration -> Events, create a new Event Hook for the Event TicketCreated. This event is triggered after a new ticket has been received and the AI processing has been completed. The customer-specific code checks whether the ticket has been marked as safe. If needed, additional checks can be performed, e.g. whether certain tags are set or the customer has been clearly identified. If all criteria are met, the automatic execution is triggered:
POST /api/mind/ticket/:ticketId/autoexecute?executeAgentId=:aiAgentId
The executeAgentId parameter is the numeric ID of the AI agent that should be executed. All other potentially recognized AI agents are ignored.
This code example intentionally omits error handling to improve 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 was 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 recognition or tags
// if (!$ticket->contractId) {
//     echo json_encode(['autoExecute' => false, 'reason' => 'No contract recognized']);
//     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 carries out the following steps:
  1. The answer created by the AI agent is sent to the customer.
  2. The ticket is closed.
  3. The ticket is marked as fully automated processing (L5).