The ININ.IceLib.Interactions namespace contains classes for manipulating Interaction Center interaction queues, watching for specific interaction changes, creating interactions (calls, emails, chats, generic objects, etc.), resolving email recipients, getting a user's interaction history, and receiving interaction alerting events. It also allows for handling screen pops, working with agent assistance requests, assign wrap up codes, and retrieving phone number details.

In the Interaction Center system, an 'interaction' is an object such as a call, chat, email, queues, watching for specific interaction changes, creating interactions (calls, emails, chats, generic objects, etc.), resolving email recipients, getting a user's interaction history, and receiving interaction alerting events. It also allows for handling screen pops, working with agent assistance requests, assign wrap up codes, and retrieving phone number details.

Note

For information about the standard attributes defined by the Interaction Center System, see the "Interaction Attributes Technical Reference" in the Interaction Center Documentation Library. This document describes the attributes and the format of their values.

Note

The following are some examples of using the interactions namespace classes. It is assumed that an active session is present, an InteractionsManager instance has been created with the session, and saved in a variable named "_interactionsManager".

Jump to a code example:

Watching for Queue Contents Changes in Bulk

The following example illustrates how to monitor an InteractionQueue for changes in bulk. It will watch for all Interactions on a given Queue as well as other related events. An example use of this type of watch would be as in the Interaction Client .Net Edition's "My Interactions" tab.

Note
If a QueueContentsChanged event handler has been added to the InteractionQueue instance, then no invididual events (e.g. InteractionAdded) will be received even if event handlers have been added.

Note
Notice that the events are subscribed to before the watch is started. In order to guarantee that no notifications are missed, the event handlers need to be subscribed to before the watch is started.

CopyC#
// For this example, we are interested in the "MyInteractions" queue of a user with ID "userid".
QueueId queueId = new QueueId(QueueType.MyInteractions, "userid");
_interactionQueue = new InteractionQueue(_interactionsManager, queueId);

// For this example, we are interested in watching the StateDescription and RemoteId attributes of the Interactions
// in the InteractionQueue. The watched attributes can also include custom attribute names.
// 
// Any attribute that will later be retrieved from the interaction must be included in an Interaction or InteractionQueue
// watch that the Interaction instance is part of.
string[] watchedAttributes = new[] { InteractionAttributeName.StateDescription, InteractionAttributeName.RemoteId };

// The QueueContentsChanged event bundles up multiple interaction and conference interaction adds, removes, and changes.
// This event is preferred for workgroup and line queues for performance.  It can be used for all queues for convenience.
// (If there is a QueueContentsChanged event handler, then the individual added/removed/changed events will not be fired.)
_interactionQueue.QueueContentsChanged += QueueContentsChanged;
_interactionQueue.LostRights += QueueLostRights;

// Subscribe to events before starting the watch.
_interactionQueue.StartWatching(watchedAttributes);

The following example illustrates the event handler signatures, and the event arguments parameters.

CopyC#
private static void QueueContentsChanged(object sender, QueueContentsChangedEventArgs e)
{
    // The event args bundles queue contents changes together for improved performance.
    // It contains collections of all the interaction adds, removes, and changes
    // as well as collections of all the conference item adds, removes, and changes.

    // For removes, this includes the interactions and conference interactions that were removed.

    // For adds and changes, this includes the interactions and conference interactions that changed,
    // and the the names of the watched attributes that changed.

    // The attribute names correspond with InteractionAttributeName entries 
    // (or the similar *AttributeName classes for specific interaction types),
    // or the names might correspond to custom attributes or attributes that aren't explicitly exposed through IceLib.

    // For adds and changes, the values of the attributes can be retrieved from the related Interaction instance's
    // properties and methods.
}

private static void QueueLostRights(object sender, EventArgs e)
{
    // This event will be sent if the session user loses rights to the queue.
}

The following example illustrates the code that needs to be run when an IceLib integrated application no longer needs the associated queue watch. This could be in cases where, for instance, a form is closed, or when the application receives a ConnectionStateChanged notification where the connection is Down.

CopyC#
if (_interactionQueue == null || !_interactionQueue.IsWatching()) return;

// Removing event handlers helps avoid dangling references.
_interactionQueue.QueueContentsChanged -= QueueContentsChanged;
_interactionQueue.LostRights -= QueueLostRights;

// Once a watch is no longer needed, it must be stopped so that IceLib/IC can clean up caches appropriately.
_interactionQueue.StopWatching();

Back to Introduction

Watching for Queue Contents Changes Individually

The following example illustrates how to monitor an InteractionQueue for changes individually. It will watch for all Interactions on a given Queue as well as other related events.

Note
The individual events (e.g. InteractionAdded) will only be received if no QueueContentsChanged event handler has been added to the InteractionQueue instance.

Note
Notice that the events are subscribed to before the watch is started. In order to guarantee that no notifications are missed, the event handlers need to be subscribed to before the watch is started.

CopyC#
// For this example, we are interested in the "MyInteractions" queue of a user with ID "userid".
QueueId queueId = new QueueId(QueueType.MyInteractions, "userid");
_interactionQueue = new InteractionQueue(_interactionsManager, queueId);

// For this example, we are interested in watching the StateDescription and RemoteId attributes of the Interactions
// in the Queue. The watched attributes can also include custom attribute names.
// 
// Any attribute that will later be retrieved from the Interaction must be included in an Interaction or InteractionQueue
// watch that the Interaction instance is part of.
string[] watchedAttributes = new[] { InteractionAttributeName.StateDescription, InteractionAttributeName.RemoteId };

// Individual interaction and conference interaction adds/removes/changes can be received,
// as an alternative to the "batching" of QueueContentsChanged.
// (If there is a QueueContentsChanged event handler, then the individual added/removed/changed events will not be fired.)
_interactionQueue.InteractionAdded += QueueInteractionAdded;
_interactionQueue.InteractionChanged += QueueInteractionChanged;
_interactionQueue.InteractionRemoved += QueueInteractionRemoved;
_interactionQueue.ConferenceInteractionAdded += QueueConferenceInteractionAdded;
_interactionQueue.ConferenceInteractionChanged += QueueConferenceInteractionChanged;
_interactionQueue.ConferenceInteractionRemoved += QueueConferenceInteractionRemoved;
_interactionQueue.LostRights += QueueLostRightsEventHandler;

// Subscribe to events before starting the watch.
_interactionQueue.StartWatching(watchedAttributes);

The following example illustrates the event handler signatures, and the event arguments parameters.

CopyC#
private void QueueInteractionAdded(object sender, InteractionAttributesEventArgs e)
{
    // The event args contains the Interaction that was added and the names of the attributes that were watched.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueInteractionChanged(object sender, InteractionAttributesEventArgs e)
{
    // The event args contains the Interaction that changed and the names of the watched attributes that changed.

    // The attribute names correspond with InteractionAttributeName entries
    // (or the similar *AttributeName classes for specific interaction types),
    // or the names might correspond to custom attributes or attributes that aren't explicitly exposed through IceLib.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueInteractionRemoved(object sender, InteractionEventArgs e)
{
    // The event args contains the Interaction that was removed.
}

private static void QueueConferenceInteractionAdded(object sender, ConferenceInteractionAttributesEventArgs e)
{
    // The event args contains the conference Interaction that was added and the names of the attributes that were watched.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueConferenceInteractionChanged(object sender, ConferenceInteractionAttributesEventArgs e)
{
    // The event args contains the conference Interaction that changed and the names of the watched attributes that changed.

    // The attribute names correspond with InteractionAttributeName entries
    // (or the similar *AttributeName classes for specific interaction types),
    // or the names might correspond to custom attributes or attributes that aren't explicitly exposed through IceLib.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueConferenceInteractionRemoved(object sender, ConferenceInteractionEventArgs e)
{
    // The event args contains the conference Interaction that was removed.
}

private static void QueueLostRightsEventHandler(object sender, EventArgs e)
{
    // This event will be sent if the session user loses rights to the queue.
}

The following example illustrates the code that needs to be run when an IceLib integrated application no longer needs the associated queue watch. This could be in cases where, for instance, a form is closed, or when the application receives a ConnectionStateChanged notification where the connection is Down.

CopyC#
if (_interactionQueue == null || !_interactionQueue.IsWatching()) return;

// Removing event handlers helps avoid dangling references.
_interactionQueue.InteractionAdded -= QueueInteractionAdded;
_interactionQueue.InteractionChanged -= QueueInteractionChanged;
_interactionQueue.InteractionRemoved -= QueueInteractionRemoved;
_interactionQueue.ConferenceInteractionAdded -= QueueConferenceInteractionAdded;
_interactionQueue.ConferenceInteractionChanged -= QueueConferenceInteractionChanged;
_interactionQueue.ConferenceInteractionRemoved -= QueueConferenceInteractionRemoved;
_interactionQueue.LostRights -= QueueLostRightsEventHandler;

// Once a watch is no longer needed, it must be stopped so that IceLib/IC can clean up caches appropriately.
_interactionQueue.StopWatching();

Back to Introduction

Watching for Interaction Changes

The following example illustrates how to monitor an Interaction for changes.

Note
Notice that the events are subscribed to before the watch is started. In order to guarantee that no notifications are missed, the event handlers need to be subscribed to before the watch is started.

CopyC#
// For this example, we are interested in the "MyInteractions" queue of a user with ID "userid".
QueueId queueId = new QueueId(QueueType.MyInteractions, "userid");
_interactionQueue = new InteractionQueue(_interactionsManager, queueId);

// For this example, we are interested in watching the StateDescription and RemoteId attributes of the Interactions
// in the Queue. The watched attributes can also include custom attribute names.
// 
// Any attribute that will later be retrieved from the Interaction must be included in an Interaction or InteractionQueue
// watch that the Interaction instance is part of.
string[] watchedAttributes = new[] { InteractionAttributeName.StateDescription, InteractionAttributeName.RemoteId };

// Individual interaction and conference interaction adds/removes/changes can be received,
// as an alternative to the "batching" of QueueContentsChanged.
// (If there is a QueueContentsChanged event handler, then the individual added/removed/changed events will not be fired.)
_interactionQueue.InteractionAdded += QueueInteractionAdded;
_interactionQueue.InteractionChanged += QueueInteractionChanged;
_interactionQueue.InteractionRemoved += QueueInteractionRemoved;
_interactionQueue.ConferenceInteractionAdded += QueueConferenceInteractionAdded;
_interactionQueue.ConferenceInteractionChanged += QueueConferenceInteractionChanged;
_interactionQueue.ConferenceInteractionRemoved += QueueConferenceInteractionRemoved;
_interactionQueue.LostRights += QueueLostRightsEventHandler;

// Subscribe to events before starting the watch.
_interactionQueue.StartWatching(watchedAttributes);

The following example illustrates the event handler signatures, and the event arguments parameters.

CopyC#
private void QueueInteractionAdded(object sender, InteractionAttributesEventArgs e)
{
    // The event args contains the Interaction that was added and the names of the attributes that were watched.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueInteractionChanged(object sender, InteractionAttributesEventArgs e)
{
    // The event args contains the Interaction that changed and the names of the watched attributes that changed.

    // The attribute names correspond with InteractionAttributeName entries
    // (or the similar *AttributeName classes for specific interaction types),
    // or the names might correspond to custom attributes or attributes that aren't explicitly exposed through IceLib.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueInteractionRemoved(object sender, InteractionEventArgs e)
{
    // The event args contains the Interaction that was removed.
}

private static void QueueConferenceInteractionAdded(object sender, ConferenceInteractionAttributesEventArgs e)
{
    // The event args contains the conference Interaction that was added and the names of the attributes that were watched.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueConferenceInteractionChanged(object sender, ConferenceInteractionAttributesEventArgs e)
{
    // The event args contains the conference Interaction that changed and the names of the watched attributes that changed.

    // The attribute names correspond with InteractionAttributeName entries
    // (or the similar *AttributeName classes for specific interaction types),
    // or the names might correspond to custom attributes or attributes that aren't explicitly exposed through IceLib.

    // The values of the attributes can be retrieved from the related Interaction instance's properties and methods.
}

private static void QueueConferenceInteractionRemoved(object sender, ConferenceInteractionEventArgs e)
{
    // The event args contains the conference Interaction that was removed.
}

private static void QueueLostRightsEventHandler(object sender, EventArgs e)
{
    // This event will be sent if the session user loses rights to the queue.
}

The following example illustrates the code that needs to be run when an IceLib integrated application no longer needs the associated interaction watch. This could be in cases where, for instance, a form is closed, or when the application receives a ConnectionStateChanged notification where the connection is Down.

CopyC#
if (_interactionQueue == null || !_interactionQueue.IsWatching()) return;

// Removing event handlers helps avoid dangling references.
_interactionQueue.InteractionAdded -= QueueInteractionAdded;
_interactionQueue.InteractionChanged -= QueueInteractionChanged;
_interactionQueue.InteractionRemoved -= QueueInteractionRemoved;
_interactionQueue.ConferenceInteractionAdded -= QueueConferenceInteractionAdded;
_interactionQueue.ConferenceInteractionChanged -= QueueConferenceInteractionChanged;
_interactionQueue.ConferenceInteractionRemoved -= QueueConferenceInteractionRemoved;
_interactionQueue.LostRights -= QueueLostRightsEventHandler;

// Once a watch is no longer needed, it must be stopped so that IceLib/IC can clean up caches appropriately.
_interactionQueue.StopWatching();

Back to Introduction

Making a call

The following example illustrates how to create a call interaction. There are various options such as placing the call on behalf of a workgroup or setting an account code.

CopyC#
CallInteractionParameters callInteractionParameters = new CallInteractionParameters("5555555");

// The call can be placed on behalf of a workgroup.
callInteractionParameters.OnBehalfOfWorkgroup = "marketing";

// An account code can easily be set on the call.
callInteractionParameters.AccountCodeId = "account code ID";

// Or some notes.
callInteractionParameters.Notes = "custom notes";

// Attributes can be initially set on the new call.
callInteractionParameters.AdditionalAttributes["custom attribute name"] = "custom attribute value";

// The asynchronous version is preferable if invoking the API from the UI thread.
Interaction interaction = _interactionsManager.MakeCall(callInteractionParameters);

Back to Introduction

Creating a generic interaction

The following example illustrates how to create a generic interaction. Custom attributes can be specified for the new interaction instance.

CopyC#
QueueId queueId = new QueueId(QueueType.Workgroup, "custom workgroup queue");

GenericInteractionParameters genericInteractionParameters = new GenericInteractionParameters(queueId, InteractionState.Alerting);

// Attributes can be initially set on the new call.
genericInteractionParameters.AdditionalAttributes["custom attribute name"] = "custom attribute value";

// The asynchronous version is preferable if invoking the API from the UI thread.
Interaction interaction = _interactionsManager.MakeGenericInteraction(genericInteractionParameters);

Back to Introduction

Watching for screen pop events

The following example illustrates how to monitor for screen pop events. The screen pop information is configured in Interaction Administrator, specifying an application, action, and commands that should be sent as a screen pop associated with the specified interactions in the system.

Note
Notice that the event is subscribed to before the watch is started. In order to guarantee that no notifications are missed, the event handlers need to be subscribed to before the watch is started.

CopyC#
_screenPop = new ScreenPop(_interactionsManager);

_screenPop.ScreenPopCreated += ScreenPopCreated;

// Subscribe to events before starting the watch.
_screenPop.StartWatching();

The following example illustrates the event handler signature, and the event arguments parameters.

CopyC#
private static void ScreenPopCreated(object sender, ScreenPopEventArgs e)
{
    // The event args contains the parameters for the screen pop: application, executable, action, commands, and Interaction ID.
    ScreenPopItem screenPopItem = e.ScreenPopItem;

    long interactionId = screenPopItem.InteractionId;

    string applicationName = screenPopItem.ApplicationName;
    string executableName = screenPopItem.ExecutableName;

    string actionName = screenPopItem.ActionName;
    string topicName = screenPopItem.TopicName;
    List<string> commands = screenPopItem.Commands;
}

The following example illustrates the code that needs to be run when an IceLib integrated application no longer needs the associated screen pop watch. This could be in cases where, for instance, a form is closed, or when the application receives a ConnectionStateChanged notification where the connection is Down.

CopyC#
if (_screenPop == null || !_screenPop.IsWatching()) return;

// Removing event handlers helps avoid dangling references.
_screenPop.ScreenPopCreated -= ScreenPopCreated;

// Once a watch is no longer needed, it must be stopped so that IceLib/IC can clean up caches appropriately.
_screenPop.StopWatching();

Back to Introduction