Data that Enneo passes to your code (Input)
Copy
Ask AI
{
"contractId": "VN-00001"
}
Data structure expected by Enneo as a return value (Output)
Copy
Ask AI
{
// Mandatory properties. Must be defined for Enneo to function
"id": "VN-00001", // must be an integer or string up to 50 characters
"customerId": "C-abcd-123", // must be an integer or string up to 50 characters
"business": false, // boolean, indicating whether the customer is a company or individual
"lastname": "Smith", // last name of the customer, can be null ONLY if business is true
"company": null, // company name, e.g. "ACME Corp.", can be null ONLY if business is false
// Recommended properties. Should be defined if possible and is used by Enneo's AI and customer identification logic. Defaults to null if not set
"firstname": "John", // first name of customer, can be null
"email": "[email protected]",
"deliveryAddress": "Horst-Kohl-Str. 15a, 12157 Berlin", // address of customer
"billingAddress": null, // Optional separate billing address. If null, billing address is the same as delivery address
"phone": "+49190332332",
"zip": "12157", // Used by the default call/phone identification based on contract id and zip code
// Optional preview section for the agent that is shown in the top right corner on the ticket page
"agentPreview": [
{
"url": "https://my-erp/customers/1234#tab=billing",
"type": "string",
"label": "Installment",
"value": "39 €",
"tooltip": null
},
{
"url": null,
"type": "string",
"label": "Consumption",
"value": "1085 kWh",
"tooltip": "Relevant for installments: 1085 kWh<br>NB-JVP: 1637 kWh<br>Previous year: 1637 kWh<br>According to customer: 3500 kWh"
}
],
// Links to any systems holding client data you want your agents to have quick access to
"erpUrls": [
{
"url": "https://my-erp.com/contract-details/1234",
"icon": "/icons/powercloud.svg"
},
{
"url": "https://my-marketing-crm.com/customer-details/c123",
"icon": "/icons/link.svg"
}
],
// Other properties that you want Enneo to be aware of can be defined here.
// Below are some examples for inspiration from the energy sector
"iban": "DE0000000000000000",
"energy": "electricity",
"status": "expired",
"endDate": "2021-10-28",
"orderId": 752050,
"vatRate": 0.19,
"basePrice": 49.41
}
Example Implementation
- PHP
Copy
Ask AI
<?php
// Load Enneo SDK. Input is made available through $in
use EnneoSDK\ApiEnneo;
use EnneoSDK\Setting;
use EnneoSDK\Api;
require(getenv()['SDK']);
$contractId = $in->contractId; // Populated with the data received, e.g. 1234 or "C-212"
// You can call your API and/or add your data processing logic here
// Option 1: Directly
// $contractRawData = Api::call(method: 'POST',url: 'https://xxx', headers: ['Authorization: AbC'], params: http_build_query(['contractId' => $contractId]));
$contractRawData = Api::call(method: 'GET', url: 'https://admin.enneo.ai/api/seed-contracts/' . $contractId);
// Option 2: Through a user-defined-function that handles e.g. OAuth2 session tokens
// $contractRawData = ApiEnneo::executeUdf('erpApiCall', ["method" => "GET", "api" => "vertrag/$contractId", "params" => false]);
// Option 3: By using Enneo user storage object as a database (only recommended for testing)
// $userDataObject = Setting::get('udfStorage');
// $contractRawData = array_search($contractId, array_column($userDataObject->contracts, 'contractId')) or throw new Exception("Contract $contractId not found");
// This is the data format you should return
$contract = [
// Mandatory properties. Must be defined for Enneo to function
'id' => $contractId, // must be an integer or string up to 50 characters
'customerId' => $contractRawData->customerId, // must be an integer or string up to 50 characters
'business' => $contractRawData->processedData->business, // boolean, indicating whether the customer is a company or individual
'lastname' => $contractRawData->processedData->lastname, // customer's last name, can be null ONLY if business is true
'company' => $contractRawData->processedData->company, // company name, e.g. "ACME Corp.", can be null ONLY if business is false
// Recommended properties. Should be defined if possible and is used by Enneo's AI and customer identification logic. Default to null if not set
'firstname' => $contractRawData->processedData->firstname, // customer's first name, can be null
'email' => $contractRawData->processedData->email,
'deliveryAddress' => $contractRawData->processedData->deliveryAddress, // customer's address
'billingAddress' => $contractRawData->processedData->billingAddress, // Optional separate billing address. If null, billing address is the same as delivery address
'letterAddress' => ($contractRawData->processedData->company ?: $contractRawData->processedData->firstname.' '.$contractRawData->processedData->lastname).', '.($contractRawData->processedData->billingAddress ?? $contractRawData->processedData->deliveryAddress),
'phone' => $contractRawData->processedData->phone,
// Preview section for the agent that is shown in the top right corner on ticket page
'agentPreview' => array_map(function($item) {
return [
'url' => $item->url, // e.g. "https://my-erp/customers/1234#tab=billing"
'type' => $item->type, // e.g. "string"
'label' => $item->label, // e.g. "Installment"
'value' => $item->value, // e.g. "39 €"
'tooltip' => $item->tooltip, // e.g. "As of January 1, 2025"
];
}, $contractRawData->processedData->agentPreview),
// Links to any systems holding client data you want your agents to have quick access to
'erpUrls' => [
[
'url' => 'https://my-erp.com/contract-details/1234',
'icon' => '/icons/powercloud.svg'
],
[
'url' => 'https://my-marketing-crm.com/customer-details/c123',
'icon' => '/icons/link.svg'
]
],
'erpUrls' => array_map(function($item) {
return [
'url' => $item->url, // e.g. "https://sap.example.com/contracts/100001"
'icon' => $item->icon, // e.g. "/icons/sap.svg",
'title' => $item->title, // e.g. SAP
];
}, $contractRawData->processedData->erpUrls),
];
// Any other properties that you want Enneo to be aware of can be defined here.
$contract = [
...$contract,
...array_diff_key((array) $contractRawData->processedData, $contract)
];
echo json_encode($contract);