Events Method

Event methods enable you to react to events that occur in the user interface of a page. This includes button clicks, changes, and updates to field values. You can register event listeners that are invoked when an event occurs.

Event Payload
When the callback method is invoked, an event payload is passed to it. The payload is a JavaScript object which contains a type field and data object.

1
2
3
4
5
// event_type contains the name of the event var event_type = event.type; // event_data is a JSON whose value depends on the type of event var event_data = event.helper.getData();

Click Events
These events occur when an agent clicks a button or link. The helper method event.helper.getData() returns an empty JSON for most of these events.

EVENT NAME DESCRIPTION SAMPLE CODE
conversation.onPrivateNoteClick When an agent clicks the Private Note button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onPrivateNoteClick", eventCallback);

conversation.onSendClick When a user clicks the Send button, Enter to send a message, or the Send button in FAQs.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onSendClick", eventCallback);

conversation.onCobrowseClick When an agent clicks the Cobrowse button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onCobrowseClick", eventCallback);

conversation.
onCannedResponseClick
When an agent clicks the Canned Response button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.
onCannedResponseClick", eventCallback);

conversation.onAttachFAQClick When an agent clicks the FAQs button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onAttachFAQClick", eventCallback);

conversation.onAttachFileClick When an agent clicks the Attach File button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onAttachFileClick", eventCallback);

conversation.onChooseFileClick When a user clicks the Choose File button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onChooseFileClick", eventCallback);

conversation.onQuickAccessClick When an agent clicks the Quick Access button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onQuickAccessClick", eventCallback);

conversation.onAttachImageClick When a user clicks the Attach Image button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onAttachImageClick", eventCallback);

conversation.onEmojiClick When a user clicks the Emoji button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onEmojiClick", eventCallback);

conversation.onResolveClick When an agent clicks the Resolve button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.onResolveClick", eventCallback);

conversation.
onResolveAndCreateTicketFDClick
When an agent clicks the Resolve And Create Ticket Freshdesk button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.
onResolveAndCreateTicketFDClick", eventCallback);

conversation.
onResolveAndCreateTicketFSClick
When an agent clicks the Resolve And Create Ticket Freshsales button.

var eventCallback = function (event) {
console.log(event.type + " event occurred");
};
client.events.on("conversation.
onResolveAndCreateTicketFSClick", eventCallback);


Change Events
These events occur when an agent changes a value of a user property. The event is triggered even if the value is not successfully submitted. The helper method event.helper.getData() returns a JSON that contains the new value of the changed field.

1
2
3
{ "new": <new_value> }

EVENT NAME DESCRIPTION SAMPLE CODE
user.saveCustomPropertyClick {type:'eventName', data: {key: "key", value: "value"}}
When an agent changes a user property and clicks Done.

var propertyChangeCallback = function (event)
// code to be executed when the user property is changed.
{
var event_data = event.helper.getData();
console.log(event.type + " data changed to " + event_data.key + event_data.value);
};
client.events.on("user.saveCustomPropertyClick", propertyChangeCallback);

user.onSaveNameClick When an agent changes a user’s name and clicks Save.

var propertyChangeCallback = function (event)
// code to be executed when the user name is changed.
{
var event_data = event.helper.getData();
console.log(event.type + " data changed to " + event_data.new);
};
client.events.on("user.onSaveNameClick", propertyChangeCallback);

user.onSavePhoneClick When an agent changes a user’s phone number and clicks Save.

var propertyChangeCallback = function (event)
// code to be executed when the user phone number is changed.
{
var event_data = event.helper.getData();
console.log(event.type + " data changed to " + event_data.new);
};
client.events.on("user.onSavePhoneClick", propertyChangeCallback);

user.onSaveEmailClick When an agent changes a user’s email address and clicks Save.

var propertyChangeCallback = function (event)
// code to be executed when the user email address is changed.
{
var event_data = event.helper.getData();
console.log(event.type + " data changed to " + event_data.new);
};
client.events.on("user.onSaveEmailClick", propertyChangeCallback);