The openFrameAPI provides methods that interact with OpenFrame. OpenFrame is an omni-present frame that communication partners can use to integrate their systems into the ServiceNow platform.

One of the core requirements is the ability to connect and serve code from different domains that can connect seamlessly with partner subsystems. This cross domain connection is required to keep connections and callbacks registered into communication systems without any cross domain issues.

OpenFrame has two significant parts. One lives in the ServiceNow application (referred to as TopFrame) and this API that is sourced from the partner application. This API has the necessary methods to communicate with TopFrame and control the visual features of the OpenFrame.
Note: To stay current with reference to the OpenFrame library, use the following resource URI: https://[servicenow instance]/scripts/openframe/latest/openFrameAPI.min.js.

openFrameAPI - getAWAAgentPresence(String success, String failure)

Returns the logged in agent’s current presence state.

Table 1. Parameters
Name Type Description
success String If the method is successful, name of the callback function to invoke.
failure String If the method fails, name of the callback function to invoke.

Example

The following code example shows how to call this method.

function failure(data)
{
  console.log("failure: " + JSON.stringify(data));
}
 
function success(data)
{
  console.log("success: " + JSON.stringify(data));
}
 
openFrameAPI.getAWAAgentPresence(success, failure)

Response to success callback function:

success: { 
  "presence": { 
    "name": "Available", 
    "sys_id": "0b10223c57a313005baaaa65ef94f970", 
    "available": true, 
    "channels": [ 
      { 
        "name": "Chat", 
        "available": true, 
        "sys_id": "27f675e3739713004a905ee515f6a7c3", 
        "restrict_update": false, 
        "service_channel_type": "chat" 
      } 
    ] 
  } 
}

openFrameAPI - hide()

Hides the OpenFrame in the TopFrame.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
void

Example

openFrameAPI.hide()

openFrameAPI - init(Object config, function successCallback, function failureCallback)

Initializes OpenFrame. This must be the first method that you call.

This method initializes communication to TopFrame and initializes any visual elements passed in the config parameter.

Table 5. Parameters
Name Type Description
config Object Name-value pairs to use during the initialization process.
Possible keys:
  • height
  • subTitle
  • title
  • titleIcon
  • width
All keys are optional. Pass an empty object if you don't want to set these key-value pairs.
successCallback function Name of the callback function to use if the init method succeeds. The OpenFrame configuration stored in the system is passed as a parameter to the callback function.
failureCallback function Name of the callback function to use if the init method fails.
Table 6. Returns
Type Description
void

Example

var config = {
height: 300,
width: 200
}
function handleCommunicationEvent(context) {
console.log("Communication from Topframe", context);
}
function initSuccess(snConfig) {
console.log("openframe configuration", snConfig);
//register for communication event from TopFrame
openFrameAPI.subscribe(openFrameAPI.EVENTS.COMMUNICATION_EVENT,
handleCommunicationEvent);
}
function initFailure(error) {
console.log("OpenFrame init failed...", error);
}
openFrameAPI.init(config, initSuccess, initFailure);

openFrameAPI - isVisible(function callback)

Checks to see if the OpenFrame is visible in the TopFrame.

Table 7. Parameters
Name Type Description
callback function The callback function receives a parameter with a value of true or false. True if OpenFrame is visible and false if not visible.
Table 8. Returns
Type Description
void

Example

function callback(isVisible) {
console.log(isVisible)
}
openFrameAPI.isVisible(callback)

openFrameAPI - openCustomURL(String details)

Opens a custom URL in the UI16 interface.

Table 9. Parameters
Name Type Description
Url String Text of the custom URL.

Maximum size: 2083 characters

Table 10. Returns
Type Description
void

Example

openFrameAPI.openCustomURL('10_cool_things.do');

openFrameAPI - openServiceNowForm(Object details)

Opens a form URL.

When an agent receives an incoming call, the OpenFrame window displays information such as the account, contact, or consumer. Clicking a link in the OpenFrame window displays the corresponding record.
  • In the platform interface, this API opens a form URL in TopFrame.
  • For Agent Workspace, this API supports interaction tab management. In Agent Workspace, an interaction record opens in a parent tab and the specified entity record opens in a child tab under the interaction tab.
Table 12. Returns
Type Description
void

Example

The following example shows basic usage in platform:

openFrameAPI.openServiceNowForm({entity:'customer_account', 
query:'sys_id=447832786f0331003b3c498f5d3ee452', 'interaction_sys_id':'3be092313b711300758ce9b534efc4dd'});

Example

The following example shows how to use the query parameter to create a new record with data provided in the form by using sysparm_query and an encoded query to populate the first and last name fields in Workspace:

openFrameAPI.openServiceNowForm({ entity: 'sys_user',
query: 'sys_id=-1&sysparm_query=first_name=Ivan^last_name=Greggor' });

openFrameAPI - openServiceNowFormwithChildTab()

Opens a ServiceNow form with a child tab if invoked in a workspace or opens an entity if invoked in the UI16 interface.

Table 14. Returns
Type Description
None

Example

The following example opens the parent entity as a parent tab on a configured workspace, or opens just the entity if invoked in UI16.

openFrameAPI.openServiceNowFormwithChildTab({
  entity: "customer_account", 
  sys_id: "447832786f0331003b3c498f5d3ee452", 	
  parent_entity: "interaction", 
  parent_entity_sys_id: "3be092313b711300758ce9b534efc4dd"
});

openFrameAPI - openServiceNowList(Object details)

Opens a list URL in the UI16 interface.

Table 15. Parameters
Name Type Description
details Object Key value pairs that describe the content to use when opening the list URL.

Valid values:

Table 16. Returns
Type Description
void

Example

openFrameAPI.openServiceNowList({entity:'case', query:'active=true'});

openFrameAPI - setFrameMode(mode)

Sets the OpenFrame mode.

The mode passed in this API:
  • Sets the appropriate icon in the header: collapse or expand
  • Raises the relevant event for CTI:
    • openFrameAPI.EVENTS.COLLAPSE
    • openFrameAPI.EVENTS.EXPAND
Table 17. Parameters
Name Type Description
Mode String Set OpenFrame Mode. Enumerated options:
  1. openFrameAPI.FRAME_MODE.COLLAPSE
  2. openFrameAPI.FRAME_MODE.EXPAND
Table 18. Returns
Type Description
void

Example

openFrameAPI.setFrameMode(openFrameAPI.FRAME_MODE.COLLAPSE);

openFrameAPI - setHeight(height)

Sets the OpenFrame height.

Table 19. Parameters
Name Type Description
Height Number Height in pixels
Table 20. Returns
Type Description
void

Example

openFrameAPI.setHeight(100);

openFrameAPI - setICContext(String Type, Object <Context>)

Sets the context data related to the interaction controls on the client. Use this context data to determine the client UI to display in OpenFrame.

For additional information on interactive controls, see Interaction Controls Component.

For additional information on interaction records, see CSM voice interaction record page.

Table 22. Returns
Type Description
None

Example

The following code example shows how to set the active state context.

openFrameAPI.setICContext("activeCall", {
  "activeCall": [
    { 
      "nowRecordTable": "interaction",
      "nowRecordId": "12345675678903456",
      "externalId": "1234567890",
      "type": "call",
      "direction": "inbound",
      "currentParticipant": {
        "id": "participant1",
        "name": "John 1",
        "actor": "agent",
        "state": "connected",
        "connectedTime": "Fri, 12 Jul 2024 05:23:41 GMT",
        "callStartTime": "Fri, 12 Jul 2024 04:20:22 GMT",
        "muted": false,
        "held": true,
        "paused": true,
        "flagged": true,
        "recording": "in_progress",
        "capabilities": {
          "hold": false,
          "mute": true,
          "endCall": true,
          "startRecording": true,
          "pauseRecording": true,
          "stopRecording": true,
          "resumeRecording": true,
          "transfer": true,
          "mergeCall": true,
          "leaveAndTransfer": true,
          "dtmf": true,
          "flag": true
        }
      },
      "participants": [
        {
          "id": "customer1",
          "name": "Gilly 1",
          "actor": "customer",
          "address": "+18582359874",
          "ani": "+16193287356", 
          "dnis": "+18004346258",
          "state": "connected",
          "connectedTime": "Fri, 12 Jul 2024 00:23:41 GMT",
          "callStartTime": "Fri, 12 Jul 2024 20:55:04 GMT",
          "muted": false,
          "held": false,
          "heldAtTime": "Fri, 12 Jul 2024 20:55:04 GMT", 
          "capabilities": {
            "mute": true,
            "hold": true,
            "endCall": true
          }
        },
        {
          "id": "agent2",
          "name": "Ned",
          "actor": "agent",
          "address": "+3134787324",
          "ani": "+13134787324", 
          "dnis": "+14773286943",
          "state": "Ringing...",
          "requireWrapup": true,
          "requestACW": true,
          "connectedTime": "Fri, 12 Jul 2024 20:24:41 GMT",
          "callStartTime": "Fri, 12 Jul 2024 20:56:34 GMT",
          "muted": true,
          "held": true,
          "heldAtTime": "Fri, 12 Jul 2024 20:55:41 GMT",
          "capabilities": {
            "mute": true,
            "endCall": true,
            "hold": true 
          }
        }
      ]
    },
    {
      "nowRecordTable": "interaction",
      "nowRecordId": "12345yhedfh534576u5",
      "externalId": "1234567890",
      "type": "call",
      "direction": "inbound",
      "currentParticipant": {
        "id": "participant1",
        "name": "John 1",
        "actor": "agent",
        "state": "connected",
        "muted": true,
        "held": false,
        "recording": "in_progress",
        "paused": true,
        "flagged": true,
        "capabilities": {
          "hold": false,
          "mute": true,
          "endCall": true,
          "record": true,
          "startRecording": true,
          "stopRecording": true,
          "transfer": true,
          },
          "mergeCall": false,
          "dtmf": true,
          "flag": true
        }
      },
      "participants": [
        {
          "id": "customer1",
          "name": "Gilly 2",
          "actor": "customer",
          "address": "+123456789",
          "state": "connected",
          "connectedTime": "Wed, 04 Dec 2024 00:23:41 GMT",
          "muted": true,
          "held": false,
          "heldAtTime": "Fri, 12 Jul 2024 20:24:41 GMT”,
          "capabilities": {
            "mute": true,
            "hold": true,
            "endCall": true
          }
        },
        {
          "id": "agent2",
          "name": "Ned 2",
          "actor": "agent",
          "address": "+123456789",
          "state": "Ringing...",
          "connectedTime": "Fri, 12 Jul 2024 20:24:41 GMT",
          "muted": true,
          "held": true,
          "heldaAtTime": "Fri, 12 Jul 2024 20:24:41 GMT”,
          "capabilities": {
            "mute": true,
            "endCall": true,
            "hold": true
          }
        }
      ]
     }
    ]
  }
);

Example

The following example shows how to set the idle state context.

openFrameAPI.setICContext("idleState", {
  "capability": {
    "outBoundCall": true,
    "logOut": true 
  },
  "enableState": {
    "outBoundCall": true,
    "logOut": true
  },
  "dialpadInfoMessage": {
    "label": "Info Message Label",
    "value": "Info Message Value"
  },
  "currentInboundId": "1234"
});

Example

The following example shows how to set the search target list context.

openFrameAPI.setICContext("searchTargetList",
  {
    "searchTargetList": [
      {
        "nowRecordTable": "interaction",
        "nowRecordId": "1234",
        "externalId": "5678",
        "participantID": "participant1",
        "targets": [
          {
            "type": "agent",
            "transferSubtypes": [
              {
                "id": "consult",
                "label": "Consult"
              },
              {
                "id": "blind",
                "label": "Blind"
              }
            ],
            "payload": {
              "list": [
                {
                  "name": "John Jason",
                  "id": "agent1Id",
                  "hasStats": "true",
                  "presence": "away",
                  "moreInfo": [
                    {
                      "label": "Skill",
                      "value": "10sec"
                    }
                  ]
                }
              ]
            }
          },
          {
            "type": "queue",
            "transferSubtypes": [
              {
                "id": "consult",
                "label": "Consult"
              },
              {
                "id": "blind",
                "label": "Blind"
              }
            ],
            "payload": {
              "list": [
                {
                  "name": "Product Support Queue",
                  "id": "queue1Id",
                  "hasStats": "true",
                  "moreInfo": [
                    {
                      "label": "Skill",
                      "value": "10sec"
                    },
                    {
                      "label": "Queue Skill",
                      "value": "German"
                    }
                  ]
                },
                {
                  "name": "Billing Queue",
                  "id": "queue2Id",
                  "hasStats": "true",
                  "moreInfo": [
                    {
                      "label": "Skill",
                      "value": "10sec"
                    }
                  ]
                }
              ]
            }
          }
        ],
        "customPayload": {}
      }
    ],
    "customPayload": {}
  });

openFrameAPI - setIcons(Array icons)

Defines icons in the OpenFrame header that are placed next to the close icon.

Table 23. Parameters
Name Type Description
icons Array of objects A list of icon configurations, where each icon configuration is an object with key values imageURL, imageTitle, and any other needed context.

Maximum size: Icons can be a maximum of 16x16 pixels. Larger images are automatically adjusted to this maximum.

Table 24. Returns
Type Description
void

Example

openFrameAPI.setIcons([{imageURL:'https://mydomian.com/image/mute.png',
imageTitle:'mute', id:101}, {imageURL:'https://mydomian.com/image/hold.png',
imageTitle:'hold', id:102}]);

openFrameAPI - setPresenceIndicator(presence)

Sets the presence indicator to display agent availability in a workspace.

For more information on configuring OpenFrame, refer to Create an OpenFrame configuration

Table 25. Parameters
Name Type Description
state String Presence state of the agent.

Default states:

  • Available
  • Away
  • Offline

You can also specify custom states.

color String Presence indicator color on workspace.

Supported colors:

  • red
  • orange
  • grey
  • green
Table 26. Returns
Type Description
void

Example

openframeAPI.setPresenceIndicator('Available', 'green');

openFrameAPI - setSize(Number width, Number height)

Sets the OpenFrame size.

Table 27. Parameters
Name Type Description
width Number Should be greater than zero.
height Number Should be greater than zero.
Table 28. Returns
Type Description
void

Example

openFrameAPI.setSize(300, 370);

openFrameAPI - setSubtitle(String subTitle)

Sets the OpenFrame subtitle.

Table 29. Parameters
Name Type Description
subTitle String A string of 256 or fewer characters.
Table 30. Returns
Type Description
void

Example

openFrameAPI.setSubtitle('+18888888888');

openFrameAPI - setTitle(String title)

Sets the OpenFrame title.

Table 31. Parameters
Name Type Description
title String A string of 256 or fewer characters.
Table 32. Returns
Type Description
void

Example

openFrameAPI.setTitle('Incoming Call');

openFrameAPI - setTitleIcon(Object icon)

Sets the OpenFrame's title icon.

Table 33. Parameters
Name Type Description
icon Object Object of key value pairs. Keys include imageURL, imageTitle, and any other context needed.

Maximum size: Icons can be a maximum of 16x16 pixels. Larger images are automatically adjusted to this maximum.

Table 34. Returns
Type Description
void

Example

openFrameAPI.setTitleIcon({imageURL:'/my/image/path.png', imageTitle:'mute', id:101});

Example

openFrameAPI.setTitleIcon({imageURL:'https://mydomian.com/image/path.png',
imageTitle:'mute', id:101});

openFrameAPI - setWidth(width)

Sets the OpenFrame width.

Table 35. Parameters
Name Type Description
Width Number Width in pixels
Table 36. Returns
Type Description
void

Example

openFrameAPI.setWidth(100);

openFrameAPI - show()

Makes the OpenFrame visible in the TopFrame.

Table 37. Parameters
Name Type Description
None
Table 38. Returns
Type Description
void

Example

openFrameAPI.show()

openFrameAPI - subscribe(openFrameAPIEVENT event, function eventCallback)

Subscribes to a specified event.

Table 39. Parameters
Name Type Description
event openFrameAPIEVENT The event to subscribe to:
  • openframe_agent_off_interaction: Indicates the presence of an agent on chat as off or available.
  • openframe_awa_agent_presence: In Advanced Work Assignment (AWA), this event occurs when there's any change in the agent presence state. Computer Telephony Integration (CTI) developers can subscribe to this event to receive presence state changes.
  • openframe_awa_workitem_accepted: Occurs when a work item is accepted by an agent.
  • openframe_awa_workitem_offered: Occurs when a work item is offered to an agent.
  • openframe_awa_workitem_rejected: Occurs when a work item is rejected by an agent.
  • openframe_before_destroy: Occurs before the TopFrame is unloaded.
  • openframe_collapse: Occurs when the collapse icon is selected on the OpenFrame header.
  • openframe_communication: Application-specific and can be customized.
  • openframe_communication_failure: Occurs when communication to TopFrame fails.
  • openframe_expand: Occurs when the expand icon is selected on the OpenFrame header.
  • openframe_heart_beat: Occurs when the user session is extended or logged out.
  • openframe_header_icon_clicked: Deprecated. Use openframe_icon_clicked or openframe_title_icon_clicked instead.
  • openframe_hidden: Occurs when the OpenFrame is hidden.
  • openframe_icon_clicked: Occurs when any icon other than the close icon is selected on the OpenFrame footer. The callback receives the icon object as a parameter.
  • openframe_shown: Occurs when the OpenFrame is shown.
  • openframe_title_icon_clicked: Occurs when the title icon is selected on the OpenFrame. The callback receives the titleIcon object as a parameter.
  • openframe_wrap_up_submitted: Occurs when the wrap up periods ends on the wrap-up modeless dialog. The event is triggered only when the wrap up is external.
eventCallback function Function to call when the specified event occurs.

Example

The following code example shows how to call this method for an openframe_awa_agent_presence event.

function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_agent_presence, handleIconClick);

Output:

// Sample presence object output
// openframe_awa_agent_presence event only

{
  "result":{
    "presence":{
      "name":"Available",
      "sys_id":"27f675e3739713004a905ee515f6a7c3",
      "available":true,
      "channels":[
        {
          "name":"Chat",
          "available":true,
          "sys_id":"36f675e4239713124a905fe515f6a832",
          "restrict_update":false
        },
        {
          "name":"Phone",
          "available":true,
          "sys_id":"9378a530a1820610f809018efd9bc01e",
          "restrict_update":false
        }
      ]
    }
  }
}

Example

The following code example shows how to call this method for an openframe_awa_workitem_accepted event.

function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_workitem_accepted, handleIconClick);

Output:

// Sample workItem object output
// openframe_awa_workitem_accepted event only
{
  "result": {
    "workItem": {
      "sys_id": "14c86c40a1650610f87701807d9bc0be",
      "size": 1,
      "serviceChannel": {
        "name": "Chat",
        "sys_id": "27f675e3739713004a905ee515f6a7c3"
      },
      "document": {
        "sys_id": "aa582040a1650610f87701807d9bc076",
        "table": "interaction"
      },
      "previousWorkItem": "7c78a440a1650610f87701807d9bc02b",
      "isQueueTransferred": true,
      "isAutoAccepted": true
    }
  }
}

Example

The following code example shows how to call this method for an openframe_awa_workitem_rejected event.

function handleIconClick(context) {
console.log("Icon was clicked", context);
}
openFrameAPI.subscribe(openFrameAPI.events.openframe_awa_workitem_rejected, handleIconClick);

Output:

// Sample workItem object output
// openframe_awa_workitem_rejected event only
{
  "payload": {
    "workItem": {
      "sys_id": "2c3bdc4824250610f8775e73b116f8de",
      "size": "1",
      "serviceChannel": {
        "name": "Chat",
        "sysID": "27f675e3739713004a905ee515f6a7c3"
      },
      "document": {
        "sys_id": "cf0a180824250610f8775e73b116f80c",
        "table": "interaction"
      },
      "rejection": {
        "reason": "Busy",
        "sys_id": "4e93fa29b38023002e7b6e5f26a8dc20"
      },
      "previousWorkItem": "831b9c4824250610f8775e73b116f841",
      "isQueueTransferred": true
    }
  }
}

openFrameAPI - version()

Returns the OpenFrame API version.

Table 41. Parameters
Name Type Description
None
Table 42. Returns
Type Description
String The OpenFrame API version

Example

var version = openFrameAPI.version();

console.log("API version " + version);