Inbound email actions allow defining actions an instance takes when receiving an email. They allow to process inbound email as either an automatic reply or as a record in the system. The processing takes the type of incoming mail and other attributes into account.

They are similar to business-rules in the usage of scripts and conditions that perform actions on the target table. Emails are checked by inbound email actions for defined conditions and some watermark that associates the email with a task. If the conditions are met, then the inbound email action performs the pre-configured activities. They may be of two types:

  • Record Action: runs a specified script.
  • Reply Email: when triggered, sends a reply email.

For inbound email processing, the default email account must be configured preliminary. See Email processing to learn more about email accounts configuring.

Inbound email actions are most commonly used to process emails (for example, create a new incident when a received incoming email contains "Incident" in the subject line).

Configuring inbound email action


  1. Navigate to System Notification → Inbound Email Actions.
  2. Click New and fill in the fields.
  3. Click Save or Save and Exit to apply changes.

Role required: admin.



FieldMandatoryDescription
NameNInbound action displayed name.
Action TypeN

The action type. Available options:

  • Reply Email
  • Record Action.

When the "Reply Email" option is chosen, then the action behavior is to send an email in reply when triggered.

When the "Record Action" option is chosen, then the script runs (it should be specified in the Script field).


Please note that the Reply Email inbound action uses a default email account for sending emails, even when more than one email account is available.


TypeN

The message type required to run the action. Available choice options:

  • New – newly created letters, neither reply nor forward.
  • Reply – letters of this type usually have distinctive features, for example:
    • Subject line beginning with a recognized prefix (optionally).
    • Reply-To email header included in message.
  • Forward – forward letters, in line with the reply letters, usually can be distinguished by watermarks, or subject lines, or any other features.
  • All – these category summarizes all the letters (new and reply and forward letters).
DSNN

Select this checkbox to trigger the action in response to Delivery Status Notification letters.

This option is applied as long as selected inbound action Type is All.


InvitationN

Select this checkbox to trigger the action in response to Invitation letters.

This option is applied as long as selected inbound action Type is All.


DescriptionNEnter the detailed description of what this email action does (optionally).
Reply EmailNCompose the email message. It will be sent to the source address which triggered the inbound action.
FromY

Reference to the user, on behalf of which the script is executed, or the reply letter is sent.

ScriptNEnter the script that the inbound email action runs. You can use all methods of server-side API classes here.
TableNSelect the table where the action adds or updates records.
ActiveN

Select this checkbox to activate the action.

OrderNEnter the number to define the order of action processing. Actions are processed in ascending order (lower numbers are processed first).

Stop Processing

NSelect this checkbox to terminate other inbound actions after the current action runs.


Use case


We need to configure an inbound action implementing the following logic:

  • When the system receives an email with topic containing keyword "access", a new incident is created and assigned to the group responsible for security and access to the system and data.

We create an inbound action as below:

FieldValue
NameCreate incident (access issue)
Action TypeRecord Action
TypeNew
ActiveTrue
Script


ss.importIncludeScript('EmailHelper');
const helper = new EmailHelper();

(function runAction( /*SimpleRecord*/ event, /*SimpleRecord*/ email) {
  const letter = email.subject.match('aсcess'); //Keywords checking
  if (letter) {
    const incident = new SimpleRecord('itsm_incident');
    incident.subject = email.subject;
    incident.caller = helper.userIDbyEmail(helper.parseSender(email.from)); // If the sender's address is registered in the system,
// the Caller field will contain reference to an existing User record. If the address is unknown, the caller will be defined as Guest
     incident.description = email.body_text;
     incident.state = '-2'; // State is Registered
     incident.contact_type = '20'; // Type is Email
     incident.assignment_group='162920380313692887'; // ID of the group responsible for security and access
     incident.impact = '2'; // Moderate
     incident.urgency = '2'; // Moderate
     incident.insert();
  }
})(event, email);


Inbound actions logging


Every inbound action triggering is logged in the Script Log table. These logs can be filtered using the criteria below:

  • Source IS Inbound Action
  • Essence Document CONTAINS 0229fa8a-bcbe-1f11.

The Essence Document field is responsible for email processed by inbound action. You can enter full address or a part of it, and you can use precision or imprecision condition operators, respectively.

Use the Condition Builder to build filters that fit your needs.