Agent Console API
  • 14 Jul 2022
  • 3 Minutes to read
  • Dark
    Light

Agent Console API

  • Dark
    Light

Article summary

Introduction

The extension area provided by the agent console is called widget here. You can extend the agent console through the widgets as below:

In order to enhance the extensibility of agent console, we also provide the following public objects.

How to Use API

You must invoke api through SDK, which provides different methods, such as listening to events using the on method. Which method is used to call the api? It it desided by the providor.

Learn more for SDK view here.

Notification

  1. Send a notification to Agent Console

Params:

NameTypeDescription
titlestringDefine title for message
messagestringThe content of message
leftTabIdstringIt is optional. The Id of left tab in the Nav bar, system tab Id: visitor, chat, tickets and agent. If it is extensive tab, use the widgetId instead. If you config it, navigate to the specific tab when clicking pop up notification

Return: No.

Example:

client.do("agentconsole.notification.notify", {
  title: "new-message",
  message: "new message",
});

Widgets

Actions

  1. Get all widgets that configured by current app when executing this API.

Params: No.

Return: Wedget list there you configured in the manifest.

Example:

const client = APPClient.init();
client.get("agentconsole.widgets").then(function (widgets) {
  // do stuff
});
  1. Send the message to others widget

Params:

NameTypeDescription
tostringWidget Id which will be received this message.
dataanyThe message content. It supports base data type and plain object. You can define a structure base on your requirements.

Return: No.

Example:

const client = APPClient.init();
client
  .do("agentconsole.widget.sendMessage", {
    to: "0593aae4-bc24-4420-8bf4-6e4ffa63bd1a", 
    data: "test",
  })



Events

  1. It will be fired when others widget send message to it throught call agentconsole.widget.sendMessage api.

Params:

NameTypeDescription
callbackfunctionIt is triggered when received a message from other widgets.

Callback params:

NameTypeDescription
fromstringThe Id of widget which sent a message.
dataanyThe received content.

Return: No.

Example:

const client = APPClient.init();
client.on("agentconsole.widget.messageReceived", function (data) {
  // do stuff
});

Dialog

This API can open a dialog dynamically, and others widget under this app can subscribe the event of a dialog have be opened.

Actions

  1. Open a dialog
    This API can open a dialog dynamically, and return promise result, you can get the opened dialog Id from result. The dialog Id is used when you want to close the dialog.

Params:

NameTypeDescription
urlstringThe content of requested will displayed in the dialog.
widthnumberDefault value is 600, you specify the value for dialog width.
heightnumberDefault value is 400, you specify the value for dialog height.

Return:

NameTypeDescription
dialogIdstringThe Id of the opened dialog, it is used when you want to close the dialog.

Example:

const client = APPClient.init();
const dialogId = await client
  .do("agentconsole.dialog.open", {
    url: "./dialog.html",
    width: 600,
    height: 480,
  })
  1. Close a dialog
    You need to pass in the Dialog Id when closing the dialog.

Params:

NameTypeDescription
dialogIdstringYou can get this Id when you opening the dialog

Return: No.

Example:

/**
 * @param {string} id - the app id
 */
const client = APPClient.init();
client
  .do("agentconsole.dialog.close", "0593aae4-bc24-4420-8bf4-6e4ffa63bd1a");



Events

  1. You can listen to the following event to track the others dialog opened.

Params:

NameTypeDescription
callbackfunctionIt is triggered when dialog opened.

Return: No.

Example:

const client = APPClient.init();
client.on("agentconsole.dialog.opened", function (dialog) {
  //do stuff
});
  1. You can listen to the following event to track the others dialog closed.

Params:

NameTypeDescription
callbackfunctionIt is triggered when dialog closed.

Return: No.

Example:

const client = APPClient.init();
client.on("agentconsole.dialog.closed", function (dialog) {
  //do stuff
});

Was this article helpful?

What's Next