Skip to main content
Version: 5.x

Subflow Triggering

The Flow Designer feature in ServiceNow makes it possible to build No-Code workflows. There is a difference between flows, subflows and actions in ServiceNow. The main difference between a flow and a subflow is that a flow consists of a trigger (a change in a ServiceNow table), and a subflow can either be triggered by another flow or a script. b+s Connects supports triggering subflows from a script based on events occurring on the b+s Connects gadget. This allows for endless and amazing possibilities.

Possible events

ServiceNow subflows can be triggered based on the following events.

Agent State Change Events

This event is raised when a specific channel's state changes.

FieldTypeDescription
eventStringEvent name "agentStateChange".
versionIntegerAPI version.
requestIdStringIdentifier to match this event to a request.
channelTypeStringChannel type (Voice).
channelIdStringChannel identifier (voice_<peripheral_id>)
newStateStringNew state (Logout, Offline, Ready, NotReady, Active, Wrapup, Unknown).
newReasonCodeStringNew reason code. Negative values indicate no code available.
newReasonCodeLabelStringNew reason name.
newStateChangeTimeStringNew state change time.
oldStateStringPrevious state: (Logout, Offline, Ready, NotReady, Active, Wrapup, Unknown).
oldReasonCodeStringPreviously selected reason code. Negative values indicate no code available.
oldReasonCodeLabelStringPreviously selected reason name.
oldStateChangeTimeStringPrevious state change time.

Workitem events (e.g. Call events)

There are several workitem events that can occur. The different events are workitemCreate, participantMapping, workitemConnect, workitemPause, workitemResume, workitemTransferred, workitemWrapup and workitemEnd. All these events contain the same following data.

FieldTypeDescription
eventStringName of the event.
versionIntegerAPI version.
requestIdStringIdentifier to match this event to a request (for future use).
idStringCall ID or Task ID for the current work item.
aniStringWhen there’s only one participant and the direction is outgoing, toAddress is picked otherwise fromAddress is chosen.
agentIdStringAgent ID.
stateStringCurrent State (Unknown, Initiated, Offered, Active, Paused, Wrapup, Ended, EndedAbandoned, EndedTransferred, EndedUnknown).
directionStringIncoming or Outgoing.
channelTypeStringChannel type (Voice, Mail, Chat, Task, Federation).
channelIdStringChannel identifier (voice_<peripheral_id>, <Media Routing ID>)
For CCX: voice_-1
ctiDataObjectPlease see the ctiData reference for available data and format.
connectedAtStringDate and time in UTC when the call was established (e.g 2020-07-28T09:51:17.696Z).
participantsStringList of participants with their address.
classificationStringWork item class (Customer, Consultation, Conference, Transfer, Internal, Unknown).
activityObjectObject including the interaction. See activity record reference
participantLookupResultArray<Object>List of the found participant lookup entries. See ServiceNow record reference
associatedParticipantObjectThe assigned record of the participant lookup. See ServiceNow record reference
associationsArray<Object>List of all records that got assigned to the interaction over the b+s Connects application. This includes the assigned participant. See ServiceNow record reference
capabilitiesArray<Object>List of actions that can be carried out.

ctiData

The availability of the following fields is dependent on the Finesse version. Please see the Finesse documentation for more details.

FieldTypeDescription
callVariable1-10StringPeripheral variables 1 to 10.
user.< variable >StringECC variables.
DNISStringDNIS of the call.
callTypeStringType of the call.
dialedNumberStringDialed Number of the call.
outboundClassificationStringOutbound call classification (VOICE, FAX, ANS_MACHINE, INVALID, DO_NOT_CALL, or BUSY).
callKeyCallIdStringThe unique number for the call routed on that particular day (CCE only).
callKeyPrefixStringThe day when the call was routed (CCE only).
mediaIdStringMedia routing ID.
queueNameStringName of the queue.
queueNumberStringQueue name ID.
wrapUpReasonStringCurrently set call wrap-up reason.

Activity record

The activity is an object containing the interaction sys_id of the workitem and the recordType (which in this case always is interaction).

caution

It is possible that the interaction is undefined for the workitemCreate event.

FieldTypeDescription
idStringUnique identifier of the ServiceNow interaction
recordTypeStringType of the activity record. This is always interaction.

ServiceNow record

caution

It is possible that the field associatedParticipant is undefined.

ServiceNow records consist of the following fields.

FieldTypeDescription
idStringUnique identifier of the ServiceNow record
recordTypeStringThe ServiceNow table of the record. e.g. sys_user
nameStringThe name / title of the record.

Error Events

This event is raised when an error is encountered in b+s Connects.

FieldTypeDescription
eventStringEvent name "error".
versionIntegerAPI version.
requestIdStringIdentifier of the request that might have caused the error. This is empty if the source of the error cannot be detected.
messageStringShort message describing the encountered error.

How to create a subflow

Please refer to the official ServiceNow documentation in order to see how to create subflows and actions. Depending on your subscription you may also be able to use the features of ServiceNow's IntegrationHub in order to have even more great possibilities.

info

ServiceNow role required: admin, flow_designer or delegated_developer

Race conditions

Subflows are executed asynchronously, this means that they could interfere with each other when altering the same table. Channel Blending can be affected as well if a subflow influences the agent state.

Performance consideration

Running these Subflows within a specific scope instead of the global scope can result in a faster execution time and reduce the above mentioned race side effects. For more information, refer to this community thread.

Input parameter

In order to make use of the parameters passed by an event, an input parameter with the name bsevent of type Object has to be created. This object paramter can then contain the needed fields depending on the event that should be triggered. See the tables above for the possible input paramters the bsevent object can contain.

Input variables

caution

The bsevent parameter has to be created on the subflow even if the parameters are not used, otherwise an error will be returned.

Output parameter

b+s Connects offers the possibility of reacting on the output of a subflow. There are 4 different scenarios available:

No output

Don't return anything in order to just execute the subflow without causing anything to happen on the b+s Connects gadget.

Pop ServiceNow Records

Return a ServiceNow record in order to open it up. To do so the output needs to consist of the two required fields id and table and the optional field interaction. Where id has to contain the sysid of the record within ServiceNow, the table field has to contain the name of the ServiceNow table this record is part of, and the interaction can contain the interaction sysid, in case you want to pop the record in the Workspace within an existing interaction.

Output variables Pop

Create an error on the b+s Connects gadget

In case of an error occurring on the subflow it is also possible to return it to the agent and display it accordingly. Therefore the output parameter has to contain a field named type with the value error and a second field called message containing the error message that you want to display to the agent.

Output variables Error

Write a trace entry in the b+s Connects gadget

In order to make a log entry in the b+s Connects gadget you can add the following two fields to the output parameter: type with value trace and message containing the message to log.

Output variables Trace

Multi Tab behaviour

In case the gadget is loaded more than once, only one of the tabs is actually triggering the subflow, so you don't have to worry that wathever the flow does will be made multiple times. Nevertheless the screenpops/errors will be displayed on all the open browser tabs where the b+s Connects gadget is loaded.

Reloading the b+s Connects gadget

In case an agent reloads the b+s Connects gadget during an active workitem, the On Workitem Create event will be triggered a second time. All other events will not be executed again in case of a reload.

Samples

We recommend using the sample subflows available as an update set in order to get started. The update set can be downloaded here. There are three different Subflows and one action available. These examples are meant to be used as a starting point and most probably it doesn't make sense to use them in production without any modifications. All samples include all the possible input values (except for Cisco ECC variables) even if most of them are not used in the scripts.

The following samples reference the above mentioned update set.

b+s Connects Workitem Event Sample

This sample shows how to create an incident in case the event was triggered based on an incoming voice call. It adds the Wrap Up Reason in the "short description" field and puts the caller assigned to the interaction in the "opened for" field.

The created incident will then pop on the agents screen.

For outgoing Voice calls, the script will add a log message to ServiceNow and also return a trace message to the b+s Gadget.

If the event was triggered from a channel other than the voice channel, it will write an error log to ServiceNow and return an error to the b+s Gadget that will be displayed to the agent.

b+s Connects Agent State Change Event Sample

This sample shows how to change the AWA state in case of a Voice agent state change. It uses a sample action that is also part of this update set to trigger the state change.

info

Be aware that the action script to change the AWA state doesn't include any channels. In case you want to set states for just some channels, you have to adjust this script.

b+s Connects Error Event Sample

This sample adds an error log message to ServiceNow.