In this workflow, you'll learn how to create a conditional flow that checks if agents are available. While the bot builder can verify if a message arrived during business hours, it doesn't automatically detect agent availability. To achieve this, you need to create an API connection that detects the number of online agents.
This article describes functionality available only to customers who had a drafted or published AI agent as of February 2, 2025. For information about equivalent functionality in the AI agents - Advanced add-on, see Building dialogues for AI agents - Advanced.
The workflow includes the steps below.
- Step 1: Create a bearer token
- Step 2: Create an API connection
- Step 3: Create a conditional statement in the bot builder
Step 1: Create a bearer token
Create a bearer token for the Zendesk Chat API. See Chat API tutorial: Generating an OAuth token.
Step 2: Create an API connection
Create an API connection:
- In Admin Center, navigate to Apps and integrations > Connections and click Create connection
- Select the Bearer token authentication type and enter the token created in Step 1
- Enter the allowed domain value
rtm.zopim.com
Step 3: Create a conditional statement in the bot builder
- In Admin Center, navigate to AI > AI agents and select your bot
- Go to the Intents tab
- In the bot builder, add the Make API call step with the below API details:
- In the Request method, select GET
- Enter the Endpoint URL:
https://rtm.zopim.com/stream/agents/agents_online - In the Authentication field, select the connection created in Step 2
- Click Make API call to test the call and return status code 200
- Under the Variables tab in the Key column, expand Content then Data
- Find agents_online and click Save
-
The Add variable popup appears. Click Save to create the
agents_onlinevariable.
- Under API call successful, add a Branch by condition step with the If this and Else options
- Open the If this branch and rename it to Online, then click Add condition
-
Add the condition, Variables > agents_online | Is not | 0
- You successfully created a condition that checks if there are live agents in Chat. Complete the flow with your desired steps and publish the bot.
Note: The real-time API used above is available to Enterprise plans.