NotifyScoped - スコープ指定
NotifyScoped API を使用すると、スクリプトを使用して通知コールおよび SMS メッセージを操作できます。
sn_notify 名前空間から NotifyScoped クラスとそれに関連するメソッドを実行します。
NotifyScoped - call(文字列 notifyPhoneNumber, 文字列 toPhoneNumber, GlideRecord conferenceCall, GlideRecord conferenceCallRecord, 文字列 userSysId, 文字列 groupSysId, GlideRecord sourceRecord)
指定された E.164 準拠の電話番号に電話をかけます。
| 名前 | タイプ | 説明 |
|---|---|---|
| notifyPhoneNumber | 文字列 | 発信元の通知電話番号。コールを開始すると、この番号に関連付けられた番号グループの発信コール ワークフローが実行されます。このワークフローに、ユーザーをカンファレンスに接続するための カンファレンス参加 アクティビティが含まれていることを確認します。 |
| toPhoneNumber | 文字列 | コールする電話番号。着信番号がカンファレンスに追加されます。 |
| カンファレンスコール | GlideRecord | オプション。このパラメーターが渡されると、 toPhoneNumber パラメーターで識別された発信者が、このレコードによって識別されるカンファレンスに自動的に参加します。 カンファレンスレコードを識別する通知コール [notify_call] テーブルの GlideRecord。このレコードは、発信コールワークフロースクラッチパッドにworkflow.scratchpad.conference_call変数として自動的に追加されます。 |
| userSysId | 文字列 | オプション。コールに関連付けられたユーザーの一意の識別子 (sys_id)。 |
| groupSysId | 文字列 | オプション。コールに関連付けられたグループの一意の識別子 (sys_id)。 |
| sourceRecord | GlideRecord | オプション。このコールをプロンプトしたソースレコード。 |
| タイプ | 説明 |
|---|---|
| なし |
この例では、別の電話番号へのコールを開始する方法を示します。
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);
}
NotifyScoped - conferenceCall(GlideRecord sourceRecord)
新しいカンファレンスコール GlideRecord を作成します。
| 名前 | タイプ | 説明 |
|---|---|---|
| sourceRecord | GlideRecord | オプション。カンファレンスコールを作成する要求を開始したレコード。レコードのソースフィールドとテーブルフィールドnotify_conference_call入力するために使用されます。 |
| タイプ | 説明 |
|---|---|
| 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);
}
NotifyScoped - dequeueCall(GlideRecord callRecord)
キューに入れられたコール (保留中) を再開します。
このメソッドを使用して、 queueCall() メソッドでキューに入れられた呼び出しを再開します。
| 名前 | タイプ | 説明 |
|---|---|---|
| コールレコード | GlideRecord | 再開する保留中のコールを含む通知コール [notify_call] テーブルの GlideRecord オブジェクト。 |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、保留になったコールを再アクティブ化する方法を示しています。
var notifyCallGr = new GlideRecord('notify_call');
notifyCallGr.get('active participant sys id');
if (notifyCallGr.isValid) {
sn_notify.NotifyScoped.dequeueCall(notifyCallGr);
}
NotifyScoped - forwardCall(GlideRecord call, String destination, String dtmf)
指定されたコールを別のコール受信者に転送します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 呼び出し | GlideRecord または文字列 | 転送するコールのコールレコードまたはテレフォニープロバイダーコール ID を通知します。 |
| destination | GlideRecord または文字列 | コールの転送先の発信者の電話番号レコードまたは E.164 準拠の電話番号に通知します。 |
| DTMF | 文字列 | デュアルトーン:通話接続時に送信するマルチ周波数 (DTMF) コード。 |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、コールを別の電話番号に転送する方法を示しています。
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)
コールを受信できるクライアントセッションのリストを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 通知番号 | 文字列 | 有効な通知電話番号。 |
| タイプ | 説明 |
|---|---|
| アレイ | 指定された電話番号のnotify_client_sessionテーブルからの GlideRecord。 利用可能なクライアントセッションがない場合は「0」を返します。 |
次の例は、 getAvailableClients() メソッドを使用して notify_client_session テーブルにインデックスを作成し、利用可能なすべての通知クライアントを反復処理する方法を示しています。
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()
通知で利用可能なすべての電話番号と短縮コードを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| アレイ | NotifyPhoneNumber オブジェクトのリスト。各オブジェクトは、通知で利用可能な 1 つの電話番号を表します。 |
この例では、通知電話番号を取得してリストを反復処理する方法を示します。
// 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()
通知で利用可能なすべての短縮コードを返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| なし |
この例では、通知の短縮コードを取得してリストを反復処理する方法を示します。
// 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
}
NotifyScoped - getTokens(GlideRecord, record)
WebRTC またはモバイルクライアントで使用するアクティブな電話ドライバーのクライアントトークンを返します。
この方法では、現在ログインしているユーザーレコードをクライアントとして使用します。
| 名前 | タイプ | 説明 |
|---|---|---|
| レコード | GlideRecord | グループレコードやユーザーレコードなどの通知クライアントを識別するために使用する GlideRecord。 |
| タイプ | 説明 |
|---|---|
| 文字列 | サポートされているドライバーの Web RTC トークン ({driverName1: "token1", driverName2: "token2"} 形式の JSON 文字列として表示されるもの。"TwilioDirect":"eyJhxxxx.eyJleHAiOiIxxxx.7fejxxx_mbLxxx" など) |
この例では、現在ログインしているユーザーのクライアントトークンを取得する方法を示します。
// 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(文字列オーナー)
指定されたテレフォニードライバーに対して、クライアントセッションがアクティブ状態のままになると自動的にタイムアウトするまでの最大時間を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| owner | 文字列 | セッション長を取得する電話ドライバーの名前。 有効な値:
|
| タイプ | 説明 |
|---|---|
| 整数 | セッションの最大長 (秒)。 デフォルト: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(文字列 notifyPhoneNumber, 文字列 capability)
指定された電話番号に指定された機能があるかどうかを判定します。
電話番号に関連付けられた電話ドライバーには、電話のすべての機能のリストが含まれています。
| 名前 | タイプ | 説明 |
|---|---|---|
| notifyPhoneNumber | 文字列 | 指定した機能を確認する電話番号。 |
| capability | 文字列 | 検出する機能。文字列テキストは、電話機の内容と完全に一致する必要があります。 |
| タイプ | 説明 |
|---|---|
| ブーリアン | 指定された電話に指定された機能があるかどうかを示すフラグ。
|
この例では、電話機に特定の機能があるかどうかを確認する方法を示します。
// 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
NotifyScoped - kick(GlideRecord participant)
現在の通知カンファレンスから指定された発信者を削除します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 参加者 | GlideRecord | カンファレンスから削除する発信者の参加者通知 [notify_participant] レコードを含む GlideRecord オブジェクト。 |
| タイプ | 説明 |
|---|---|
| なし |
この例では、通話から参加者を削除する方法を示します。
var participant = new GlideRecord('notify_participant');
participant.get('<sys_id>');
if (participant.isValid()) {
new sn_notify.NotifyScoped().kick(participant);
}
NotifyScoped - modifyCall(GlideRecord callRecord, NotifyAction notifyAction)
アクティブな通知電話で 1 つ以上のアクティビティを実行します。
| 名前 | タイプ | 説明 |
|---|---|---|
| コールレコード | GlideRecord | アクションを適用するコールの通知コール [notify_call] レコード。 |
| 通知アクション | 通知アクション | コールで実行する 1 つ以上のアクティビティを記述する NotifyAction オブジェクト。 |
| タイプ | 説明 |
|---|---|
| なし |
NotifyScoped - mute(GlideRecord participantRecord)
指定されたカンファレンス参加者をミュートします。
| 名前 | タイプ | 説明 |
|---|---|---|
| 参加者レコード | GlideRecord | 参加者がミュートする notify_participant テーブルの GlideRecord。 |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、発信者をミュートする方法を示しています。
var notifyParticipantGr = new GlideRecord('notify_participant');
notifyParticipantGr.get('active participant sys id');
if (notifyParticipantGr.isValid) {
sn_notify.NotifyScoped.mute(notifyParticipantGr);
}
NotifyScoped - queueCall (GlideRecord callRecord)
指定されたコールをキューに入れます (保留中)。
dequeueCall() メソッドを使用して、キューに入れられたコールを再開します。
| 名前 | タイプ | 説明 |
|---|---|---|
| コールレコード | GlideRecord | 保留にする通知コールレコード (notify_callテーブル) の GlideRecord オブジェクト。 |
| タイプ | 説明 |
|---|---|
| なし |
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 source)
指定された通知クライアント (電話番号) の指定されたリストに指定された SMS メッセージを送信します。
| 名前 | タイプ | 説明 |
|---|---|---|
| notifyPhoneNumber | NotifyPhoneNumber | SMS メッセージの送信元の電話番号。 |
| toPhoneNumber | 文字列 | SMS メッセージの送信先のカンマ区切りリスト電話番号。 フォーマット:E.164準拠 |
| メッセージ本文 | 文字列 | 送信する SMS テキスト。 |
| ソース | GlideRecord | インシデントなど、この SMS メッセージを促したソースレコード。 |
| タイプ | 説明 |
|---|---|
| 文字列 | Null |
この例では、複数の電話番号に 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 source)
SMS テキストメッセージを E.164 準拠の電話番号に送信します。
このメソッドは、通知メッセージ [notify_message] テーブルに新しいレコードを作成し、それをソースレコードに関連付けます。
| 名前 | タイプ | 説明 |
|---|---|---|
| notifyPhoneNumber | NotifyPhoneNumber | この SMS メッセージの送信先の通知電話番号または短縮コード。 |
| toPhoneNumber | 文字列 | SMS メッセージの送信先の E.164 準拠の電話番号。 |
| メッセージ本文 | 文字列 | SMS テキストメッセージ。 |
| ソース | GlideRecord | インシデントなど、この SMS メッセージを促したソースレコード。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 一意のメッセージ SID。message_idとして通知メッセージ [notify_message] レコードに保存されます。 |
次の例は、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);
}
NotifyScoped - unmute(GlideRecord participantRecord)
指定されたカンファレンス参加者のミュート状態を解除します。
| 名前 | タイプ | 説明 |
|---|---|---|
| 参加者レコード | GlideRecord | 参加者のミュートを解除する notify_participant テーブルの GlideRecord。 |
| タイプ | 説明 |
|---|---|
| なし |
この例では、指定されたコール参加者のミュートを解除する方法を示します。
var notifyParticipantGr = new GlideRecord('notify_participant');
notifyParticipantGr.get('active participant sys id');
if (notifyParticipantGr.isValid) {
sn_notify.NotifyScoped.unmute(notifyParticipantGr);
}