---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://www.servicenow.com/docs/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Inbound email action examples

# Inbound email action examples {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

Various examples of inbound email actions are available to help you build your own
inbound email actions. These examples show how to set up inbound email actions to handle email
replies, create (log) a problem record, request a change, and update an incident.

## Inbound email action example: handling email replies {#ariaid-title2}

This example shows you how to set up inbound email actions to handle replies that
users send back to the instance.

### Before you begin

Role required: admin

### About this task

The inbound email action parses the email and responds using a script. By default,
an email received by the instance creates a new incident, and the body of the email
is added to the Additional Comments text box. More refined
Inbound Email Actions can create incident tickets with more data, thus saving the
incident management team valuable time.

Normally, when a user responds to an email sent by the instance, the inbound email
action matches the watermark to an existing incident, and updates the incident
rather than creating a new record. However, if the watermark is missing, this
inbound email action attempts to match a reply to the original incident.

This inbound email action is replicated in Workflow Studio as the sample
flow Inbound Email Flow Example: handling email replies. To
view the sample flow, navigate to Flow DesignerDesigner.

### Procedure

1. Navigate to System PolicyInbound Actions and click New.
2. Populate the form as follows:  
   {#t_DefInboundEmailActionRep__table_dth_jbj_wr__entry__2}

   | Field | Value |
   |-|-|
   | Name | Update Incident |
   | Type | Reply |
   | Target table | Incident \[incident\] |
   [Table 1. Inbound action field values]

   {#t_DefInboundEmailActionRep__table_dth_jbj_wr}
3. In Script, enter this code.  

       gs.include('validators');
        
       //Note: current.caller_id and current.opened_by are already set to the first UserID that matches the From: email address
        
       if (current.getTableName() == "incident") {
         current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
        
         if (email.body.assign != undefined)
           current.assigned_to = email.body.assign;
        
         if (email.body.priority != undefined && isNumeric(email.body.priority))
           current.priority = email.body.priority;
        
         if (email.body.category != undefined)
           current.category = email.body.category;
        
         if (email.body.short_description != undefined)
           current.short_description = email.body.short_description;
        
         current.update();
       }

## Inbound email action example: logging a problem {#ariaid-title3}

This example shows you how to set up inbound email actions to a create a problem
record.

### Before you begin

Role required: admin

### About this task

Inbound email actions allow users to log or update incidents on an instance via
email. The inbound email action parses the email and responds using a script.

This inbound email action is replicated in Workflow Studio as the sample
flow Inbound Email Flow Example: logging a problem. To view
the sample flow, navigate to Flow DesignerDesigner.

### Procedure

1. Navigate to System PolicyInbound Actions and click New.
2. Populate the form as follows:  
   {#t_DefInboundEmailActionLogProb__simpletable_iry_cjf_hq__entry__2}

   | Field | Entry |
   |-|-|
   | Name | Log Problem |
   | Type | New |
   | Active | True |
   | Target Table | Problem \[problem\] |
   | Condition | email.subject.indexOf("Problem: ") == 0 |
   | Script | current.description = email.body_text; current.short_description = email.subject.toString().substring(9); current.assignment_group.setDisplayValue("Development"); if (email.body.assign != undefined) current.assigned_to = email.body.assign; current.insert(); |
   [Table 2.]

   {#t_DefInboundEmailActionLogProb__simpletable_iry_cjf_hq}

## Inbound email action example: requesting a change {#ariaid-title4}

This example shows you how to set up inbound email actions to create a change request
record.

### Before you begin

Role required: admin

### About this task

Inbound Email Actions allow users to log or update incidents on an instance via
email. The inbound email action parses the email and responds using a script.

### Procedure

1. Navigate to AllSystem PolicyInbound Actions and click New.
2. Populate the form as follows:  
   {#t_DefInboundEmailActionCR__simpletable_iry_cjf_hq__entry__2}

   | Field | Entry |
   |-|-|
   | Name | Request Change |
   | Type | New |
   | Active | True |
   | Target Table | Change Request \[change_request\] |
   | Condition | email.subject.indexOf("Change Request: ") == 0 |
   | Script | current.comments = email.body_text; current.short_description = email.subject; current.notify = 2; if (email.body_text.assign != undefined) current.assigned_to = email.body_text.assign; if (email.body_text.priority != undefined) current.priority = email.body_text.priority; if (email.body_text.category != undefined) current.category = email.body_text.category; current.insert(); |
   [Table 3.]

   {#t_DefInboundEmailActionCR__simpletable_iry_cjf_hq}

## Values automatically set from incoming email {#ariaid-title5}

The default inbound action for the Incident table automatically sets the following field values when it receives an incoming email.
{#r_ValuesAutoSetFromIncEmail__table_fzv_hgq_n4__entry__2}

| Field value set | Value used from incoming email |
|-|-|
| `current.caller_id` | User ID of the first user whose email address matches the `email.from` variable. |
| `current.opened_by` | User ID of the first user whose email address matches the `email.from` variable. |
[Table 4. Values automatically set from incoming email]

{#r_ValuesAutoSetFromIncEmail__table_fzv_hgq_n4}If multiple users have the same email address, the instance first searches for an active user with the email address. Use unique email addresses for each user record whenever possible. If not, having only one active user with the shared email address guarantees that the instance always matches incoming email from this address to the active user.

*[\>]: and then


