Contents |
This section shows how to use the Predictive service via the API to have a complete agent session. Most of the description is available here, so the focus of this page is mainly on the source code.
This source code is:
public static void main(String[] args)
{
// xFire specific client instantiation
PredictiveServiceRunner client = new PredictiveServiceRunner();
// Constants
// These values are for demonstration only, please replace with your own
// specific parameters.
String API_KEY = "cbecba7e80afasdfarewbfdfgrregtnrgtb2b35081652f9fc8ad52";
long campaignId = 190047;
String agentPhoneNumber = "";
String userId = "John Doe";
String agentId = "";
String nextCall = "Y";
// Get the endpoint
PredictiveServicePortType service = client.getPredictiveServiceHttpPort();
// Prompt for phone number
agentPhoneNumber = getPhoneNumber();
// Request agent call
service.sendAgentCallBack(API_KEY, campaignId, userId , agentPhoneNumber);
// Prompt for agent ID
agentId = getAgentId();
// login agent.
service.loginAgent( API_KEY , campaignId, agentId, userId);
while( nextCall.equalsIgnoreCase( "y") )
{
CallType ct = service.getConnectionForAgent( API_KEY, campaignId, agentId );
System.out.println( " You are connected to " + ct.getPhonenumber().getValue() );
nextCall = moveToNextCall();
if ( nextCall.equalsIgnoreCase( "y") ) //Requeue the agent for another call.
{
service.storeAgentResponse( API_KEY, campaignId, agentId,
new Long( ct.getCallid()).toString() ,
"SomeResponse", "SomeNotes", false );
}
else if ( nextCall.equalsIgnoreCase( "n") ) // This is the last call
{
service.storeAgentResponse( API_KEY, campaignId, agentId,
new Long( ct.getCallid()).toString() ,
"SomeResponse", "SomeNotes", true);
}
}
System.out.println("test client completed");
System.exit(0);
}
| Please enter your phone number:: 2135555511 |
| Please enter the agentID being spoken to you:: 233180 |
| You are connected to 9495555550 |
| Connect you to next customer? (y/n) y |
| You are connected to 9495555550 |
Just in case, here are the helper methods referenced above
private static String moveToNextCall()
{
String nextCall = "y";
System.out.println( "Connect you to next customer? (y/n) ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try
{
nextCall = br.readLine();
}
catch (IOException e)
{
System.out.println( "Error getting input " + e );
}
return nextCall;
}
private static String getAgentId()
{
String agentId = "";
System.out.println( "Please enter the agentID being spoken to you: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try
{
agentId = br.readLine();
}
catch (IOException e)
{
System.out.println( "Error getting input " + e );
return agentId;
}
return agentId;
}
private static String getPhoneNumber()
{
String agentPhoneNumber = "";
System.out.println( "Please enter your phone number: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try
{
agentPhoneNumber = br.readLine() + ",";
}
catch (IOException e)
{
System.out.println( "Error getting input " + e );
return agentPhoneNumber;
}
return agentPhoneNumber;
}
