NotifyScoped - 범위 지정됨

  • 릴리스 버전: Xanadu
  • 업데이트 날짜 2024년 08월 01일
  • 읽기19분
  • NotifyScoped API를 사용하면 스크립트를 사용하여 알림 통화 및 SMS 메시지와 상호 작용할 수 있습니다.

    sn_notify 네임스페이스에서 NotifyScoped 클래스 및 관련 메서드를 실행합니다.

    NotifyScoped - call(String notifyPhoneNumber, String toPhoneNumber, GlideRecord conferenceCall, GlideRecord conferenceCallRecord, string userSysId, string groupSysId, GlideRecord sourceRecord)

    지정된 E.164 호환 전화 번호로 전화를 겁니다.

    표 1. 매개변수
    이름 유형 설명
    알림 전화 번호 문자열 전화를 걸 알림 발신 전화 번호입니다. 통화를 시작하면 이 번호와 연결된 번호 그룹에 대한 발신 통화 워크플로우가 실행됩니다. 이 워크플로우에 사용자를 전화 회의에 연결하는 전화 회의 참가 활동이 포함되어 있는지 확인합니다.
    toPhoneNumber 문자열 발신 대상 전화 번호입니다. 호출된 번호가 전화 회의에 추가됩니다.
    conferenceCall GlideRecord 옵션입니다. 이 매개변수가 전달되면 매개변수에서 toPhoneNumber 식별된 호출자가 이 기록으로 식별된 전화 회의에 자동으로 참가합니다.

    전화 회의 기록을 식별하는 알림 통화 [notify_call] 테이블에 대한 GlideRecord입니다. 이 기록은 발신 콜 워크플로우 스크래치패드에 workflow.scratchpad.conference_call 변수로 자동 추가됩니다.

    userSysId 문자열 옵션입니다. 통화와 관련된 사용자의 sys_id(고유 식별자)입니다.
    groupSysId 문자열 옵션입니다. 호출과 관련된 그룹의 sys_id(고유 식별자)입니다.
    sourceRecord GlideRecord 옵션입니다. 이 호출을 촉발한 소스 기록입니다.
    표 2. 반환
    유형 설명
    void

    이 예에서는 다른 전화 번호로 전화를 거는 방법을 보여 줍니다.

    var from = '+14048007337';
    var to = '+31646810495';
    
    // set up call
    new sn_notify.NotifyScoped().call(from, to);

    이 예제에서는 전화 번호 목록에 대한 통화를 시작하고 해당 번호를 새 전화 회의에 자동으로 참가하는 방법을 보여 줍니다.

    var notify = new sn_notify.NotifyScoped();
    var from = '+14041234567';
    var participants = ['+31612345678', '+31623456789', '+31687654321'];
    
    // set up a conference call
    var conferenceCall = notify.conferenceCall();
    
    // set up the outbound calls for all conference call participants
    for (var i in participants) {
        var to = participants[i];
        notify.call(from, to, conferenceCall);
    }

    알림 범위 지정 - conferenceCall(GlideRecord sourceRecord)

    새 전화 회의 GlideRecord를 생성합니다.

    표 3. 매개변수
    이름 유형 설명
    sourceRecord GlideRecord 옵션입니다. 전화 회의 생성 요청을 시작한 기록입니다. notify_conference_call 기록의 소스 및 테이블 필드를 채우는 데 사용됩니다.
    표 4. 반환
    유형 설명
    GlideRecord 새 알림 전화 회의 [notify_conference_call] 기록.
    var notify = new sn_notify.NotifyScoped();
    var from = '+14041234567';
    var participants = ['+31612345678', '+31623456789', '+31687654321'];
    
    // set up a conference call
    var conferenceCall = notify.conferenceCall();
    
    // set up the outbound calls for all conference call participants
    for (var i in participants) {
        var to = participants[i];
        notify.call(from, to, conferenceCall);
    }

    알림 범위 지정 - dequeueCall(GlideRecord callRecord)

    큐에 넣은 호출을 다시 시작합니다(보류 중).

    이 메서드를 사용하여 queueCall() 메서드로 대기열에 배치된 호출을 다시 시작할 수 있습니다.

    표 5. 매개변수
    이름 유형 설명
    callRecord GlideRecord 다시 시작하려는 보류된 통화가 있는 알림 통화 [notify_call] 테이블의 GlideRecord 객체입니다.
    표 6. 반환
    유형 설명
    void

    다음 예제에서는 보류 중인 통화를 다시 활성화하는 방법을 보여 줍니다.

    var notifyCallGr = new GlideRecord('notify_call');
    notifyCallGr.get('active participant sys id');
     
    if (notifyCallGr.isValid) {
        sn_notify.NotifyScoped.dequeueCall(notifyCallGr);
    }

    알림 범위 지정 - forwardCall(GlideRecord 호출, 문자열 대상, 문자열 dtmf)

    지정된 통화를 다른 통화 수신자에게 전달합니다.

    표 7. 매개변수
    이름 유형 설명
    외침 GlideRecord 또는 String 착신 전환할 통화의 알림 통화 기록 또는 전화 통신 제공자 통화 ID입니다.
    목적지 GlideRecord 또는 String 통화를 착신 전환할 호출자의 전화 번호 기록 또는 E.164 호환 전화 번호를 알립니다.
    디엠프(DTMF) 문자열 이중 신호음 - 통화 연결 시 전송할 DTMF(다중 주파수) 코드입니다.
    표 8. 반환
    유형 설명
    void

    다음 예제에서는 다른 전화 번호로 통화를 착신 전환하는 방법을 보여 줍니다.

    var callID = 'CA92374b5aa561dab476a7001db6026edc'; // Twilio Call ID
    var phoneNumber = '+91406xxxxxxx';
    var dtmfTones = null;
     
    var notifyCallGr = new GlideRecord('notify_call');
    notifyCallGr.get('active participant sys id');
     
    if (notifyCallGr.isValid) {
        sn_notify.NotifyScoped.forwardCall(notifyCallGr(or) callID, phoneNumber, dtmfTones)
    }

    NotifyScoped - getAvailableClients(문자열 notifyNumber)

    호출을 받을 수 있는 클라이언트 세션 목록을 반환합니다.

    표 9. 매개변수
    이름 유형 설명
    알림 번호 문자열 올바른 알림 전화 번호입니다.
    표 10. 반환
    유형 설명
    배열 지정된 전화 번호에 대한 notify_client_session 테이블의 GlideRecord입니다.

    사용 가능한 클라이언트 세션이 없는 경우 "0"을 반환합니다.

    다음 예제에서는 getAvailableClients() 메서드를 사용하여 notify_client_session 테이블로 인덱싱한 다음 사용 가능한 모든 Notify 클라이언트에서 반복하는 방법을 보여줍니다.

    var clientSessionGr = sn_notify.NotifyScoped.getAvailableClients('+185xxxxxxxx'); 
    // Here clientSessionGr is of type GlideRecord on 'notify_client_session' table.
     
    var isLoggedInUserAvailable = false;
    while (clientSessionGr.next()) {
      if (clientSessionGr.user == gs.getUserID())
        isLoggedInUserAvailable = clientSessionGr.available;
    }
    gs.info('isLoggedInUserAvailable - ' + isLoggedInUserAvailable);

    NotifyScoped - getPhoneNumbers()

    알림에 사용할 수 있는 모든 전화 번호와 짧은 코드를 반환합니다.

    표 11. 매개변수
    이름 유형 설명
    없음
    표 12. 반환
    유형 설명
    배열 NotifyPhoneNumber 개체의 목록으로, 각 개체는 알림에 사용할 수 있는 하나의 전화 번호를 나타냅니다.

    이 예제에서는 알림 전화 번호를 가져온 다음 목록을 반복하는 방법을 보여 줍니다.

    // Instantiate notify
    var notify = new sn_notify.NotifyScoped();
    
    // Retrieve all available phone numbers
    var phoneNumbers = notify.getPhoneNumbers();
    
    // Iterate over phone numbers
    for (var i = 0; i < phoneNumbers.length; i++) {
      var number = phoneNumbers[i];
    
      // Perform any actions using each phone number
    
    }

    NotifyScoped - getShortCodes()

    알림에 사용할 수 있는 모든 약식 코드를 반환합니다.

    표 13. 매개변수
    이름 유형 설명
    없음
    표 14. 반환
    유형 설명
    void

    이 예제에서는 알림 약식 코드를 가져온 다음 목록을 반복하는 방법을 보여 줍니다.

    // Instantiate notify
    var notify = new sn_notify.NotifyScoped();
    
    // Retrieve all available shortcodes
    var shortCodes = notify.getShortCodes();
    
    // Iterate over phone numbers
    for (var i = 0; i < shortCodes.length; i++) {
      var shortCode = shortCodes[i];
      gs.log(shortCode.getNumber());
    
    //perform any actions using each shortcode
    
    }

    알림 범위 지정 - getTokens(GlideRecord, record)

    WebRTC 또는 모바일 클라이언트에서 사용할 활성 전화 통신 드라이버에 대한 클라이언트 토큰을 반환합니다.

    이 메서드는 현재 로그인한 사용자 기록을 클라이언트로 사용합니다.

    표 15. 매개변수
    이름 유형 설명
    기록 GlideRecord 그룹 기록 또는 사용자 기록과 같은 알림 클라이언트를 식별하는 데 사용하는 GlideRecord입니다.
    표 16. 반환
    유형 설명
    문자열 지원되는 드라이버에 대한 웹 RTC 토큰({driverName1: "token1", driverName2: "token2"}, 예: "TwilioDirect":"eyJhxxxx.eyJleHAiOiIxxxx.7fejxxx_mbLxxx" 형식의 JSON 문자열)

    이 예제에서는 현재 로그인한 사용자에 대한 클라이언트 토큰을 가져오는 방법을 보여 줍니다.

    // get Notify client Tokens per active Notify driver for the currently logged in user
    var json = new sn_notify.NotifyScoped().getTokens();
     
    // Parse the JSON that was return into a tokens object
    var tokens = JSON.parse(json);
    
    // Log line
    gs.log('Notify client tokens for the currently logged in user');
    
     // iterate over the driver tokens
    for (var driver in tokens) {
     	gs.log(driver + ' Driver token: ' + tokens[driver]);
    }

    이 예시에서는 모든 알림 그룹에 대한 클라이언트 토큰을 가져오는 방법을 보여줍니다.

    // instantiate Notify
    var notify = new sn_notify.NotifyScoped.Notify();
     
    // get all Notify Groups
    var notifyGroup = new GlideRecord("notify_group");
    notifyGroup.query();
     
    // iterate over all notify groups
    while (notifyGroup.next()) {
      // generate Notify Client tokens per active Notify Driver for this group
      var json = notify.getTokens(notifyGroup);
      var tokens = JSON.parse(json);
     
      for (var driver in tokens) {
        gs.log(gs.getMessage("Notify Client token for {0} driver and Notify Group '{1}': {2}", [driver, notifyGroup.getValue('name'), tokens[driver]]));
      }
    }

    이 예제에서는 활성 전화 통신 드라이버에 대한 클라이언트 토큰을 가져오는 방법을 보여 줍니다.

    var notify = new sn_notify.NotifyScoped();
    var now_GR = new GlideRecord('sys_user');
    if (now_GR.get(gs.getUserID())) {
      gs.info(notify.getTokens(now_GR));
    }

    출력:

    {"TwilioDirect":"eyJhxxxx.eyJleHAiOiIxxxx.7fejxxx_mbLxxx"}

    NotifyScoped - getTokenTTL(문자열 소유자)

    클라이언트 세션이 자동으로 시간 초과되기 전에 지정된 전화 통신 드라이버에 대해 활성 상태로 유지되는 최대 시간을 반환합니다.

    표 17. 매개변수
    이름 유형 설명
    소유자 문자열 세션 길이를 검색할 전화 통신 드라이버의 이름입니다.

    유효한 값은 다음과 같습니다.

    • Twilio: 이전 드라이버용
    • TwilioDirect: 새 드라이버용
    표 18. 반환
    유형 설명
    정수 세션의 최대 길이(초)입니다.

    기본값: 1800초

    다음 예제에서는 이 메서드와 관련 응답을 올바르게 호출하는 방법을 보여 줍니다. 또한 잘못된 드라이버가 전달될 경우 반환되는 내용도 표시됩니다.

    var owner = "TwilioDirect";  // Valid driver
    var ttl = SNC.Notify.getTokenTTL(owner);
    gs.info("Token TTL for " + owner + " --> " + ttl);
     
    owner = "Abcxyz";  // Invalid driver
    ttl = SNC.Notify.getTokenTTL(owner);
    // For an invalid driver, we throw NoSuchNotifyDriverException saying that Abcxyzdriver is not available
    // and return the default value of TTL
    gs.info("Token TTL for " + owner + " --> " + ttl); 

    NotifyScoped - hasCapability(String notifyPhoneNumber, String capability)

    지정된 전화 번호에 지정된 기능이 있는지 여부를 확인합니다.

    전화 번호와 연결된 전화 통신 드라이버에는 휴대폰의 모든 기능 목록이 포함되어 있습니다.

    주:
    기본 시스템에서 Notify JS 드라이버에는 'show_speakers'만 기능으로 있습니다. 이는 수정할 수 있습니다.
    표 19. 매개변수
    이름 유형 설명
    알림 전화 번호 문자열 지정된 역량을 확인할 전화 번호입니다.
    역량 문자열 탐지 능력. 문자열 텍스트는 전화기에 있는 텍스트와 정확히 일치해야 합니다.
    표 20. 반환
    유형 설명
    부울 지정된 전화기에 지정된 기능이 있는지 여부를 나타내는 플래그입니다.
    • true: 전화기에 기능이 있음
    • false: 전화기에 기능이 없습니다.

    이 예에서는 전화기에 특정 기능이 있는지 확인하는 방법을 보여줍니다.

    // Each driver has a defined set of capabilities.
    
    var capability = 'show_speakers';
    gs.info(sn_notify.NotifyScoped.hasCapability('+185xxxxxxxx', capability)); // true
     
    capability = 'send_sms';
    gs.info(sn_notify.NotifyScoped.hasCapability('+185xxxxxxxx', capability)); // false

    알림 범위 지정 - kick(GlideRecord 참가자)

    현재 알림 전화 회의에서 지정된 호출자를 제거합니다.

    표 21. 매개변수
    이름 유형 설명
    참가자 GlideRecord 전화 회의에서 제거할 호출자의 알림 참가자 [notify_participant] 기록을 포함하는 GlideRecord 객체입니다.
    표 22. 반환
    유형 설명
    void

    이 예에서는 통화에서 참가자를 제거하는 방법을 보여줍니다.

    var participant = new GlideRecord('notify_participant');
    participant.get('<sys_id>');
    if (participant.isValid()) {
        new sn_notify.NotifyScoped().kick(participant);
    }

    알림 범위 지정 - modifyCall(GlideRecord, callRecord, NotifyAction, notifyAction)

    활성 알림 전화 통화에 대해 하나 이상의 활동을 수행합니다.

    이 메서드를 사용하여 호출 동작을 변경할 수 있습니다. 예를 들어 통화 전환, 오디오 재생 또는 강제 끊기 등이 있습니다.
    주:
    이 메서드의 범위가 지정된 구현은 사용자 지정 알림 활동만 지원합니다. 전역 구현과 달리 NotifyAction API를 제공하지 않습니다. 사용자 지정 알림 활동을 만드는 방법에 대한 자세한 내용은 알림 워크플로우 활동을 참조하십시오.
    표 23. 매개변수
    이름 유형 설명
    callRecord GlideRecord 작업을 적용할 호출의 알림 [notify_call] 기록입니다.
    알림 작업 알림 작업 호출 시 수행할 하나 이상의 활동을 설명하는 NotifyAction 개체입니다.
    표 24. 반환
    유형 설명
    void

    알림 범위 지정 - 음소거(GlideRecord participantRecord)

    지정된 컨퍼런스 회의 참가자를 음소거합니다.

    표 25. 매개변수
    이름 유형 설명
    participantRecord GlideRecord 참가자가 음소거할 notify_participant 테이블의 GlideRecord입니다.
    표 26. 반환
    유형 설명
    void

    다음 예제에서는 호출자를 음소거하는 방법을 보여 줍니다.

    var notifyParticipantGr = new GlideRecord('notify_participant');
    notifyParticipantGr.get('active participant sys id');
     
    if (notifyParticipantGr.isValid) {
        sn_notify.NotifyScoped.mute(notifyParticipantGr);
    }

    알림 범위 지정 - queueCall(GlideRecord callRecord)

    지정된 호출을 큐에 넣습니다(보류 중).

    dequeueCall() 메서드를 사용하여 대기 중인 호출을 다시 시작합니다.

    표 27. 매개변수
    이름 유형 설명
    callRecord GlideRecord 보류할 알림 통화 기록(notify_call 테이블)의 GlideRecord 객체입니다.
    표 28. 반환
    유형 설명
    void
    var call = new GlideRecord('notify_call');
    call.get('<call record sys_id>');
    if (call.isValid()) {
        new sn_notify.NotifyScoped().queueCall(call);
    }

    NotifyScoped - sendBulkSMS(NotifyPhoneNumber, notifyPhoneNumber, String toPhoneNumbers, String messageBody, GlideRecord 소스)

    지정된 알림 클라이언트(전화 번호) 목록에 지정된 SMS 메시지를 보냅니다.

    표 29. 매개변수
    이름 유형 설명
    알림 전화 번호 알림 전화 번호 SMS 메시지가 전송되는 전화 번호입니다.
    toPhoneNumbers 문자열 SMS 메시지를 보낼 쉼표로 구분된 목록 전화 번호입니다.

    형식: E.164 호환

    메시지 본문 문자열 보낼 SMS 텍스트입니다.
    소스 GlideRecord 인시던트와 같이 이 SMS 메시지를 표시한 소스 기록입니다.
    표 30. 반환
    유형 설명
    문자열

    이 예에서는 SMS 메시지를 여러 전화 번호로 보내는 방법(대량 SMS)을 보여줍니다.

    var incidentGr = new GlideRecord('incident');
    incidentGr.get('active incident sys_id');
    if (incidentGr.isValid()) {
        sn_notify.NotifyScoped.sendBulkSMS('+15413970605', ['+919885XXXXXX', '+919775XXXXXX'], 'Test automation message', incidentGr);
    }

    NotifyScoped - sendSMS(NotifyPhoneNumber, notifyPhoneNumber, String toPhoneNumber, String messageBody, GlideRecord 소스)

    E.164와 호환되는 전화 번호로 SMS 텍스트 메시지를 보냅니다.

    이 메서드는 알림 메시지 [notify_message] 테이블에 새 기록을 만들고 원본 기록과 연결합니다.

    표 31. 매개변수
    이름 유형 설명
    알림 전화 번호 알림 전화 번호 이 SMS 메시지를 보낼 전화 번호 또는 짧은 코드를 알립니다.
    toPhoneNumber 문자열 SMS 메시지를 보낼 E.164 호환 전화 번호입니다.
    메시지 본문 문자열 SMS 문자 메시지.
    소스 GlideRecord 인시던트와 같이 이 SMS 메시지를 표시한 소스 기록입니다.
    표 32. 반환
    유형 설명
    문자열 고유 메시지 SID입니다. 알림 메시지 [notify_message] 기록에 message_id로 저장됩니다.

    다음 예제에서는 SMS 메시지를 보내는 방법을 보여 줍니다.

    var incidentGr = new GlideRecord('incident');
    incidentGr.get('active incident sys_id');
    if (incidentGr.isValid()) {
        sn_notify.NotifyScoped.sendSMS('+15413970605', '+919885XXXXXX', 'Test automation message', incidentGr);
    }

    알림 범위 지정 - 음소거 해제(GlideRecord participantRecord)

    지정된 컨퍼런스 회의 참가자의 음소거를 해제합니다.

    표 33. 매개변수
    이름 유형 설명
    participantRecord GlideRecord 참가자가 음소거를 해제할 notify_participant 테이블의 GlideRecord입니다.
    표 34. 반환
    유형 설명
    void

    이 예에서는 지정된 통화 참가자의 음소거를 해제하는 방법을 보여줍니다.

    var notifyParticipantGr = new GlideRecord('notify_participant');
    notifyParticipantGr.get('active participant sys id');
     
    if (notifyParticipantGr.isValid) {
        sn_notify.NotifyScoped.unmute(notifyParticipantGr);
    }