Docs
On this page
reference2 min readApplication: System Email

Inbound message fields

Fields of an inbound message, the email object its scripts receive, and how Servicely matches an email to a record and a user.

An inbound message is a rule that decides what Servicely does with a collected email: create an interaction, add a comment to a ticket, or run any other server script. Use this page when you build or change one under Administration → Messaging → Inbound messages.

How an email is processed

The Inbound email processing job collects mail through each active inbound messaging account. For each email, Servicely works out its type and any record it replies to. It then tries the active inbound messages for that type in Priority order, lowest first. The first one whose To, From and Condition all match runs its processing script, and no other runs.

Before matching, Servicely drops the email if an active email address override disables inbound processing for the sender. It stops with an error if it detects an email loop. See Email address override fields.

The shipped inbound message “Interaction - Create new interaction” with Type New, Table Interaction, an empty condition and the processing script.

Matching fields

Field Type Required Behaviour Purpose
Name String No Shown in lists and logs Identifies the rule
Active Yes or No No Default Yes. Only active rules are candidates. Turns the rule on
Providers Multiple choice No Email processing only considers rules whose providers include Email The channels the rule handles
Type Choice No New, Forward or Reply The kind of email the rule handles
Table Table No For replies, the rule matches only if the replied-to record is in this table The record type the rule updates
To String No Empty matches every address. Compared with the address the email was originally sent to, before redirection. Limits the rule to one mailbox address
From String No Empty matches every sender Limits the rule to one sender
Priority order Integer No Default 0. Lower numbers are tried first. Only the first matching rule runs. Orders the rules
Condition Script No Sets answer to true or false. Empty always matches. Adds any other test on the email

Processing fields

Field Type Required Behaviour Purpose
User script Script No Receives email and sets answer to a User record. Empty looks the sender up by email address. Chooses the user, for example when several users share an address
Processing script Script No Runs with email, current (the replied-to record) and user Creates or updates records

A processing script that changes current must call current.update() after its last change. Attachments are copied with AttachmentManager.copyEmailAttachmentsToJournal, as the example below shows.

Example: create an interaction

This is the start of the shipped “Interaction - Create new interaction” script.

let interactionRec = Table("Interaction").newRecord()
    .ShortDescription(email.subject)
    .Description(email.no_html_body)
    .Source("email");

AttachmentManager.copyEmailAttachmentsToJournal(email.id, interactionRec.ClientJournal, email.body, email);

if (user.UserName() != "guest") {
    if (user.Mobile.hasValue()) {
        interactionRec.Phone(user.Mobile());
    }
    if (user.Location.hasValue()) {
        interactionRec.Location(user.Location.value());
    }
}
interactionRec.create();

The email object

Field Type Required Behaviour Purpose
email.id String Yes ID of the System email record Passes the email to attachment functions
email.subject String Yes The subject line Record titles and conditions
email.body HTML Yes The full body Full content
email.body_reply HTML Yes The body with earlier replies stripped Comments on existing records
email.no_html_body Text Yes The full body without HTML Plain-text fields
email.no_html_body_reply Text Yes The reply part without HTML Plain-text comments
email.from String Yes The sender’s address Matching and user lookup
email.to String Yes The address the email was sent to Routing by mailbox
email.recipients_to Array Yes Addresses in To Routing and followers
email.recipients_cc Array Yes Addresses in CC Routing and followers
email.type String Yes New, Reply or Forward Conditions
email.matched Yes or No Yes True when a replied-to record was found Conditions
email.is_auto_reply Yes or No Yes True when the headers or an override mark it as an auto reply Skipping automated mail
email.is_no_reply Yes or No Yes True when the sender is a no-reply address Skipping replies to robots
email.is_email_loop Yes or No Yes True when Servicely detected a mail loop Loop protection
email.record Record Yes The System email record Logging and custom handling

Record and user matching

Servicely appends a watermark such as servicely:MSG0000001: to every email it sends about a record. To find the record an email replies to, it checks the Reply-To header, the thread ID, the References header and the body watermark. A match sets Type to Reply and makes the record available as current.

Without a user script, Servicely looks up the sender’s address among users. A user can hold extra addresses as user email aliases, in the Email aliases list on the user record or the UserEmailAlias table. Inbound matching accepts the primary address or any alias. Outbound email always goes to the primary address.

Shipped inbound messages

Name Table Type
Interaction - Create new interaction Interaction New
Interaction - Create new interaction from forward Interaction Forward
Interaction - Update existing interaction Interaction Reply
Incident - Update existing incident Incident Reply
ITSM Request - Update existing ITSM request ITSMRequest Reply
Problem - Update existing problem Problem Reply
Change - Update existing change Change Reply
HR Case - Update existing HR case HRCase Reply
Incident task - Update existing Incident task IncidentTask Reply
ITSM Request task - Update existing ITSM Request task ITSMRequestTask Reply
Problem task - Update existing problem task ProblemTask Reply
Change task - Update existing change task ChangeTask Reply
HR Case task - Update existing HR case task HRCaseTask Reply
Approval task - Approve / Reject for ITSM request, change, HR case and knowledge ApprovalTask Reply
Last updated 24 November 2026commit 88e011e506a8Chris Jones
Back to top