Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

Zoho Voice SDK | Details and Configuration

Java SDK

Introduction


Zoho Voice is a cloud-based telephony service using which you can make and receive calls. Zoho Voice also provides SDKs for developers to integrate their app with Zoho Voice.

SDK Details and Configuration


Download Refresh Token


Step 1 : Login https://voice.zoho.com 
Step 2 : Please click the "java sdk refresh token" button under the user profile.

Step 3 : Store refresh token in DB.


ZohoVoiceSDK Structure 


Source jar for SDK

(jar needs to be copied to your lib directory)


ZohoVoiceSDK.jar

available in lib/ZohoVoiceSDK.jar


Needed lib for SDK

(Dependencies folder needs to be copied to your product zip)


httpcore-4.4.5.jar,  json,  httpclient-4.5.2.jar, commons-logging-1.1.1.jar

available in lib/thirdParty_Jars


java docs for SDK




Java SDK

SDK Object


SDK Object Creation 

(mandatory)


ZohoVoiceSDK zohoVoiceSDK = new ZohoVoiceSDK(DC dc  ,  String refreshToken);

(ZohoVoiceSDK object created only in server start)


Default DataCenter : DC.US

Allowed DataCenter : 

DC.US


Set Proxy


zohoVoiceSDK.setViaProxy(boolean)


Default value : false

Zoho Voice API Object 

Zoho Voice API Object 

API object creation 

(mandatory)


ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);


zohoVoiceSDK was created in the above step.




Features of SDK

Agents

Import Agents

Import agents from your app to Zoho Voice.
  1.  // Create import object
  2.  ImportAgents importAgents = new ImportAgents();

  3.  // Create agentsinfo object 
  4.  AgentsInfo agentsInfo = new AgentsInfo();
  5.  agentsInfo.setName("ZohoVoice");
  6.  agentsInfo.setEmailId("abc@sample.com");
  7.  agentsInfo.setDepartmentName("ZVoice");
  8.  // Using the associated number api allows to associate phone numbers.  
  9.  JSONArray associatedNumber = new JSONArray(); // Collection of phone numbers
  10.  agentsInfo.setAssociatedNumbers(associatedNumber);

  11.  // Multiple agentsInfo object
  12.  ArrayList<AgentsInfo> agentsInfos = new ArrayList<AgentsInfo>();
  13.  agentsInfos.add(agentsInfo);

  14.  importAgents.setAgentsInfo(agentsInfos);

  15.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  16.  ImportAgentsResponse response = zohoVoiceAPI.importAgents(importAgents);

  17.  // Response Object
  18.  String status = response.getStatus();
  19.  String statusCode = response.getStatusCode();
  20.  String errorMessage = response.getErrorMessage();
  21.  JSONObject responseInJSON = response.getJSONObject();
  22.  ArrayList<Agents> agents = response.getAgents();
  23.  Agents agent = agents.get(0);
  24.  agent.getAgentId();
  25.  agent.getAgentNumber();
  26.  agent.getDepartmentName();
  27.  agent.getEmailId();
  28.  agent.getExtension();
  29.  agent.getName();
  30.  agent.getOnlineStatus();


Get Login Details

Fetch the login details by inputting agent ID and email address.
  1.  GetAgentLoginDetail getAgentLoginDetail = new GetAgentLoginDetail();
  2.  // Set agentId or emailId .
  3.  getAgentLoginDetail.setAgentId("agentId");
  4.  getAgentLoginDetail.setEmailId("emailId");

  5.  ZohoVoiceAPI zVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  6.  GetAgentLoginDetailResponse response = zVoiceAPI.getAgentLoginDetail(getAgentLoginDetail);

  7.  // Response Object
  8.  String status = response.getStatus();
  9.  String statusCode = response.getStatusCode();
  10.  String errorMessage = response.getErrorMessage();
  11.  JSONObject responseInJSON = response.getJSONObject();
  12.  JSONObject loginDetails = response.getLoginDetail();
  13. //LoginDetails has the credentials to log in to the dialer


Get Agents

Input agent ID or search key and get the agent list.
  1.  GetAgents getAgents = new GetAgents();
  2.  getAgents.setAgentId("agentId");
  3.  getAgents.setSearchKey("searchKey");
  4.  getAgents.setFromIndex(2);
  5.  getAgents.setToIndex(10);

  6.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK,);
  7.  GetAgentsResponse response =  zohoVoiceAPI.getAgents(getAgents);

  8.  // Response Object
  9.  String status = response.getStatus();
  10.  String statusCode = response.getStatusCode();
  11.  String errorMessage = response.getErrorMessage();
  12.  JSONObject responseInJSON = response.getJSONObject();
  13.  ArrayList<Agents> agents = response.getAgents();
  14.  Agents agent = agents.get(0);
  15.  agent.getAgentId();
  16.  agent.getAgentNumber();
  17.  agent.getDepartmentName();
  18.  agent.getEmailId();
  19.  agent.getExtension();
  20.  agent.getName();
  21.  agent.getOnlineStatus();


Associated Number

To get details about associated numbers and respective agents.

  1.  GetAssociatedNumbers getAssociatedNumbers = new GetAssociatedNumbers();
  2.  getAssociatedNumbers.setAgentId("agentId");

  3.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  4.  GetAssociatedNumbersResponse response = zohoVoiceAPI.getAssociatedNumbers(getAssociatedNumbers);

  5.  // Response Object
  6.  String status = response.getStatus();
  7.  String statusCode = response.getStatusCode();
  8.  String errorMessage = response.getErrorMessage();
  9.  JSONObject responseInJSON = response.getJSONObject();
  10.  ArrayList<NumberInfo> outgoingNumbers = response.getOutgoingNumbers();
  11.  ArrayList<NumberInfo> incomingNumbers = response.getIncomingNumbers();
  12.  NumberInfo incomingNumber = incomingNumbers.get(0);
  13.  Long numberId = incomingNumber.getNumberId();
  14.  String displayName = incomingNumber.getDisplayName();
  15.  String telNumber = incomingNumber.getTelNumber();
  16.  String countryCode = incomingNumber.getCountryCode();
  17.  String didNumber = incomingNumber.getDidNumber();


Regenerate Key

To regenerate the agent-specific key. This key and password are used to log in to the Dialer.

  1.  RegenerateKey regenerateKey = new RegenerateKey();
  2.  regenerateKey.setAgentId("AgentId");
  3.  regenerateKey.setOldAgentKey("oldAgentPassword");

  4.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  5.  RegenerateKeyResponse response = zohoVoiceAPI.regenerateKey(regenerateKey);

  6.  // Response Object
  7.  String status = response.getStatus();
  8.  String statusCode = response.getStatusCode();
  9.  String errorMessage = response.getErrorMessage();
  10.  JSONObject responseInJSON = response.getJSONObject();


Regenerate Password

To regenerate the agent-specific password.

  1.  RegeneratePassword regeneratePassword = new RegeneratePassword();
  2.  regeneratePassword.setAgentId("AgentId");
  3.  regeneratePassword.setEmailId("abc@sample.com");
  4.  regeneratePassword.setOldPassword("oldPassword");

  5.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  6.  RegeneratePasswordResponse response = zohoVoiceAPI.regeneratePassword(regeneratePassword);

  7.  // Response Object
  8.  String status = response.getStatus();
  9.  String statusCode = response.getStatusCode();
  10.  String errorMessage = response.getErrorMessage();
  11.  JSONObject responseInJSON = response.getJSONObject();

Resend Mail

To resend the email that contains the regenerated password.

  1.  ResendMail resendMail = new ResendMail();
  2.  resendMail.setAgentId("AgentId");
  3.  resendMail.setEmailId("abc@sample.com");

  4.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  5.  ResendMailResponse  response = zohoVoiceAPI.resendMail(resendMail);

  6.  // Response Object
  7.  String status = response.getStatus();
  8.  String statusCode = response.getStatusCode();
  9.  String errorMessage = response.getErrorMessage();
  10.  JSONObject responseInJSON = response.getJSONObject();

Call Transfer - Agent or Queue List

Shows a list of agents or queue to whom a call needs to be transferred.

  1.  TransferAgentOrQueue transferAgentOrQueue = new TransferAgentOrQueue();
  2.  transferAgentOrQueue.setSearchText("searchText");
  3.  transferAgentOrQueue.setFromIndex(2);
  4.  transferAgentOrQueue.setToIndex(10);
  5.  transferAgentOrQueue.setIncludeQueues(true);

  6.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  7.  TransferAgentOrQueueResponse response = zohoVoiceAPI.transferAgentOrQueue(transferAgentOrQueue);

  8.  // Response Object
  9.  String statusCode = response.getStatusCode();
  10.  String errorMessage = response.getErrorMessage();
  11.  JSONObject responseInJSON = response.getJSONObject();
  12.  ArrayList<Agents> agents = response.getAgents();
  13.  Agents agent = agents.get(0);
  14.  agent.getAgentId();
  15.  agent.getAgentNumber();
  16.  agent.getDepartmentName();
  17.  agent.getEmailId();
  18.  agent.getExtension();
  19.  agent.getName();
  20.  agent.getOnlineStatus();


Logs

Get Call Logs

Fetch the call logs from Zoho Voice.

  1.  GetCallLogs getCallLogs = new GetCallLogs();
  2.  getCallLogs.setFromIndex(1);
  3.  getCallLogs.setToIndex(20);
  4.  getCallLogs.setFromDate("2021-09-27");
  5.  getCallLogs.setToDate("2021-09-30");
  6.  getCallLogs.setAllCountry(true);
  7.  getCallLogs.setMinCredits(1.0);
  8.  getCallLogs.setMaxCredits(10.0);
  9.  getCallLogs.setMinDuration(20); // min duration in secs
  10.  getCallLogs.setMaxDuration(30);// max duration in secs
  11.  // agent id get from Get Agents
  12.  ArrayList<String> agnetIds = new ArrayList<String>();
  13.  agnetIds.add("615000001010123");
  14.  getCallLogs.setAgnetIds(agnetIds);
  15.  // call types
  16.  ArrayList<String> callTypes = new ArrayList<String>();
  17.  callTypes.add("incoming");
  18.  callTypes.add("outgoing");
  19.  callTypes.add("missed");
  20.  callTypes.add("forward");
  21.  callTypes.add("bridged");
  22.  getCallLogs.setCallType(callTypes);

  23.  ZohoVoiceAPI zohoVoiceAPI = new ZohoVoiceAPI(zohoVoiceSDK);
  24.  GetLogsResponse getLogsResponse = zVoiceAPI.getCallLogs(getCallLogs);

  25.  // Response 
  26.  String status = getLogsResponse.getStatus();
  27.  String statusCode = getLogsResponse.getStatusCode();
  28.  String errorMessage = getLogsResponse.getErrorMessage();
  29.  JSONObject responseInJSON = getLogsResponse.getJSONObject();
  30.  ArrayList<CallLog> logs = getLogsResponse.getCallLogs();
  31.  CallLog callLog = logs.get(0);
  32.  String agentName = callLog.getAgentName();
  33.  String callDuration = callLog.getCallDuration();
  34.  String callerIdName = callLog.getCallerIdName();
  35.  String callerIdNumber = callLog.getCallerIdNumber();
  36.  String callType = callLog.getCallType();
  37.  String destinationNumber = callLog.getDestinationNumber();
  38.  String endTime = callLog.getEndTime();
  39.  String startTime = callLog.getStartTime();

Helpful?00
Updated: 2 years ago
Share :