Chat Availability Work in progress
Table of contents
Overview
Chat considered available, when the chat can be answered by a live agent. Chat unavailability triggers state event StateEvent.Unavailable, which will have an UnavailableReason and will be passed to the hosting App along side unavailable form / message.
If the chat is canceled by the user while in
StateEvent.InQueueor while waiting for acceptanceStateEvent.Pending, chat end will be handled asunavailable.
ChatAvailability API
Availability check
Check if your chat is available.
-
Create an
Account. -
Call
ChatAvailability.checkAvailabilityas follows:ChatAvailability.checkAvailability(account, callback = object : ChatAvailability.Callback { override fun onComplete(result: ChatAvailability.AvailabilityResult) { // Validate no error // Check isAvailable and check the UnavailabilityReason if not } })ChatAvailability.AvailabilityResultprovides the check parameters (apiKey, departmentId, etc) as well as the execution results
Availability check with department
Use ChatAvailability.checkAvailability call as before, just add the departmentId.
ChatAvailability.checkAvailability(account, departmentId, callback = object : ChatAvailability.Callback {
override fun onComplete(result: ChatAvailability.AvailabilityResult) {
// do your wonders...
}
})
❗ In order to get availability status of the different departments in your organization, make sure your api access key is not configured to work with a specific department.
Available departments
With ChatAvailability API, you can also fetch the current available departments, for your account configuration.
-
Create an
Account. -
Call
ChatAvailability.availableDepartmentsas follows:ChatAvailability.availableDepartments(account, callback = object : ChatAvailability.DepartmentsCallback { override fun onComplete(result: ChatAvailability.DepartmentsResult) { // Validate no error result.error?.let{ //handle error } ?: // get departments list result.data.takeIf { it.isNotEmpty() }?.let{ // handle departments list } } })ChatAvailability.DepartmentsResultwill contain, if no errors occurred, a list ofDepartmentitems. Each contains name, id and language of the department.