Inbound email action example: updating an incident

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.

Before you begin

Role required: admin

About this task

By default, an email received by the instance creates a new incident, sets the Contact type field to Email, and adds the body of the email to the Additional Comments field. More refined Inbound Email Actions can create incident tickets with more data, thus saving the incident management team valuable time.

The following Inbound Email Action applies to email replies. Normally, when a user responds to an email sent by the instance, the inbound email action will match the watermark to an existing incident, and update the incident rather than creating a new record. However, if the watermark is missing, this Inbound Email Action will attempt to match a reply to the original incident.

To define an inbound email action for replies:

Procedure

  1. Navigate to System Policy > Email > Inbound Actions and click New.
  2. Populate the form (see table).
    Name Update Incident
    Action type Reply Email
    Target table Incident [incident]
    Actions > Script Insert the following:
    gs.include('validators');
     
    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();
    }