CA - Retrieve Report Data from the CA Engine Via WebIF
Brekeke Contact Analytics provides a web interface (WebIF) for retrieving real-time data, daily aggregated data, server information, and more.
This article introduces a script that utilizes the WebIF to fetch agent information, one of the real-time data types,and generates an HTML page. Then the HTML page can be shown at the agent veiw on CRM with an iframe tag.
Steps
Step 1. Login Brekeke CA as an administrator.
Step 2. Create a new script as “ca_rep_sample” from the Tenant menu > [Script] page.
Step 3. Select “Page” at the [Type] select box.
Step 4. Copy & paste the entire text from the ca_rep_sample.js and save.
ca_rep_sample.js
var PrintWriter = Java.type('java.io.PrintWriter');
var BaseTenant = Java.type('jp.brekeke.common.business.BaseTenant');
var getRealTimeAgentInfo = function(request,ca,user,response){
var t_name=request.getParameter('tenant');
// var user_id = user.getUser_id();
var tenant = BaseTenant.getTenant(t_name);
var params = new (Java.type("java.util.HashMap"))();
params.put("category","agent");
var result = tenant.userif('getInfo',params,'from_script');
var resultValue = result.get('resultValue');
var info = resultValue.get('info');
var recordCount = info.get('recordCount');
// var w = response.getWriter();
// var w = response.getOutputStream();
response.setContentType("text/html; charset=UTF-8");
w = new PrintWriter( response.getOutputStream() );
if(recordCount > 0){
w.println('<table border="1"><tr>');
w.println('<th nowrap>agentID</th>')
w.println('<th nowrap>agentName</th>')
w.println('<th nowrap>agentType</th>')
w.println('<th nowrap>agentOnlineDate</th>')
w.println('<th nowrap>curState</th>')
w.println('<th nowrap>sumCallOutbound</th>')
w.println('</tr>')
var records = resultValue.get('records');
for (var i=0; i<recordCount; i++) {
w.println( '<tr>' );
w.println( '<td nowrap>' );
w.println( records[i].get('agentId') );
w.println( '</td>' );
w.println( '<td nowrap>' );
w.println( records[i].get('agentName') );
w.println( '</td>' );
w.println( '<td nowrap>' );
w.println( records[i].get('agentType') );
w.println( '</td>' );
w.println( '<td nowrap>' );
w.println( ca.toYmdhms(records[i].get('agentOnlineDate')).replace("1969/12/31 16:00:00","-"));
w.println( '</td>' );
w.println( '<td nowrap>' );
w.println( records[i].get('curState') );
w.println( '</td>' );
w.println( '<td nowrap>' );
w.println( records[i].get('sumCallOutbound') );
w.println( '</td>' );
w.println( '</tr>' );
}
w.write('</table>');
w.flush();
w.close();
}
return null;
}
Step 5. Add the following parameter to the [Advanced Option] on CA to set loginkey for using the script created on the Step 4.
Syntax:
script.<script name>.loginkey=<any password>
Example:
script.ca_rep_sample.loginkey=asdfasdfadsf
Step 6. At CRM >[Workspace] >[Customers] > [Field Settings], select “HTML” type and add the iframe to retrieve the HTML page configured on CA.
Syntax:
<iframe width="100%" src="https://<CA's address and port>/ca/page?loginkey=<loginkey set at step5 >&tenant=<tenant name>&script=<script name>&function=<function name>"></iframe>
Example:
<iframe width="100%" src="https://sample.contactcenter-suite.com/ca/page?loginkey=asdfasdfadsf&tenant=nori001&script=ca_rep_sample&function=getRealTimeAgentInfo"></iframe>