Email ingestion: How to have emails for multiple Departments/Applications get actions appropriately?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 10:18 AM
Greetings Folks.
We are bringing other Business Units into oru ServiceNow instance. Our Facilities dept is going live with the Nuvolo application next week and our e-mail ingestion is still not figured out.
I am trying to figure out A: How to get emails coming into the instance that are intended for the facilities dept.
Then B: How to get that email to generate a Workorder in the Nuvolo application rather than a New Call in the Service Desk application.
Our New Calls are simply emails set to our Help Desk mailbox are also sent to the ServiceNow instance and create new Calls. The inbound email actions for that were fairly straight-forward.
My challenge is how do I get emails sent to the facilities mailbox to come into servicenow and get ingested to the Nuvolo app rather than the Service Desk app?
Nuvolo themselves had crafted an inbound email action but it did not work as they had expected it would...
I can't have the Facilities desk auto-forward the messages to SN because then all the workorders will be from the Facilities desk rather than the person reporting the issue.
Any suggestions on how to make this work?
We also have our HR dept (and then have 9 different mailboxes) and our Finance dept coming onto the instance within the next 2-3 months so I need to find a universal solution...
All advice is appreciated!
Cheers
A.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 02:18 PM
Greetings Trevor
Thank you for the response!
It does help. We are also on O365, and our Help Desk and App Support emails are handled similarly for SN ingestion except we Duplicate send rather than Auto-forward: (any mail coming to this address: ####@blahblahblah.com also send to this address: ###@service-now.com-blah)
I am more used to configuring Inbound Email Rules to handle traffic. I am just unsure how to script this as I am a code Noob.
Cheers
A.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2019 10:06 AM
So now my question becomes: How to script the Inbound Action to have it create the Work Order under the name of the original sender, and not the mailbox it was forwarded from. Can anyone provide an example of that?
Cheers
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2019 10:41 AM
It's all in how you do your mailbox forwarding. I see you're on Office 365 too - here is a screenshot (and I apologize I have no drawing tools on this laptop so it's all free-hand):
Click settings (upper right), go into Forwarding, enable it, then set your SN instance.
Let's pretend joe@gmail.com sends facilities@yourcompany.com an email message. If you enable forwarding as per above (your admin's can do it in the back end too) the message that arrives in ServiceNow will still show joe@gmail.com as the sender and facilities@yourcompany.com as the recipient. Nowhere will it show your ServiceNow email address.
Therefore in your inbound action you can use the code I posted above -
email.direct.toLowerCase()
and
email.copied.toLowerCase()
email.direct is a comma separated list of who it is sent to (so that's why the indexOf) and email.copied is a comma separated list of who it was CCed to.
Here is the email object: https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/notification/reference/r_AccessingEmailObjsWithVars.html
You convert toLowerCase to eliminate the chance that someone used mixed case in sending to you.
Now this helps with the inbound action/forwarding but the other part is linking the request to the guest. You will notice in the email object doc above you can use the following to get the sys_id of the person who sent it: email.from_sys_id
In our environment we actually have multiple email addresses for the same user (very long story that would confuse things) so we wrote our own function in a script include. This was written many years ago (and maybe not even by us) so please don't judge the code too poorly:
getCaller : function(emailaddy) {
var gr = new GlideRecord("sys_user");
gr.addQuery("email",emailaddy);
gr.addQuery("user_name", "DOES NOT CONTAIN", "chat.user");
gr.query();
// IF = multiple users match the email address
if (gr.getRowCount() > 1) {
// We have unique scenarios where multiple
// people have the same email address. It's
// all custom logic and quite long so I'm
// taking it out not the confuse things
}
// ELSE IF = one user matches the email address. Return that user.
else if (gr.getRowCount() == 1) {
gr.next();
return gr.sys_id;
}
// ELSE = a user does not match the email address. Return GUEST
else {
return "sys_id_of_guest_user";
}
},
So our inbound action looks like:
// This is the script include above
var scriptInclude = new CallerFromEmail();
var sid = scriptInclude.getCaller(email.origemail);
if (email.direct.toLowerCase().indexOf('facilities@me.com') != -1 || email.copied.toLowerCase().indexOf('facilities@me.com') != -1) {
var gr = new GlideRecord('incident');
gr.initialize();
gr.u_new_call = current.sys_id;
gr.caller_id = sid;
gr.contact_type = 'email';
gr.u_caller_email = email.origemail;
gr.assignment_group.setDisplayValue('Facilities');
gr.short_description = email.subject;
gr.description = current.description;
gr.u_group_email = 'Facilities <facilities@me.com>';
gr.incident_state = 1;
incId = gr.insert();
var si = new CloneEmail();
si.cloneEmailToINC(current.sys_id, email.uid, incId);
current.state = 3;
}
Does that help? There are always many (and probably better) ways to do it but this is how we have done it for years and never really looked into changing it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2019 12:19 PM
Greetings TrevorK
Yes I think this will help a lot!