startSession
startSession(String sessionID, 
boolean relyOnExistingSession,
boolean debug,
String interactiveChannel,
NameValuePairImpl[] audienceID,
String audienceLevel,
NameValuePairImpl[] parameters)
The startSession method creates and defines a runtime session. startSession can trigger up to five actions:
*
*
*
*
load offer suppression data into the session, if the enableOfferSuppressionLookup property is set to true.
*
load score override data into the session, if the enableScoreOverrideLookup property is set to true.
The startSession method requires the following parameters:
*
sessionID-a string which identifies the session ID. You must define the session ID. For example, you could use a combination of customer ID and timestamp.
To define what makes a runtime session, a session id has to be specified. This value is managed by the client. All method calls for the same session id has to be synchronized by the client. The behavior for concurrent API calls with the same session id is undefined.
*
relyOnExistingSession - a boolean which defines whether this session uses a new or an existing session. Valid values are true or false. If true, you must supply an existing session ID with the startSession method. If false, you must supply a new session ID.
If you set relyOnExistingSession to true and a session exists, the runtime environment uses the existing session data and does not reload any data or trigger segmentation. If the session does not exist, the runtime environment creates a new session, including loading data and triggering segmentation. Setting relyOnExistingSession to true and using it with all startSession calls is useful if your touchpoint has a longer session length than the runtime session. For example, a web site session is alive for 2 hours, but the runtime session is only alive for 20 minutes.
If you call startSession twice with the same session ID, all session data from the first startSession call is lost if relyOnExistingSession is false.
*
debug - a boolean which enables or disables debug information. Valid values are true or false. If true, Interact logs debug information to the runtime server logs. The debug flag is set for each session individually. Therefore, you can trace debug data for an individual session.
*
interactiveChannel-a string defining the name of the interactive channel this session refers to. This name must match the name of the interactive channel defined in Campaign exactly.
*
audienceID - an array of NameValuePairImpl objects where the names must match the physical column names of any table containing the audience ID.
*
audienceLevel - a string defining the audience level.
*
parameters - NameValuePairImpl objects identifying any parameters that need to be passed with startSession. These values are stored in the session data and can be used for segmentation.
If you have several interactive flowcharts for the same audience level, you must include a superset of all columns in all the tables. If you configure the runtime to load the profile table, and the profile table contains all the columns you require, you do not need to pass any parameters, unless you want to overwrite the data in the profile table. If your profile table contains a subset of the required columns, you must include the missing columns as parameters.
If the audienceID or audienceLevel are invalid and relyOnExistingSession is false, the startSession call fails. If the interactiveChannel is invalid, startSession fails, whether relyOnExistingSession is true or false.
If relyOnExistingSession is true, and you make a second startSession call using the same sessionID, but the first session has expired, Interact creates a new session.
If relyOnExistingSession is true, and you make a second startSession call using the same sessionID but a different audienceID or audienceLevel, the runtime server changes the audience for the existing session.
If relyOnExistingSession is true, and you make a second startSession call using the same sessionID but a different interactiveChannel, the runtime server creates a new session.
Return value
The runtime server responds to startSession with a Response object with the following attributes populated:
*
*
*
*
Example
The following example shows one way to call startSession.
String sessionId="MySessionID-123";
String audienceLevel="Customer";
NameValuePair custId = new NameValuePairImpl();
custId.setName("CustomerId");
custId.setValueAsNumeric(1.0);
custId.setValueDataType(NameValuePair.DATA_TYPE_NUMERIC);
NameValuePair[] initialAudienceId = { custId };
boolean relyOnExistingSession=false;
boolean initialDebugFlag=true;
String interactiveChannel="Accounts Website";
NameValuePair parm1 = new NameValuePairImpl();
parm1.setName("SearchString");
parm1.setValueAsString("");
parm1.setValueDataType(NameValuePair.DATA_TYPE_STRING);

NameValuePair parm2 = new NameValuePairImpl();
parm2.setName("TimeStamp");
parm2.setValueAsDate(new Date());
parm2.setValueDataType(NameValuePair.DATA_TYPE_DATETIME);

NameValuePair parm3 = new NameValuePairImpl();
parm3.setName("Browser");
parm3.setValueAsString("IE6");
parm3.setValueDataType(NameValuePair.DATA_TYPE_STRING);

NameValuePair parm4 = new NameValuePairImpl();
parm4.setName("FlashEnabled");
parm4.setValueAsNumeric(1.0);
parm4.setValueDataType(NameValuePair.DATA_TYPE_NUMERIC);

NameValuePair parm5 = new NameValuePairImpl();
parm5.setName("TxAcctValueChange");
parm5.setValueAsNumeric(0.0);
parm5.setValueDataType(NameValuePair.DATA_TYPE_NUMERIC);

NameValuePair parm6 = new NameValuePairImpl();
parm6.setName("PageTopic");
parm6.setValueAsString("");
parm6.setValueDataType(NameValuePair.DATA_TYPE_STRING);

/** Specifying the parameters (optional) */
NameValuePair[] initialParameters = { parm1,
parm2,
parm3,
parm4,
parm5,
parm6
};

/** Make the call */
response = api.startSession(sessionId, relyOnExistingSession, initialDebugFlag,
interactiveChannel, initialAudienceId, audienceLevel, initialParameters);

/** Process the response appropriately */
processStartSessionResponse(response);
processStartSessionResponse is a method which handles the response object returned by startSession.
public static void processStartSessionResponse(Response response)
{
// check if response is successful or not
if(response.getStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("startSession call processed with no warnings or errors");
}
else if(response.getStatusCode() == Response.STATUS_WARNING)
{
System.out.println("startSession call processed with a warning");
}
else
{
System.out.println("startSession call processed with an error");
}

// For any non-successes, there should be advisory messages explaining why
if(response.getStatusCode() != Response.STATUS_SUCCESS)
printDetailMessageOfWarningOrError("StartSession",
response.getAdvisoryMessages());
}