Interaction Workspace 8.0.0 .NET Developer's Guide and API Reference
Writing Your Custom Applications
Using Interaction Workspace API

You can use the Interaction Workspace API to write your custom-built .NET applications. This document describes how to implement the basic functions that are needed to write and deploy simple customized applications for Interaction Workspace.

- Creating a New Module
- Replacing an Existing View
- Creating a New View
- Customizing a Command
- Deploying Your Custom Module Into the Genesys Out-Of-The-Box Application

After you have reviewed the information in this section, it might be useful to refer to the Interaction Workspace Extension Samples, upon which this document was based. The samples are working applications which contain and execute the functionality outlined here. When you are ready to write more complex applications, refer to the classes and methods described in this API reference.

Creating a New Module

The Interaction Workspace application is a modular application, so the best way to add your customized behavior or appearance is to create a new module. To create a new module you must first create a new assembly (`.dll`), and then create a class that inherits from the `IModule` interface.

The following example shows the new assembly, `Genesyslab.Desktop.Modules.ExtensionSample`, which contains the new class `ExtensionSampleModule`. The `ExtensionSampleModule` class inherits from the `IModule` interface.

    [C#]

    namespace Genesyslab.Desktop.Modules.ExtensionSample
    {
      public class ExtensionSampleModule : IModule
      {
        public void Initialize()
        {
          container.RegisterType<IDispositionCodeView, DispositionCodeExView>();
        }
      }
    }

You must modify the `Modules` section of the `ExtensionSample.module-config` file to include your new module. This can be done in two ways. The first method requires that you add the following topic in the modules section:

    [XML]

    <modules>
     <module assemblyFile="Genesyslab.Desktop.Modules.ExtensionSample.dll"
      moduleType="Genesyslab.Desktop.Modules.ExtensionSample.ExtensionSampleModule"
      moduleName="ExtensionSampleModule">
      <dependencies>
       <dependency moduleName="WindowsModule" ⁄>
      <⁄dependencies>
     <⁄module>
    <⁄modules>

The second method requires that you load the module conditioned with a task. In Configuration Manager, configure a role with the task and assign it to an agent. In this example, the task is `InteractionWorkspace.ExtensionSample.canUse`:

    [XML]

    <tasks>
     <task name="InteractionWorkspace.ExtensionSample.canUse"
      clickOnceGroupsToDownload="ExtensionSample"
      modulesToLoad="ExtensionSampleModule" ⁄>
    <⁄tasks>
    <modules>
     <module assemblyFile="Genesyslab.Desktop.Modules.ExtensionSample.dll"
      moduleType="Genesyslab.Desktop.Modules.ExtensionSample.ExtensionSampleModule"
      moduleName="ExtensionSampleModule"
      startupLoaded="false"⁄>
    <⁄modules>

Replacing an Existing View

There are several ways to customize Interaction Workspace. The most basic way is to change an existing behavior or appearance by changing the implementation of an existing interface. The code that is displayed after Figure 1 demonstrates how to replace an existing view, `DispositionCodeView`, with the new view, `DispositionCodeExView`. You can replace the existing view with another by associating the existing `IDispositionCodeView` interface with the new `DispositionCodeExView` implementation. Start by creating a new Windows Presentation Foundation (WPF) UserControl that is composed of the following two files:

- `DispositionCodeExView.xaml`
- `DispositionCodeExView.xaml.cs`

Note that in Figure 1, the out-of-the-box application uses radio buttons in the Voice Interactions view. The code sample that is displayed after Figure 1 modifies this view.

Figure 1: Voice Interactions View Before Customization

Ensure that your custom-built view named, `DispositionCodeExView` implements the genuine `IDispositionCodeView` interface:

    [C#]

    public partial class DispositionCodeExView : UserControl, IDispositionCodeView
    {
      public DispositionCodeExView(IDispositionCodeViewModel dispositionCodeViewModel)
      {
        Model = dispositionCodeViewModel;
        InitializeComponent();
      }

      #region IDispositionCodeView Members
      public IDispositionCodeViewModel Model
      {
        get { return this.DataContext as IDispositionCodeViewModel; }
        set { this.DataContext = value; }
      }
      #endregion
      ...
    }

The `IObjectContainer.RegisterType` method must be used to register the new implementation in the initialization method of the `ExtensionSampleModule`:

    [C#]

    public class ExtensionSampleModule : IModule
    {
      public void Initialize()
      {
        container.RegisterType<IDispositionCodeView, DispositionCodeExView>();
      }
    }

You can replace any view with your own custom-built view by using the preceding examples.

Figure 2 shows the view for Interaction Workspace Voice Interactions after customization. In the customized view the radio buttons are replaced with check boxes.

Figure 2: Voice Interactions View After Customization

Note: Although the application has a different appearance, it retains its previous behavior.

Creating a New View

Advanced customization can include adding a new view to an existing region (which is embedded in an existing view). To use the Model-View-ViewModel (MVVM) pattern, you must create both the view (`MySampleView`) and the view-model (`MySampleViewModel`).

In the Voice Interactions view, shown in Figure 3 the out-of-the-box application has a single tab (My Channels). You can modify this view by using the code sample that follows Figure 3.

Figure 3: Voice Interactions View Before Customization

To create the view-model, create a new interface named, `IMySampleViewModel` in which a new class named, `MySampleViewModel` is implemented:

    [C#]

    public interface IMySampleViewModel
    {
      ...
    }

    public class MySampleViewModel : IMySampleViewModel
    {
      ...
    }

To create the view, create a new WPF UserControl that is composed of the following two files:

- `MySampleView.xaml`
- `MySampleView.xaml.cs`

Next create your custom-built class named `MySampleView`, and the interface you want to implement, named `IMySampleView`:

    [C#]

    public interface IMySampleView
    {
      IMySampleViewModel Model { get; set; }
    }

    public partial class MySampleView : UserControl, IMySampleView
    {
      public MySampleView(IMySampleViewModel mySampleViewModel)
      {
        this.Model = mySampleViewModel;
        InitializeComponent();
      }

      #region IMySampleView Members
      public IMySampleViewModel Model
      {
        get { return this.DataContext as IMySampleViewModel; }
        set { this.DataContext = value; }
      }
      #endregion
      ...
    }

Use the `IObjectContainer.RegisterType` method to register your new classes in the module initialization:

    [C#]

    public class ExtensionSampleModule : IModule
    {
      public void Initialize()
      {
        container.RegisterType<IMySampleView, MySampleView>();
        container.RegisterType<IMySampleViewModel, MySampleViewModel>();
    		...

Use the `IViewManager.ViewsByRegionName` method to retrieve the region information (see the TabControl on the main toolbar) and insert the new view in the form of a `ViewActivator` object:

    [C#]

        ...
        viewManager.ViewsByRegionName["ToolbarWorkplaceRegion"].Insert(0, new ViewActivator()
        {
          ViewType = typeof(<IMySampleView>), ViewName = "MySample"
        } );
      }
    }

Figure 4 depicts the `MySampleView` after customization with the second tab (My Sample Header) included in the view. In the following example the `ToolbarWorkplaceRegion` of the view is modified. For a complete list of views and regions, see Views with Their Regions.

Figure 4: Voice Interactions View After Customization

Customizing a Command

The command system is based on the chain of command (or chain of responsibility) design pattern. The following example illustrates how to create your own command by using Genesys best practices. After creating the command, you must add it to a chain of command. The custom command in the example displays a confirmation dialog before executing the `ReleaseCall` command. Create the elementary command class:

    [C#]

    class BeforeReleaseCallCommand : IElementOfCommand
    {
     readonly IObjectContainer container;
     ILogger log;

     //Initializes a new instance of the BeforeReleaseCallCommand class
     public BeforeReleaseCallCommand(IObjectContainer container)
     {
       this.container = container;

       //Initialize the trace system
       this.log = container.Resolve<ILogger>();

       //Create a child trace section
       this.log = log.CreateChildLogger("BeforeReleaseCallCommand");
     }

     //Get the name of the command (optional)
     public string Name { get { return "BeforeReleaseCall"; } }

     // Execute the command.
     public bool Execute(IDictionary<string, object> parameters, IProgressUpdater progress)
     {
       log.Info("Execute");

       //Get the parameter
       IInteractionVoice interactionVoice = parameters.TryGetValue("CommandParameter") as IInteractionVoice;

       container.Resolve<IEnterpriseServiceProvider>()
        .Resolve<IInteractionService>("interactionService")
        .BeforeReleaseCallCommand(interactionVoice.EntrepriseInteractionCurrent,
        parameters.TryGetValue("Reasons") as KeyValueCollection,
        parameters.TryGetValue("Extensions") as KeyValueCollection);

       return false;
     }
    }

Create the chain of command in the `Module` initialization by using the `CommandManager`:

    [C#]

    ICommandManager commandManager = container.Resolve<ICommandManager>();
    commandManager.AddCommandToChainOfCommand("InteractionVoiceReleaseCall", new List<CommandActivator>()
     { new CommandActivator() { CommandType = typeof(BeforeReleaseCallCommand) } });

You can add several commands to a chain of command. The order of execution follows the order in which the commands are added. `BeforeReleaseCallCommand` is executed before `ReleaseCallCommand`, for example:

    [C#]

    commandManager.AddCommandToChainOfCommand("InteractionVoiceReleaseCall", new List<CommandActivator>() {
    new CommandActivator() { CommandType = typeof(BeforeReleaseCallCommand) },
    new CommandActivator() { CommandType = typeof(ReleaseCallCommand) }
    });

Finally, execute the chain of command by using parameters, as shown in the following example (defined here: Command list):

    [C#]

    IDictionary<string, object> parameters = new Dictionary<string, object>();
    parameters.Add("CommandParameter", interaction);
    parameters.Add("Reasons", reasons);
    parameters.Add("Extensions", extensions);
    commandManager.GetChainOfCommandByName("InteractionVoiceReleaseCall").Execute(parameters);

For a detailed list of customizable commands, see Customizable Commands.

Deploying Your Custom Module into the Genesys Out-Of-The-Box Application

To deploy your custom module in a Click-Once deployment environment:

1. Write your custom code by using the provided APIs.
2. Compile the project as an assembly.
3. Unit test the project using a Unit Test framework or a simple test application.
4. Package the custom assembly with the Genesys out-of-the-box Interaction Workspace (by using Deployment Manager if Click-Once is used, or by using a custom IP).
5. In the Interaction Workspace application in Management Framework, configure a mapping between any custom tasks and the custom assembly.
6. Use the Genesys RBAC model to assign the custom task to users or to an access group of users.

For all other types of deployment, use the following steps to load and execute your custom assembly in Interaction Workspace:

1. Add your `.dll` file to the same directory as the one containing the `InteractionWorkspace.exe` file.
2. Create a new `<module>` section in the `ExtensionSample.module-config` file. See the following examples:

    [XML]

    <module assemblyFile="Genesyslab.Desktop.Modules.ExtensionSample.dll"
     moduleType="Genesyslab.Desktop.Modules.ExtensionSample.ExtensionSampleModule"
     moduleName="ExtensionSampleModule">
     <dependencies>
      <dependency moduleName="WindowsModule" />
     </dependencies>
    </module>

    [XML]

    <tasks>
     <task name="InteractionWorkspace.ExtensionSample.canUse"
      clickOnceGroupsToDownload="ExtensionSample"
      modulesToLoad="ExtensionSampleModule" ⁄>
    <⁄tasks>
    <modules>
     <module assemblyFile="Genesyslab.Desktop.Modules.ExtensionSample.dll"
      moduleType="Genesyslab.Desktop.Modules.ExtensionSample.ExtensionSampleModule"
      moduleName="ExtensionSampleModule"
      startupLoaded="false"⁄>
    <⁄modules>

Additional Information

Refer to the Genesys Developer Documentation CD or the Genesys Developer website, DevZone. DevZone is available at http://www.genesyslab.com/developer. It contains the latest versions of all Software Development Kit (SDK) documents, and forums, along with other important sources of developer-related information.

For additional information about the Genesys Telecommunications Laboratories, Inc., see our Technical Support website.

The following documentation contains information about Interactive Workspace. Genesys recommends that you consult the Deployment Guide first.

- Interaction Workspace 8.0.0 Deployment Guide

- Interaction Workspace 8.0.0 User’s Guide

- Interaction Workspace 8.0.0 Release Note

- Interaction Workspace 8.0.0 Extension Samples

- Interaction Workspace 8.0.0 Context Sensitive Help (found in the application interface)

Top of Page