This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!

Introduction

Customers can send emails to create new cases and update current cases. They can also receive email updates from customer service agents as cases progress.

CSM uses the Email Accounts application to create and maintain email accounts. The system administrator can create multiple incoming email addresses that customers can use to communicate with customer service agents. The system administrator can also create one outgoing email address.

After the incoming and outgoing email addresses are created, the system administrator can set these properties for the email communication channel:

• Establish one of the incoming email addresses to automatically create a case. • Enable a prefix to include in the subject line of an email to any of the incoming email addresses that automatically creates a case. • Create cases for customers who are not currently in the system.

When an agent proposes a solution to a case, the customer receives an email with instructions for accepting or rejecting the solution. The customer can reply and include Accept or Reject in the first line of the email, or the customer can click the Accept or Reject link in the email.

Configure an email address for a product

  1. Navigate to Customer Service > Administration > Channels. csm04042020 (56).png
  2. Click New. csm04042020 (57).png
  3. Fill in the fields, as appropriate. csm04042020 (58).png
  4. Click on Submit Button.

Configure an email subject line prefix.

  1. Navigate to Customer Service > Administration > Properties.
  2. In the Email subject prefix format for new case field, enter the prefix. csm04042020 (59).png The default prefix is Case:.
  3. Click Save.

Configure signatures in quick messages and email client templates

  1. Navigate to Email Client > Quick Messages csm04042020 (60).png
  2. Click on New csm04042020 (61).png
  3. Select the table as Case csm04042020 (62).png
  4. Update mail body and signature csm04042020 (63).png
  5. When an agent replies to the customer with the template that you have predefined, agents will go to the Agent Workspace open the case. csm04042020 (64).png
  6. Select your predefined quick message from Quick message section csm04042020 (65).png

Creating rules for incoming emails that create and assign cases

Create your email-related business processes using Inbound Email Flows. Once you receive an email on a specified support email address, you can define rules to create cases and assign the cases to specific teams. Inbound Email Flows provide powerful configuration capabilities to manage emails along with your customer service processes through a visual Flow Designer interface.

  1. Navigate to Customer Service > Flow Designer > Inbound Email Flows. csm04042020 (66).png
  2. Select a default flow.The available flows are: csm04042020 (67).png
  3. Click the Inbound Email trigger. csm04042020 (68).png
  4. Modify the default email filter conditions or select New Criteria to add conditions. csm04042020 (69).png
  5. Select a table in the Reply Record Type field. csm04042020 (70).png
  6. Click Done.
  7. Click an existing action and expand it. csm04042020 (71).png
  8. Provide information for the action or click + to add a new action, flow logic, or subflow.
  9. Click Done.
  10. Verify the email flow and modify it if necessary.
  11. Click Save.
  12. Click Activate. csm04042020 (72).png

The defined inbound email flow is activated.

POC

We are going to do a POC with following requirement.

Below is the mail format that we will use to create case: inboundaction_040520201 (9).png

Requirements:

  1. Inbound email to case creation: Generate a case with:
    • Short Description: Subject of the email
    • Channel: Email
    • Contact: Contact from the email-Create new contact if one doesn’t exist
    • Category: Printer Management
    • Subcategory: Printer configuration
    • Severity:4
    • Assignment Group: SOC Printer Manager
    • Notes: Body of the email request
    • Email attachment: Attach to the case
  2. We need to include additional email address that are on cc filed in the incoming email.
  3. Case Update: Anyone (who is in CC) can reply to the email for an update to the case.

Solution:

inboundaction_040520201 (10).png

Create Inbound Email Action.

inboundaction_040520201 (1).png inboundaction_040520201 (2).png

Field Mapping:

inboundaction_040520201 (11).png

inboundaction_040520201 (3).png inboundaction_040520201 (4).png inboundaction_040520201 (5).png

//Get the HTML body of the email
var htmlcode = email.body_html;

//remove all the HTML tags from the HTML body
htmlcode = htmlcode.replace(/<style([\s\S]*?)<\/style>/gi, '');
htmlcode = htmlcode.replace(/<script>/gi, '');
htmlcode = htmlcode.replace(/<\/div>/ig, '\n');
htmlcode = htmlcode.replace(/<\/li>/ig, '\n');
htmlcode = htmlcode.replace(/<li>/ig, '  *  ');
htmlcode = htmlcode.replace(/<\/ul>/ig, '\n');
htmlcode = htmlcode.replace(/<\/p>/ig, '\n');
htmlcode = htmlcode.replace(/<br\s*[\/]?>/gi, "\n");
htmlcode = htmlcode.replace(/<[^>]+>/ig, '');
htmlcode = htmlcode.replace('  ', '');

//remove all the new line tags from the plain text
htmlcode = htmlcode.replace(/\r?\n|\r/g, '');

htmlcode = htmlcode.replace(/\s/g,'');

//Now put the result in system log
gs.info("final email String  " + htmlcode);

// Customer Contact Name:
var CutomerContactNamePattern = /CustomerContactName.+?(?=Title)/i;
var ccn = htmlcode.match(CutomerContactNamePattern).toString().split(":")[1];

//Title:
var TitlePattern = /Title.+?(?=Telephone)/i;
var titlep = htmlcode.match(TitlePattern).toString().split(":")[1];
//Telephone:
var TelephonePattern = /Telephone.+?(?=Email)/i;
var phonep = htmlcode.match(TelephonePattern).toString().split(":")[1];
//Email:
var EmailPattern = /Email.+?(?=ChangeRequested)/i;
var emailId = htmlcode.match(EmailPattern).toString().split(":")[1];

//Getting Acount name
var accountSysId = "";
var acountname = new GlideRecord("customer_account") ;
acountname.addQuery("name", "SC");
acountname.query();
if (acountname.next()) {
accountSysId = acountname.sys_id;
}
// End Account name

gs.info("emailId "+emailId);

//Contact name from the email body.Create new contact if one doesnot exist
var rec = new GlideRecord("customer_contact");
rec.addQuery("email", emailId.toString().trim());
rec.query();
if (rec.next()) {
current.contact = rec.sys_id;
gs.info("if emailId"+emailId+rec.sys_id);
}
else{
	var gr = new GlideRecord("customer_contact") ;
  gr.initialize();
  gr.name = ccn.toString().trim(); 
  gr.title = titlep.toString().trim(); 
  gr.phone = phonep.toString().trim(); 
  gr.email = emailId.toString().trim();
  gr.account = accountSysId;
  gr.insert();
 current.contact=gr.sys_id;
	gs.info("else emailId "+emailId+gr.sys_id);
}

current.description = email.body_text;
current.short_description = email.subject;
current.contact_type = "email";

//put the sysid of the Asignment Group  in system properties and use here
var assignmentGroup = new GlideRecord("sys_properties");
assignmentGroup.addQuery("name", "sn_customerservice.case.assignemnt.group");
assignmentGroup.query();
if (assignmentGroup.next()) {
current.assignment_group = assignmentGroup.value;
}
//To updat the worknote as a table format
current.work_notes = "[code]"+email.body_html+"[/code]";

//To update cc in watch_list
rarray = email.recipients.split(",");
var instanceEmail = gs.getProperty('glide.email.user_Case');
for (var i = rarray.length; i--;) {
    if (rarray[i] === instanceEmail) {
        rarray.splice(i, 1);
    }
}
gs.info("watch list"+rarray.toString());
current.watch_list = rarray.toString();
current.insert();

Note:

If we want to ignore service email id from recipient list, we have to update glide.email.user_Case this properties with the instance email id. inboundaction_040520201 (6).png

For the requirement Case Update: Anyone (who is in CC) can reply to the email for an update to the case.

  1. At first in the 1st inbound action we have added the cc in the watch list.
  2. We need to create another inbound email action. inboundaction_040520201 (7).png inboundaction_040520201 (8).png
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
	
	current.work_notes =email.body_text;
	current.update();
})(current, event, email, logger, classifier);
    Content