Use events method

Front-end events are actions on the product UI, such as button clicks and changes/updates to the UI field values. Events method is an interface that the developer platform provides, to enable your app to react to front-end events.

To enable your app to react to front-end events, in the app.js file,

  1. Subscribe to the app.initialized event, through an event listener. When the app is initialized, the parent application passes a client reference to the app.
  2. After app initialization,
    1. Use the client reference, subscribe to <Event name> and register a callback method to be executed when the event occurs.
    2. Define the callback method.

When the event occurs, a payload is passed to the callback method. Let us call this payload event. event.type returns the name of the event. The event.helper.getData() helper method returns a JSON object that contains information pertaining to the event. Your app logic can process this data into meaningful results.

Front-end events are of the following types: Click events, Change events, Intercept events.

Click events

These events occur when an agent clicks a button or link on the page. The event.helper.getData() method returns an empty JSON for most of these events, the only exception being timer events.

Change events

These events occur when a user changes the value of a field on the UI.

Note:User need not submit the modified value for the event listeners to pick up the event and execute the callback; merely changing the values is sufficient for the event trigger.

The event.helper.getData() method returns a JSON that contains the old and new values of the changed field.

Intercept events

These are events that are paused, while the event listener and the corresponding callback run. The app can choose to allow the original event to complete or block the event.

To enable your app to intercept an event, after app initialization,

  1. Use the client reference, subscribe to event, register a callback method to be executed when the event occurs, and set intercept as true.
  2. Define the callback method.
  3. To allow the event to proceed, use the event.helper.done() helper method.
  4. To prevent the event from completion, use the event.helper.fail(‘errorMessage’) helper method.
  5. To obtain data pertaining to the event, use the event.helper.getData() helper method. If your app is intercepting a click event, the method returns an empty JSON.

Conversation editor page event

Event nameEvent trigger
Click events
conversation.onPrivateNoteClick When an agent clicks the Private Note button.
conversation.onSendClick When a user clicks the Send button, Enter to send a message, or the Send button in FAQs.
conversation.onCobrowseClickWhen an agent clicks the Cobrowse button.
conversation. onCannedResponseClickWhen an agent clicks the Canned Response button.
conversation.onAttachFAQClick When an agent clicks the FAQs button.
conversation.onAttachFileClick When an agent clicks the Attach File button.
conversation.onChooseFileClick When a user clicks the Choose File button.
conversation.onQuickAccessClick When an agent clicks the Quick Access button.
conversation.onAttachImageClick When a user clicks the Attach Image button.
conversation.onEmojiClick When a user clicks the Emoji button.
conversation.onResolveClick When an agent clicks the Resolve button.
conversation. onResolveAndCreateTicketFDClickWhen an agent clicks the Resolve And Create Ticket Freshdesk button.
conversation. onResolveAndCreateTicketFSClickWhen an agent clicks the Resolve And Create Ticket Freshsales button.
Intercept events
conversation.onSendMessage When an agent clicks the Send button. The event payload is the conversation.onSendMessage object.
conversation.onResolveClick When an agent clicks the Resolve button.
conversation.onReopenClick When an agent clicks the Reopen button.
chatConversation.onSendMessageWhen an agent clicks the Send button. The event payload is the chatConversation.onSendMessage object.

User details page events

Event nameEvent trigger
Change events
user.saveCustomPropertyClickWhen an agent changes a user property and clicks Save.
user.onSaveNameClickWhen an agent changes a user’s name and clicks Save.
user.onSavePhoneClick When an agent changes a user’s phone number and clicks Save.
user.onSaveEmailClickWhen an agent changes a user’s email address and clicks Save.

Event and payload descriptions

conversation.onPrivateNoteClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Private Note button.

conversation.onSendClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Send button, Enter to send a message, or the Send button in FAQs.

conversation.onCobrowseClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent click on the Co-browse button.

conversation.onCannedResponseClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent click on the Canned Response button.

conversation.onAttachFAQClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent click on the FAQs button.

conversation.onAttachFileClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Attach File button.

conversation.onChooseFileClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Choose File button.

conversation.onQuickAccessClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Quick Access button.

conversation.onAttachImageClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Attach Image button.

conversation.onEmojiClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Emoji button.

conversation.onResolveClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Resolve button.

conversation.onResolveAndCreateTicketFDClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Resolve And Create Ticket Freshdesk button.

conversation.onResolveAndCreateTicketFSClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Resolve And Create Ticket Freshsales button.

conversation.onSendMessage

Use the sample code shown on the right pane > Sample code tab, to enable your app to respond when an agent clicks the Send button in either the conversation reply editor or email editor.

Note:The conversation.onSendMessage method triggers only when the Send button is clicked in reply editors for conversations and emails; it does not trigger for new email conversation creation.

conversation.onResolveClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Resolve button.

conversation.onReopenClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to an agent's click on the Reopen button.

user.saveCustomPropertyClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when an agent changes a user property and clicks Save.

user.onSaveNameClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when an agent changes a user's name and clicks Save.

user.onSavePhoneClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when an agent changes a user's phone number and clicks Save.

user.onSaveEmailClick

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when an agent changes a user's email address and clicks Save.

chatConversation.onSendMessage

Use the sample code shown on the right pane > Sample code tab, to enable your app to respond when an agent clicks the Send button in either the conversation reply editor or email editor.

Note:The chatConversation.onSendMessage method triggers only when the Send button is clicked in reply editors for conversations and emails; it does not trigger for new email conversation creation.