Sales Force live agent status

Multi tool use


Sales Force live agent status
I have implemented agent live availability according to documentation. Problem is according to documentation it would land in OnResult method but every time response is landed in OnCompleted method, where I am unable to retrieve agent status from async variable.
Please Guide me if I am missing something or how to get live agent availability from OnCompleted.
My code (called within HomeFragment)
private void setupChatButton() {
try {
// Build a configuration object
ChatConfiguration chatConfiguration =
new ChatConfiguration.Builder(ORG_ID, BUTTON_ID,
DEPLOYMENT_ID, LIVE_AGENT_POD)
.build();
// Create an agent availability client
AgentAvailabilityClient client = ChatCore.configureAgentAvailability(chatConfiguration);
// Check agent availability
client.check().onResult((async, state) -> {
switch (state.getStatus()) {
case AgentsAvailable: {
// Toast.makeText(context, "Available Chat", Toast.LENGTH_LONG).show();
isAgentAvailable = true;
fabChat.setBackgroundTintList(ContextCompat.getColorStateList(context, R.color.colorAccent));
break;
}
case NoAgentsAvailable: {
// Toast.makeText(context, "NOAGENTS Chat", Toast.LENGTH_LONG).show();
isAgentAvailable = false;
fabChat.setBackgroundTintList(ContextCompat.getColorStateList(context, R.color.grey));
break;
}
case Unknown: {
// Toast.makeText(context, "UNKNOWN Chat", Toast.LENGTH_LONG).show();
isAgentAvailable = false;
fabChat.setBackgroundTintList(ContextCompat.getColorStateList(context, R.color.grey));
break;
}
}
})
.onComplete(async -> {
Log.e("Home Fragment ", "Chat Call completed");
if (async.isComplete()) {
isAgentAvailable = true;
fabChat.setBackgroundTintList(ContextCompat.getColorStateList(context, R.color.colorAccent));
} else {
isAgentAvailable = false;
fabChat.setBackgroundTintList(ContextCompat.getColorStateList(context, R.color.grey));
}
// Toast.makeText(context, "Chat Completed!", Toast.LENGTH_LONG).show();
});
} catch (Exception e) {
Log.e(getContext().getClass().getSimpleName(), e.getMessage());
}
Looking for an answer drawing from credible and/or official sources.
Please provide a working solution to problem
1 Answer
1
So turns out I was missing some dependencies in my gradle files, also the update library versions require you to use minSDK 21 where I was using minSDK 19.
Following are the dependencies needed to support chat and preChat features:
implementation 'com.salesforce.service:chat-ui:3.1.0'
implementation 'com.salesforce.service:chat-core:3.1.0'
Apparently there are no references to it in official documentation.
Reference Agent
Reference Chat
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.