Messaging recipe: Checking agent availability during an AI agent conversation (Legacy)

<body>
<p id="docs-hc-snippet" style="display: none;">In this recipe, you’ll use the bot builder'sMake API callandBranch by conditionsteps to branch an existing AI agent answer based on the number of online agents at the time of the conversation. TheMake API callstep gets a count of the current online agents by calling the Zendesk Real Time Chat REST API'sGet Agent Status Countendpoint. TheBranch by conditionstep then uses the count to branch the answer's flow.</p>
<div class="article-banners">
<div id="docs-wmp-link">
<a href="https://support.zendesk.com/hc/en-us/articles/5411234991258-plan" rel="noopener" target="_blank">What's my plan?</a>
</div>
<div class="article-banner" id="suite_all">
<table>
<tbody>
<tr>
<td>
<strong>All Suites</strong>
</td>
<td>Team, Growth, Professional, Enterprise, or Enterprise Plus</td>
</tr>
</tbody>
</table>
</div>
<div class="article-banner" id="support_with_msg_all">
<table>
<tbody>
<tr>
<td>
<strong>Support with</strong>
</td>
<td>Live chat and messaging Team, Professional, or Enterprise</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="body">
<div class="p" id="topic_ddp_m2r_kxb__note_owy_qnb_hbc">
<div class="note attention" id="topic_ddp_m2r_kxb__note_yng_dh2_f2c">
<span class="attentiontitle"></span> <span class="ph">This article describes functionality that moved into legacy
status on February 2, 2025. On December 10, 2026, this functionality will no longer
be available. For more information, see <a href="https://support.zendesk.com/hc/en-us/articles/10487730059034" target="_blank">this announcement</a>.</span>
</div>
The bot builder's <strong class="ph b">Add business hours condition</strong> step lets you branch
an AI agent's answers based on your business hours. However, it can't branch a
conversation based on agent availability.</div>
<p class="p">In this recipe, you’ll use the bot builder's <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4572971586586" target="_blank">Make API call</a> and <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/5280598023450" target="_blank">Branch by condition</a> steps to branch an existing AI agent answer based on the
number of online agents at the time of the conversation. The <strong class="ph b">Make API call</strong> step
gets a count of the current online agents by calling the Zendesk Real Time Chat REST
API's <a class="xref" href="https://developer.zendesk.com/api-reference/live-chat/real-time-chat-api/rest/#get-agent-status-count" target="_blank">Get Agent Status Count</a> endpoint. The <strong class="ph b">Branch by
condition</strong> step then uses the count to branch the answer's flow.</p>
<div class="p">
<div class="note" id="topic_ddp_m2r_kxb__note_eng_vkp_2fc">
<span class="notetitle">Note:</span> If your account was created after November 11, 2021, you
can't use the use the <a class="xref" href="https://developer.zendesk.com/api-reference/live-chat/real-time-chat-api/rest/#get-agent-status-count" target="_blank">Get Agent Status Count</a> endpoint. Instead, use the Agent
Availability API's <a class="xref" href="https://developer.zendesk.com/api-reference/agent-availability/agent-availability-api/agent_availabilities/#get-agent-availabilities" target="_blank">Get agent availabilities</a> endpoint.</div>
</div>
<p class="p">You can use this setup to send customized AI agent messages before creating a ticket using the
<strong class="ph b">Transfer to agent</strong> step. These messages can help set better customer
expectations around wait or response times.</p>
<p class="p"><img class="image img-screenshot" id="topic_ddp_m2r_kxb__image_v24_3sr_kxb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/no-agent-recipe-example.gif" width="300"></p>
<div class="p">The recipe involves the following tasks:
<ul class="ul" id="topic_ddp_m2r_kxb__ul_lt2_x3r_kxb">
<li class="li"><a class="xref" href="#topic_en5_x3r_kxb">Task 1: Checking your setup</a></li>
<li class="li"><a class="xref" href="#topic_s1l_pkr_kxb">Task 2: Creating an API connection</a></li>
<li class="li"><a class="xref" href="#topic_r1r_zlr_kxb">Task 3: Retrieving agent availability</a></li>
<li class="li"><a class="xref" href="#topic_gm3_14r_kxb">Task 4: Branching based on agent availability</a></li>
<li class="li"><a class="xref" href="#id_elm_lqr_kxb">Task 5: Publishing your updated AI agent</a></li>
<li class="li"><a class="xref" href="#id_ad5_nqr_kxb">Task 6: Testing your changes</a></li>
</ul>
</div>
</div>
<div aria-labelledby="ariaid-title2" class="topic nested1" id="topic_en5_x3r_kxb">
<h2 class="title topictitle2" id="ariaid-title2">Task 1: Checking your setup</h2>
<div class="body">
<div class="p">To complete this recipe, you'll need the following:
<ul class="ul" id="topic_en5_x3r_kxb__ul_kbk_bjr_kxb">
<li class="li">A Zendesk account with a published AI agent. If you are on a Suite Enterprise or Enterprise Plus
plan, you can use a <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408844075930" target="_blank">sandbox testing environment</a> to
test the AI agent before using it in production. <p class="p">To set up an AI agent on
a web and mobile messaging channel, see <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408824263578" target="_blank">Creating an AI agent for your web and mobile
channels</a>.</p>
</li>
<li class="li">An OAuth access token for the Zendesk Chat API. To create this token, see
<a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408828740762" target="_blank">Chat API tutorial: Generating an OAuth
token</a>.</li>
</ul>
</div>
</div>
</div>
<div aria-labelledby="ariaid-title3" class="topic nested1" id="topic_s1l_pkr_kxb">
<h2 class="title topictitle2" id="ariaid-title3">Task 2: Creating an API connection</h2>
<div class="body">
<p class="p">To start, create an API connection to store your OAuth access token for the Chat API. Your AI
agent can use this connection to authenticate calls to the API.</p>
<div class="p">
<strong class="ph b">To create the connection</strong>
<ol class="ol" id="topic_s1l_pkr_kxb__ol_tqz_tkr_kxb">
<li class="li"><span class="ph">In <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4581766374554#topic_hfg_dyz_1hb" target="_blank">Admin Center</a>, click <img class="image" id="topic_s1l_pkr_kxb__d9e2105" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/ac_apps_integrations_icon.png">
<strong class="ph b">Apps and integrations</strong> in the sidebar, then select <strong class="ph b">Connections &gt;
Connections</strong>.</span></li>
<li class="li">Click
<strong class="ph b">Create connection</strong>.</li>
<li class="li">Select the
<strong class="ph b">Bearer token</strong>
authentication type.</li>
<li class="li">For
<strong class="ph b">Connection name</strong>, enter "zendesk_chat_api_oauth_token".</li>
<li class="li">For <strong class="ph b">Token</strong>, enter your OAuth access token (see <a class="xref" href="#topic_en5_x3r_kxb">Task 1: Checking your setup</a>).</li>
<li class="li">For
<strong class="ph b">Allowed domain</strong>, enter "rtm.zopim.com".</li>
<li class="li">Click
<strong class="ph b">Save</strong>
to create the connection.</li>
</ol>
</div>
</div>
</div>
<div aria-labelledby="ariaid-title4" class="topic nested1" id="topic_r1r_zlr_kxb">
<h2 class="title topictitle2" id="ariaid-title4">Task 3: Retrieving agent availability</h2>
<div class="body">
<p class="p">Next, add a <strong class="ph b">Make API call</strong> step to an existing answer in your AI agent. This step gets a
current count of online agents from the Real Time Chat API's <a class="xref" href="https://developer.zendesk.com/api-reference/live-chat/real-time-chat-api/rest/#get-agent-status-count" target="_blank">Get Agent Status Count</a> endpoint.</p>
<p class="p"><strong class="ph b">To add the Make API call step</strong></p>
<ol class="ol">
<li class="li"><span class="ph">In <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4581766374554#topic_hfg_dyz_1hb" target="_blank">Admin Center</a>, click <img class="image" id="topic_r1r_zlr_kxb__d9e1351" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/icon_ai.png">
<strong class="ph b">AI</strong> in the sidebar, then select <strong class="ph b">AI agents &gt; AI agents</strong>.</span></li>
<li class="li">Click the AI agent you want to update, then click the answer you want to
update.</li>
<li class="li">In bot builder, add a step to the desired location in the answer's
flow.</li>
<li class="li">Under <strong class="ph b">Choose step</strong>, select <strong class="ph b">Make API Call</strong>.</li>
<li class="li">Enter <strong class="ph b">Get agent availability</strong> as the <strong class="ph b">Name</strong>.</li>
<li class="li">Under <strong class="ph b">API details,</strong> enter
<code class="ph codeph">https://rtm.zopim.com/stream/agents/agents_online</code> as the
<strong class="ph b">Endpoint URL.</strong>
</li>
<li class="li">In <strong class="ph b">Authentication</strong>, select the <strong class="ph b">zendesk_chat_api_oauth_token</strong>
connection.</li>
<li class="li">To test the API request, click <strong class="ph b">Make API call</strong>.</li>
<li class="li">Under <strong class="ph b">Test Data</strong>, enter <strong class="ph b">Melbourne, AU</strong> as the <strong class="ph b">Location</strong>.</li>
<li class="li">Click <strong class="ph b">Make API call</strong>.</li>
<li class="li">Save the following variable using its default name: <ul class="ul" id="topic_r1r_zlr_kxb__ul_jty_4kl_nwb">
<li class="li">
<strong class="ph b">content</strong> &gt; <strong class="ph b">data</strong> &gt; <strong class="ph b">agents_online</strong>
</li>
</ul>
</li>
<li class="li">(Optional) Add a step under the <strong class="ph b">Get agent availability</strong> step’s <strong class="ph b">API call
failed</strong> branch. This step runs if the Get Agent Status Count request
fails.</li>
</ol>
</div>
</div>
<div aria-labelledby="ariaid-title5" class="topic nested1" id="topic_gm3_14r_kxb">
<h2 class="title topictitle2" id="ariaid-title5">Task 4: Branching based on agent availability</h2>
<div class="body">
<p class="p">Next, add a
<strong class="ph b">Branch by condition</strong>
step to branch the answer's flow based on the
value of the
<strong class="ph b">agents_online</strong>
variable.</p>
<p class="p"><strong class="ph b">To add the Branch by condition step</strong></p>
<ol class="ol" id="topic_gm3_14r_kxb__ol_w55_c4r_kxb">
<li class="li">In the bot builder, add a step in the
<strong class="ph b">Get agent availability</strong>
step's
<strong class="ph b">API call successful</strong>
branch.</li>
<li class="li">Under
<strong class="ph b">Choose step</strong>, select
<strong class="ph b">Branch by condition</strong>.</li>
<li class="li">Enter
<strong class="ph b">Check agent availability</strong>
as the
<strong class="ph b">Name</strong>.</li>
<li class="li">In the
<strong class="ph b">If this</strong>
branch, enter
<strong class="ph b">Agents are online</strong>
as the
<strong class="ph b">Name</strong>.</li>
<li class="li">In the
<strong class="ph b">If this</strong>
branch, click
<strong class="ph b">Add condition</strong>. Configure the
condition as follows:
<ul class="ul" id="topic_gm3_14r_kxb__ul_e3r_spr_kxb">
<li class="li">
<strong class="ph b">Variable</strong>: agents_online</li>
<li class="li">
<strong class="ph b">Operator</strong>: Is not</li>
<li class="li">
<strong class="ph b">Value</strong>: 0</li>
</ul>
</li>
<li class="li">Click
<strong class="ph b">Add</strong>.</li>
<li class="li">Add any desired steps under the
<strong class="ph b">Agents are online</strong>
and
<strong class="ph b">Else</strong>
branches. Steps under the
<strong class="ph b">Agents are online</strong>
branch run when the
<a class="xref" href="https://developer.zendesk.com/api-reference/live-chat/real-time-chat-api/rest/#get-agent-status-count" target="_blank">Get Agent Status Count</a>
request
indicates one or more agents are online. Steps under the
<strong class="ph b">Else</strong>
branch run
when the request indicates no agents are online.</li>
</ol>
</div>
</div>
<div aria-labelledby="ariaid-title6" class="topic nested1" id="id_elm_lqr_kxb">
<h2 class="title topictitle2" id="ariaid-title6">Task 5: Publishing your updated AI agent</h2>
<div class="body">
<p class="p">When you're done editing the answer, you can publish the updated AI agent.</p>
<div class="p">
<strong class="ph b">To publish the AI agent</strong><ol class="ol" id="id_elm_lqr_kxb__ol_rkw_jml_nwb">
<li class="li">Click <strong class="ph b">Done</strong> in the upper right corner of the bot builder.</li>
<li class="li">On the AI agent page, click <strong class="ph b">Publish AI agent</strong>.</li>
<li class="li">Click <strong class="ph b">Publish</strong>.</li>
</ol>
</div>
</div>
</div>
<div aria-labelledby="ariaid-title7" class="topic nested1" id="id_ad5_nqr_kxb">
<h2 class="title topictitle2" id="ariaid-title7">Task 6: Testing your changes</h2>
<div class="body">
<p class="p">After you publish your changes, you can test the updated answer by using one of its training
phrases in a conversation with the updated AI agent. For more information about
testing AI agents, see <a class="xref" href="https://support.zendesk.com/hc/en-us/articles/4408835784602" target="_blank">Testing the end user's messaging experience</a>.</p>
<p class="p"><img class="image img-screenshot" id="id_ad5_nqr_kxb__image_gt2_ksr_kxb" src="https://zen-marketing-documentation.s3.amazonaws.com/docs/en/no-agent-recipe-example.gif" width="300"></p>
</div>
</div>
<script id="docs-schema-markup" type="application/ld+json">{
"@context": "https://schema.org",
"@type": "TechArticle",
"@id": "https://support.zendesk.com/hc/en-us/articles/5706660392602",
"url": "https://support.zendesk.com/hc/en-us/articles/5706660392602",
"headline": "Messaging recipe: Checking agent availability during an AI agent conversation (Legacy)",
"description": "You can configure an AI agent to check real-time agent availability during conversations by making API calls and branching responses based on the number of online agents to manage customer expectations.",
"articleSection": "Using bot builder to create answers (Legacy)",
"datePublished": "2023-05-16T17:39:44+00:00",
"dateModified": "2026-05-12T16:37:23.014052+00:00",
"inLanguage": "en-US",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://support.zendesk.com/hc/en-us/articles/5706660392602"
},
"author": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"publisher": {
"@type": "Organization",
"name": "Zendesk",
"@id": "https://www.zendesk.com"
},
"isPartOf": {
"@type": "WebSite",
"name": "Zendesk Help",
"@id": "https://support.zendesk.com/hc/"
},
"about": {
"@type": "SoftwareApplication",
"name": "Zendesk",
"@id": "https://www.zendesk.com",
"softwareAddOn": {
"@type": "SoftwareApplication",
"name": "Live chat and messaging",
"@id": "https://support.zendesk.com/hc/en-us/sections/4405298882330"
}
}
}</script>
</body>