How to send SMS to assignment group members when an incident is created

ss52
Tera Contributor

Hi All,

 

Greetings!!

 

We have enabled Twilio Spoke plugin to send SMS to assigned to and assignment group members when an incident is created.

 

I achieved this for assigned to easily by using send SMS action which is available OOB as part of Twilio Spoke plugin. Now i want to send SMS to assignment group members of incident record dynamically.

 

Kindly provide me some insights to achieve this requirement.

 

Plugin Enabled for Twilio:

 

Twilio Spoke(App id: sn_twilio_spoke)

 

 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@ss52 

are you accessing the correct script include and from correct scope?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

ss52
Tera Contributor

Hi All,

I am using notify API's which is mentioned in docs and send SMS to assignment group members of incident whenever priority incident is created.

Business Rule:

(function executeRule(current, previous /*null when async*/ ) {
   gs.info("twilio inside");
    var twilio = '+'; // This is twilio trial account number which I am using and passing as a parameter in sendSMS method. Removed for security reasons

    var group = current.assignment_group;

    gs.info("twilio" + group);

    var gr1 = new GlideRecord('sys_user_grmember');
    gr1.addQuery('group', "=", group);
    gr1.query();   

    while (gr1.next()) {

        gs.info("twilio inside while ");       

        var userPhone = gr1.getDisplayValue('user.phone');
        gs.info("twilio userphone " + userPhone);
        strMessage = "This is a test";

        // Call Notify API to send the actual text

        if (userPhone) {

            gs.info("twilio inside if userphone ");

            SNC.Notify.sendSMS(twilio, userPhone, strMessage, current);

            gs.info("twilio reached end ");

        }

    }

})(current, previous);

 

Docs link: https://developer.servicenow.com/dev.do#!/reference/api/yokohama/server_legacy/c_NotifyAPI#r_N-sendS...

 

I can see logs are coming till the end but no SMS is getting triggered.