In a Conversation Builder bot, you’re implementing a flow to transfer the consumer to a human agent. You need info on the status of the agent queue, so you can properly set the consumer’s expectations regarding how long the wait time is to message with an agent (and/or to properly route the consumer based on the queue status).
- Conversation Orchestrator (specifically, its Conversation Context Service or CCS)
- Conversation Builder
- LivePerson Functions
Step 1: Get your developer key
In the Developers module in Conversation Orchestrator, copy your developer key (Maven API key), so you can use it in calls to the CCS.
Step 2: Create a function that retrieves the queue health info and sends it to the CCS
Before completing this step, verify the Conversation Context Service is turned on in Bot Accounts.
In LivePerson Functions:
- Save your developer key (Maven API key) to your Secret Storage.
Create a function that retrieves the current queue info at scheduled intervals and updates a namespace in the CCS with this info. This should be a “No Event” function. You might name it “currentQueueHealth.”
You need to ensure that the CCS URL is accessible from the function. So, in the function’s Coding Details, give access to external domains. Then add
*.context.liveperson.net. Or, whitelist the domain on the settings page.
Add the code that gets the queue health info using the Messaging Current Queue API and updates the CCS with this info.
Sample code is available in our Conversation Builder repository in GitHub.
Save and deploy the function.
Test: Invoke the function to ensure it’s working. Then, verify using an API client (e.g., Postman) that the namespace and session are updated in the CCS.
Schedule the function to run every 15 minutes (or as per your requirements) so that the queue health info remains fresh.
At this point, you now have a session within the CCS that’s updated with a reasonable approximation of the current queue health, including info on the estimated wait time.
Step 3: In the bot, retrieve the queue health info from the CCS and use it as desired
In Conversation Builder, within an interaction in the bot, query the CCS for the queue health info, and send the consumer a message to set their expectations on wait times accordingly. Sample code is below.
Add the following code to the interaction’s Pre-Process Code. In the
botContext.getGlobalContextData method below, replace “messaging-operations-api” with the namespace value from your LivePerson function:
var e = botContext.getGlobalContextData('messaging-operations-api', 'skillsMetrics'); var skillId = botContext.getBotVariable('skillId'); var awt = e[skillId].avgWaitTimeForAgentAssignment_AfterTransferFromAgent; botContext.setBotVariable('awt', awt, true, false);
LivePerson provides a number of APIs that are designed to be used with reporting dashboards to inform users about queue status, shift status of agents, etc. However, these APIs are not intended for use at conversational scale. Doing so could be detrimental to the stability of our platform.
This use case demonstrates a viable and responsible alternative to using these APIs directly in every conversation. In this solution, several Conversational Cloud services work together to regularly cache the needed data. The info is then made accessible via the CCS, which is a service that can properly handle a large volume of API calls across a large number of conversations.
Interested in this use case? Want more details? Join the LivePerson Developer Forum and visit this post.