Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Setting up autoreply for emails sent to Service-Now mailbox

John_Lee
Kilo Explorer

Hi All

 

Is there a way to setup an autoreply text for emails sent to my organizations Service-Now mailbox, only to respond to emails sent from an internal email address?

 

Is there a way where an inbound email doesn't create a record but still produce an autoreply?

 

Many Thanks.

34 REPLIES 34

Kevin Chung
Giga Guru

Hi John



Short answer to your questions is - yes they are possible.



For the auto-reply, you will probably have to modify your existing inbound script.


If you are using the out-of-the-box inbound scripts, it will probably be "Create Incident" or "Update Incident" Inbound Email Script you'll have to modify.



Basically, in the script, you'll need to add something like below:



if ( email.from.indexOf("@yourcompany.com") > -1 ) // This captures the sender's email address and check if it was sent from an internal email address


{


        //This will fire an event that will create an email notification for auto-reply


        //You will need to register this event.. and associate this with an email notification


        gs.eventQueue("incident.autoreply", current, gs.getUserID(), gs.getUserName());


}



If you'd like to prevent a record to be created, you will have to modify the "current.insert()" or "current.update()" part of the script. The new script will look something like:



if ( email.from.indexOf("@yourcompany.com") > -1 )


{


        //If the email was sent from an internal email address, fire an event for email notification


        gs.eventQueue("incident.autoreply", current, gs.getUserID(), gs.getUserName());


}


else


{


        //If the email wasn't from an internal email address, insert the record


        current.insert()


}



Let me know how you go.



Kevin


Kevin, we have something similar where all our different mailboxes link to different record creations but if someone sends a new email directly to our instance@service-now.com we want a catch-all (after all other inbound actions creating new records fail because of their conditions) that replies back to email.origemail with an error message and a directory of all the proper emails to send to.   I tried having the inbound action trigger an event that fired a notification and passed the email.origemail to it as a parameter but that was troublesome... is there an easier way to just do an autoreply message from inbound actions?



Hello, is there already a solution for this issue. I am also looking to create a autoreply in an inbound action to reply on received mails, but when I look in the event log, the state of the event is on "error".


When I use a business rule, for test, to fire the same event it works fine.


Is there another way to fire an event from incoming emails?



Patrick


Yes, the solution I used was to create another Inbound Email Action with a very high 'Order' with no conditions (so if it fails all the other conditions, it will process this) and for the target table I put: Email (sys_email)


current.type = 'send-ready';


current.recipients = email.origemail;


current.subject = 'This address is unable to create new tickets';


current.body = ''; //HTML-FORMATTED BODY GOES HERE;


//add this back in once we make a mailbox for corp svcs


current.insert();


event.state="stop_processing"; //won't search for any other inbound actions just in case there are some with a higher order than this


So instead of creating a ticket or creating some other record, it creates an outbound email back to the person letting them know not to send things directly to instance@service-now.com and to instead use one of the internal mailboxes you have that are forwarding in certain types of tickets, like facilities@company.com or it-helpdesk@company.com that the conditions figure out what type of ticket to create.