Letter
Receiving and Sending
Options and Configuration
Just like emails, letters can also be connected in enneo in two ways, depending on the requirements: IMAP and API.
Receipt of Letters
Option 1: Import of Letters as E-mail with Attachment
This solution is recommended if a scanning service is used, which converts incoming letters into emails with the letters as an attachment (e.g., PDF).
To connect letters, the following steps are necessary:
- Connect the mailbox as described here: Connecting emails
- Ensure that the emails are recognized as letters. enneo recognizes an email with an attachment as a letter if one of these criteria is met:
- The sender is the scanning service. You enter the address under “Sender Recognition”; separate several addresses with commas.
- The subject starts with "LETTER". You set a different keyword under “Subject recognition”. It is case-sensitive. If the field is empty, enneo recognizes letters by the sender only.
Recognition rules per letter subchannel
Each letter subchannel has its own recognition rules: Settings → Letter → [letter subchannel]. This way, for example, scans from two scanning services end up in two separate letter subchannels. When these rules were introduced, every existing letter subchannel took over the previous account-wide rules, so recognition stays as it was until you change something.
If an email matches several letter subchannels, this order decides:
- A mail to the scan address of a letter subchannel stays in that subchannel.
- Otherwise enneo checks the active letter subchannels, the default subchannel first. The sender takes precedence over the subject: first the first subchannel whose sender matches wins, then the first whose subject keyword matches.
- If none matches, the mail stays an email.
Note
Inactive letter subchannels do not accept letters. enneo checks the recognition rules only once, when the email arrives. A mail that was not assigned to an active letter subchannel at that point stays an email, even if you switch the subchannel on or change the rules later.
Option 2: Import of Letters via the REST API
- When importing letters via the API, the
channelattribute must be set to "letter". Enneo will handle the rest. - An example of a request with minimal parameters:
curl --location 'https://demo.enneo.ai/api/mind/ticket' \
--header 'Authorization: bearer <token>' \
--data '{
"channel": "letter",
"process": "batch",
"attachments": [
{
"base64": "base-64-encoded-string-of-pdf-or-image-file"
}
]
}'Notes:
- The
processparameter can be set tobatch(default),realtime, orfalse. In all cases, the API response returns immediately after saving the ticket - AI processing is running in the background. The difference is when it starts: Withbatch, the ticket is queued for normal processing and is handled by the next available worker. Withrealtime, AI processing is initiated immediately in its own background process, without waiting in the queue - useful if a ticket should preferably be processed immediately. Withfalse, the ticket is created without AI processing. - Attachments can either be uploaded as Base64-encoded files via the
base64parameter or provided via a URL using theurlparameter. - All ticket attributes defined in the API specification can also be specified. This is useful for transmitting metadata such as a contract ID, tags, or a creation date.
Supported File Formats
Enneo supports the automatic conversion of attachments in the following formats:
- PNG
- JPG
- TIFF
One Letter, One Scan
An incoming letter contains exactly one scan: a file in one of the formats above. Images embedded in the text of an email do not count as a scan. Other files may come along: they stay on the letter ticket and can be opened. The rule applies to every way a letter comes in:
- REST API: A request with attachments but no scan among them, or with more than one scan, is refused with status 400 and the reason. Whether a file is a scan is decided by its file extension.
- Email recognized as a letter by its sender or subject: If it contains no scan or more than one, it stays an email ticket with all its attachments. The reason is shown in the event details.
- Scan address of the letter channel: A mail with no scan or more than one becomes an email ticket of the default email channel, with all its attachments.
If your scanning service sends several letters in one mail, have it send each letter on its own.
Dispatch of Letters
When a letter is to be sent, enneo passes a JSON object with the relevant data - such as recipient, subject, and text content - to the respective user code. From there, they can call a printing service of their choice via API.
You configure this under Settings → Letter → (select mailbox) → Webhooks: switch on “Enable Webhooks” and add the code under “Send Letter”.
Here is example code for sending a letter:
import importlib.util
import os
import json
file_path = os.getenv("SDK", "sdk.py")
spec = importlib.util.spec_from_file_location("sdk", file_path)
sdk = importlib.util.module_from_spec(spec)
spec.loader.exec_module(sdk)
input_data = sdk.load_input_data()
ticket_id = input_data.get("ticketId")
# Optional: load ticket data if you need it elsewhere
ticket_data = sdk.ApiEnneo.get(f"/api/mind/ticket/{ticket_id}")
# Build payload from input_data
payload = {
"to": input_data.get("to"),
"subject": input_data.get("subject"),
"body": input_data.get("body"),
"attachments": input_data.get("attachments", []),
"userId": input_data.get("userId"),
"ticketId": ticket_id,
"conversationId": input_data.get("conversationId", ""),
"contractId": input_data.get("contractId"),
"customerId": input_data.get("customerId"),
"subchannelId": input_data.get("subchannelId", ""),
}
try:
echo_response = sdk.Api.call(
method="POST",
url="https://echo.enneo.ai/api/echo", # replace with your printing service here
headers={},
params=payload,
)
output_msg = "Letter sent successfully"
except Exception as e:
print(json.dumps({"input": input_data, "error": str(e)}))
exit(1)
print(json.dumps({
"input": input_data,
"payloadSentToEcho": payload,
"echoResponse": echo_response,
"output": output_msg,
}))Validation of Postal Addresses
Postal addresses are validated so that no letters are sent to invalid addresses and returned as postal returns. These are described here: Address Validation
Use of Addresses Stored in ERP
Enneo can reply to an address stored by you instead of the AI-recognized sender. For this, the variable letterAddress must be set in the response format of the contract data, e.g. "letterAddress": "Laura Ludwig, Hauptstraße 29, 20249 Hamburg".
Replying by email
Incoming letters can also be answered by email. For this, the option “Channel shift to Email” must be enabled in the letter settings. How the recipient is prefilled is controlled by the switch “Prefill ERP email for letter replies” (on by default):
- On: The customer's email address from the ERP is entered as the recipient. If none is stored there, the reply is sent by letter.
- Off: Every letter is answered by email, and the agent enters the recipient.
You choose which email account sends these replies in the letter mailbox under “Email account for email replies”.
When the customer replies to that email, the reply lands in the letter ticket. Their email address then becomes the recipient, so the next reply is sent by email again. How replies are matched is described here: Customer replies to emails from other channels