Inbound email actions are most commonly used to process emails. For example, if an incoming email contains “Incident” in the subject line, the system creates an incident record.
Inbound email actions are similar to business rules in the usage of scripts and conditions that perform actions on the target table. Inbound email actions verify emails for defined conditions and features that associate an email with a task. If the conditions are met, the inbound email action performs the pre-configured activities. There are two types of them:
Unlike Notification Rules, inbound email actions enable the user to interact with the records in the system.
For example, while processing an incident in the Information needed state, the system inserts the body of this email to the Additional comment field in the Activity Feed when the caller sends their response. To do so, an inbound email action is created. The condition for this action is the presence of a certain text in the subject and the same task number as in the incident record.
To process inbound email, set up the default email account. See the Email Accounts article to learn how to do it. |
Inbound actions include three major groups of parameters:
The third group of parameters is required to organize multiple inbound actions in a way that they check an incoming email to match the condition defined in each of them, in a certain order. Оne incoming email can trigger execution of none, one or several action scripts in a row, depending on the values of the Active, Order and Stop processing when complete fields of the action.
If there are several actions for incoming emails in the system, they are processed starting from the action with the lowest Order, according to the following logic:
Role required: admin. |
Field | Mandatory | Description | ||
---|---|---|---|---|
Name | N | Specify an action name. | ||
Action type | N | Select the action type. Available options:
| ||
Message type | N | Specify a message type required to run the action. Available choice options:
| ||
DSN | N | Select this checkbox to trigger the action in response to Delivery Status Notification emails. | ||
Invitation | N | Select this checkbox to trigger the action in response to Invitation emails. | ||
Description | N | Add a detailed description of what this email action does. | ||
Reply email | N | Enter the text of the reply letter. It will be sent to the original email address that initiated the action. | ||
From | Y | Select a user, who initiates a script execution, or sends a response email. | ||
Script | N | Enter a script that triggered by the inbound email action. You can use all methods of server-side API classes.
| ||
Active | N | Select this checkbox to activate the action. | ||
Order | N | Enter a number to define the order of action processing. Actions are processed in ascending order. | ||
Stop processing when complete | N | Select the checkbox to end the message processing after the current action is completed. All subsequent actions (with a higher Order) are ignored. |
You need to configure an inbound email action implementing the following logic:
When the system receives an email with the subject containing the keyword “access”, a new incident is created and assigned to the group responsible for security and access to the system and data.
Create an inbound email action as shown below:
Field | Value | |
---|---|---|
Name | Create incident (access issue) | |
Action type | Record Action | |
Message type | New | |
Active | true | |
Script |
|
Every inbound email action triggering is logged in the Script Log. You can filter these logs using the criteria below:
The Essence Document field is responsible for email processed by the inbound email action. Enter the full address or a part of it, and use precise or imprecise condition operators. |
The incoming mail parsing returns the address value for the From field of a record from the Email (sys_email) table in lower case.
When searching for a user by email in the Script column, do not use the IS operator because the value of email can be entered with uppercase letters. For example, J.Doe@mail.com.
user.get('email', 'j.doe@mail.com'); |
Also, do not use the LIKE operator when searching for a user by email because the search will find a user with a similar email, for example, 'raj.doe@mail.com'.
user.get('email', 'like', 'j.doe@mail.com') |
The following example shows the script with the userIDbyEmail() method that searches for a user by email value:
class MyEmailHelper extends EmailHelper { userIDbyEmail(email) { const user = new SimpleRecord('user'); user.addQuery('email', 'startswith', email); user.addQuery('email', 'endswith', email); user.selectAttributes('sys_id'); user.setLimit(1); user.query(); if (user.next()) { return user.sys_id; } return this.searchGuest(); } } |