Next IVR

IVR, web and mobile programming for contact center technology.

Aspect CXP Programming Tips


CXP is Aspect's latest IVR offering, with a long history behind it.  Simply stated, it is a comprehensive workflow engine for contact center applications, for IVR and beyond.  It takes time to appreciate all of the features; for now I'm going to provide a few tips.

New CXP Installs

Here is the first thing you should do.

  1. Go into Eclipse preferences (Window, Preferences in Windows - not sure about Mac)
  2. Under General, Startup and Shutdown, Workspaces, check "Prompt for Workspace on Startup."

The reason being, if you accidentally click on the CXP icon on your desktop and start loading CXP, depending on your environment, you may have to wait a couple of minutes before you can close Eclipse.  With the workspace prompt, you can quickly get out of Eclipse.

Configuration Files

The configuration file is essentially a Java properties file, or .NET configuration file. Of course it has its own format, and that's documented well enough in the help guides.
Here are two (of many) reasons to use a configuration file:

  1. You are deploying the application in more than one environment - development, production, premise, hosted, and so on - and that affects what values your application may be using, like passwords, URLs and so on.
  2. You are going to provide Release Notes that tell people how they can configure values which change the application behavior.

If you are testing your app locally, you can set the "Configuration File" parameter in the testService Service and test it out. I put mine in my public documents folder, and I reference it like so:

file:///Users/Public/Documents/devconfig.xml

Expressions

The CXP Expression objects help enforce good programming principles, like "Do One Thing" and "Don't Repeat Yourself." You have to break down your complex functions into discrete parts. While this is time well spent, here are a few built-in "shortcuts" you can use to get the most out of the existing functions:

The REPLACE expression

The Replace expression can perform a text substitution. While it looks like a simple little function, it is very powerful because it implements Regular Expressions.

You can learn everything you ever want to know about RegEx by reading "Mastering Regular Expressions."  This is a must-read for programmers, and it gets deep into regular expressions to the point where you will probably be fine just skimming the later chapters (unless, of course, you really want to master those regular expressions!).

Here's an example of how to use it.  Suppose you want to read off the date part from "2012-01-02 03:04:56.000" as mm/dd/yyyy. You can REPLACE "(dddd)(-)(dd)(-)(dd)(.*)" with "\$2/\$3/\$1" and you get "01/02/2012"  Simple and powerful!

The XLST expression

This is another "iceberg" function offered in the expressions. You can spend a few days mastering XSLT transformations (and if you deal with XML, it is time well spent), and then dealing with things like complex web service results, or the Collection object, becomes very simple.
For example, if you have to retrieve a database set of 300 records, and dynamically filter them down to various subsets, you don't want to write out parsing routines with lengthy CXP code. Let an XSLT transformation do all the work.

The following illustrates XSLT transformations:

demo.xml

5 xml records which are essentially table records.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="demo.xsl"?>
<root>
 <row>
  <col name="id">1</col>
  <col name="name">John Jones</col>
  <col name="status">Active</col>
 </row>
 <row>
  <col name="id">2</col>
  <col name="name">Zeta Jones</col>
  <col name="status">Pending</col>
 </row>
 <row>
  <col name="id">3</col>
  <col name="name">Alpha Zeta</col>
  <col name="status">Withdrawn</col>
 </row>
 <row>
  <col name="id">4</col>
  <col name="name">Larry Fowl</col>
  <col name="status">Active</col>
 </row>
 <row>
  <col name="id">5</col>
  <col name="name">Susan Cod</col>
  <col name="status">Active</col>
 </row>
</root>

demo.xsl

this will transform the above xml. This is selecting only the ones where status is Active.

<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/><xsl:template match="/">
<xsl:param name="arg3">status</xsl:param>
<xsl:param name="arg4">Active</xsl:param>
<root>
 <xsl:for-each select="/root/row[col/@name=$arg3 and col/text()=$arg4]">
  <row>
   <xsl:copy-of select="col"/>
  </row>
 </xsl:for-each>
</root>
 </xsl:template>
</xsl:stylesheet>

XSLTPROC

Using a command line tool to transform demo.xml:
\$ xsltproc.exe demo.xsl demo.xml

<?xml version="1.0"?>
<root>
 <row>
  <col name="id">1</col>
  <col name="name">John Jones</col>
  <col name="status">Active</col>
 </row>
 <row>
  <col name="id">4</col>
  <col name="name">Larry Fowl</col>
  <col name="status">Active</col>
 </row>
 <row>
  <col name="id">5</col>
  <col name="name">Susan Cod</col>
  <col name="status">Active</col>
 </row>
</root>

That's the output I was expecting. It's ready for my app. Within CXP, you can pass in the params (column_name and column_value as the 3rd and 4th arguments) and override the default values I used.  There you have it, instant filtering with a simple Expression.

That's all I have for now. Happy coding!