➕ Checking for Agent Availability in Zendesk Messaging

Sometimes you want to let your customers know if agents are available before they try to reach out. This article will show you how to do it (on any Zendesk plan!)

➕ Checking for Agent Availability in Zendesk Messaging

Zendesk Messaging is a so called Conversational channel and is asynchronous by design. This means that the customer sending the messaging and an agent reading the message aren't necessarily things that happen at the same time. A customer can leave a message and close their browser window. When an agent reads the message the customer gets an email and can then choose to resume the conversation within the chat widget, or reply to the email and continue that way.

It's a nice feature but it often doesn't meet a customers' expectations. Some customers see the widget and assume an agent will reply to them immediately. They invested time to start the conversation and letting them know no-one can reply right now is a bad experience if that alert only appears whenever they try to contact an agent.

A while back I posted this link in one of my Roundup articles, showcasing how you can use the Zendesk Chat API to let users in your Zendesk Widget know if an Agent was available or not, which could be used to set expectations from the get go.

Messaging recipe: Checking agent availability during a bot conversation
What’s my plan? The conversation bot builder’s Add business hours condition step lets you branch a conversation bot’s answers based on your business hours. However, it can’t branch a…

.

At the time I didn't notice that this flow was limited to Enterprise users only and used a fairly complex (and old) API flow based on Zopim chat. However, with the new Agent Status feature in Agent Workspace and Omnichannel Routing there's now a different way to set and get Agent availabilities.

Getting agent availability

The new Agent Status and availability feature gives agent a central place to manage with which channels they can or want to interact, and gives colleagues and managers insight in work load and availability of their teams. It allows them to strategically make channels available, and balance the load between ticketing, conversations and voice channels.

This API call to the Agent Availability endpoint returns the status of all agents across all default and custom statuses. By adding a filter we can narrow this down to all agents that have an online status for Messaging across all agent statuses.

GET 'https://domain.zendesk.com/api/v2/agent_availabilities?filter[channel_status]=messaging%3Aonline'

The returned data[] object returns an array of each available agent.

{
    "links": {},
    "data": [
        {
            "type": "agent_availabilities",
            "id": "agent_availabilities|362397585840",
            ...
        }
    ],
    "included": [
        ...
    ],
    "meta": {
        "has_more": false
    }
}

And when no one is online it returns an empty array:

{
    "links": {},
    "data": [],
    "included": [],
    "meta": {
        "has_more": false
    }
}

Since we are only interested if someone is online, we can just check on the availability of elements within the data array. If no items are available, we are offline, when e.g. data[0].id exists, we know there is at least one person online.

👨‍💻
You can always use the API to nuance this availability a bit more. You could for example use the &filter[work_items_count]=messaging:3 parameter to only return agents who are online and have less than three active conversations going on.

However you decide to filter, if the array ends up empty, you know no agents are. available.

Setting up the Zendesk Bot