How do I create a condition in the bot builder to check when no agents are available?
The bot builder has a step to check if the message came within or outside business hours, but it doesn't have the option to know if the agents are offline.
Creating a conditional flow based on agent availability and not business hours can be achieved through a custom solution that requires some configuration. This recipe has three major components.
1. Create a bearer token
Create a bearer token for the Zendesk Chat API by following the steps in the article: Chat API tutorial: Generating an OAuth token.
2. Create an API connection
Create an API connection by following the steps provided in the article: Creating API connections for the bot builder.
While creating a connection ensure to complete the following:
- Select the option Bearer token and enter the token created in step 1
- Enter the allowed domain value:
3. Create a conditional statement in the bot builder
- In Admin Center, navigate to Bots and automation and select your bot.
- Under the selected bot, choose the answer intent.
- Add the HTTP API call step with details:
- Enter the Endpoint URL: https://rtm.zopim.com/stream/agents/agents_online
- Under Authentication, select the connection created in Step 2.
- Click on Make an API call to test the call and return status code 200.
- Under the Variable tab, select Open content, then Data.
- In Data, you will see agent_online. Click Save adjacent to this and save the variable as is. Zendesk creates a variable as
agent_onlinewhich is utilized in the next step.
- Under API Successful flow, create a conditional step with options Online and Else.
- Open the Conditional step, and under Options configure the option as Online.
- Add the condition:
agent_online IS NOT 0
- Save and publish the bot.
You have successfully created a condition in your bot to check if agents are available.