# Events
We'll broadcast several events on the fly. You can subscribe to the relevant events to handle your own logic.
Note
All callbacks for subscribed events will be executed in a background thread. Please be cautious when manipulating UI elements.
# API
# registerAsyncEventListener()
To register a callback for a specific event.
AIHelpSupport.registerAsyncEventListener(YOUR_EVENT, function(jsonEventData, ack) {
// You can get callback here if the target event is fired
// checkout at the definition and code examples for more information
/**
* Called when an event is triggered.
*
* @param jsonEventData JSON formatted event data
* @param ack Callback interface to acknowledge to AIHelp
*/
console.log(jsonEventData);
/**
* Some events may require sending results back to AIHelp. Use this callback
* method to send acknowledgment.
*
* Currently required for these events:
* 1. `EventType.ENTERPRISE_AUTH`: Enterprise authentication. Send the user token
* back via the `token` field.
* 2. `EventType.UPLOAD_LOG`: Log upload. Send upload results or other information
* via the `content` field.
*
* @param jsonAckData JSON formatted acknowledgment data
*/
ack(jsonAckData);
});
# unregisterAsyncEventListener()
To unregister a callback for a specific event.
AIHelpSupport.unregisterAsyncEventListener(YOUR_EVENT);
# Definition
# eventType
- Type:
EventType
- Details: Required All Events may be triggered. It's worthing noting that different events may carry different parameters, some may need a acknowledge callback.
# Event Type
# Initialization
- Event: initialization
- Data:
{ "isSuccess": true, "message": "Success" }
- ACK:
-
# Logging In
- Event: userLogin
- Data:
{ "code": 1, "message": "Success" }
- ACK:
-
# Authentication
- Event: enterpriseAuth
- Data:
-
- ACK:
{ "token": "this_is_your_authenticated_token" }
# Unread Message
- Event: messageArrival
- Data:
{ "msgCount": 1 }
- ACK:
-
# Unread Task Count
- 枚举值:unreadTaskCount
- 数据:
{ "taskCount": 1 }
- ACK:
-
# Uploading Logs
- Event: logUpload
- Data:
-
- ACK:
{ "content": "this_is_your_authenticated_token" }
# Clicking URLs
- Event:
urlClick
- Data:
{ "url": "https://your.target.url?js-bridge=enable" }
- ACK:
-
- Details: When links containing
js-bridge=enable
as parameters are clicked, this event is triggered.
# Conversation Start
- 枚举值:
conversationStart
- 数据:
{ "message": "this is the first message user sent" }
- ACK:
-
# Opening AIHelp
- Event:
sessionOpen
- Data:
-
- ACK:
-
# Closing AIHelp
- Event:
sessionClose
- Data:
-
- ACK:
-