How to configure live agent functionality using Zendesk?

Smriti Bajaj
3 min readNov 7, 2020

--

If you haven’t read my previous article on Zendesk chatbot, please do for a better understanding of this one.

To enable live agents, it’s advised to create a department such that for payment related stuff, we can have a payments department, likewise for customer support, orders etc. How to create a department?

Once department(s) is(are) created, we can move ahead with the technicalities. So, whenever a visitor says, “Connect me to a live agent” or if the chatbot is unable to map the intents(NLP) for visitor queries, then we can transfer the visitor to a live agent belonging to a particular department.

The transfer depends on -

  • Get department query which tells us the status(Online, Away, Offline) of the agents present in the department. Suppose, if any agent is online, the department becomes online, we fetch it’s Id and then we can initiate a transfer through the transfer mutation.
const transferToDepartmentQuery = {
payload: {
query: `mutation {
transferToDepartment(
channel_id: "${channelToBeTransferred}",
department_id: "${onlineDepartment.id}") {
success
}
}`
},
type: "request",
id: REQUEST_ID.TRANSFER_TO_DEPARTMENT
};
webSocket.send(JSON.stringify(transferToDepartmentQuery));
  • Channel Id of the communication channel between the visitor and the agent available in the transferred department.

Depending on the requirement, we can either allow a bot-to-agent handoff by making the bot leave the conversation or stop the bot from backend to halt answering when an agent has joined the chat. In this article, we’ll discuss the former approach.

To allow the bot to leave the conversation, we should first use the leaveChannel mutation. This mutation requires the channel Id of the channel where a visitor is communicating with an API client/agent who is thrown out of the conversation.

const leaveChannel = {
payload: {
query: `mutation {
leaveChannel(
channel_id: "${channelToBeTransferred}"
) {
success
}
}`
},
type: "request",
id: REQUEST_ID.LEAVE_CHANNEL
};
webSocket.send(JSON.stringify(leaveChannel));

Next, we should start listening to the activity after the transfer with the help of listenVisitorChannel. The activities include, member join log and member leave log. With this approach, once a live agent leaves, we can allow the bot to continue the conversation with the visitor.

const listenVisitorChannel = {
payload: {
query: `mutation {
listenVisitorChannel(
channel_id: "${channelToBeTransferred}"
) {
success
}
}`
},
type: "request",
id: REQUEST_ID.LISTEN_VISITOR_CHANNEL
};
webSocket.send(JSON.stringify(listenVisitorChannel));

Now we can see that when Bank Bot leaves the chat, a live agent, Sarah, joins in while Bank Bot doesn’t interrupt.

Source: https://web-assets.zendesk.com/images/p-chatbot/chatbot-real-2X.png

However, the visitors might have to wait for a long time to chat with a live agent. As a real time status of their waiting queue, Zendesk displays a queue position reflecting the visitor’s position with respect to other visitors waiting to chat with a live agent in the requested department.

Source: https://zen-marketing-documentation.s3.amazonaws.com/docs/en/chat_standalone_offline_form.png

I hope I have explained the important bits of the implementation. For any relevant queries, you can comment below.

Tips-

  • You can record channel activity by subscribing to the channel activity subscription. — https://zendesk.github.io/conversations-api/
  • Initiate a transfer only to a particular department.
  • Messages from visitors are broadcasted to all the available(online) agents in the department.

References-

https://develop.zendesk.com/hc/en-us/articles/360001331787-Getting-started-with-the-Chat-Conversations-API

If you liked the content, please clap. It’s a really good exercise :)

Thanks for reading! ❤ #CodeEveryday

--

--