handleTrigger()
You can use this API handler to perform custom trigger actions.
Steps to use:
- Add the handler to your code.
- Navigate Settings > Automation > Intelligent triggers, choose the Invoke JS API option from the drop-down list, and set the criteria for which the handler should be triggered.
- In the handler method, you will be receiving the same trigger name that you specified in the Invoke JS API as the first parameter. The second parameter consists of visitor information.
Parameters:
triggername: Name of the configured trigger in the Invoke JS API trigger rule.
visitor: The class object that holds the following visitor information.
Attribute | Description | Datatype |
name | Name of the visitor | String |
The email address of the visitor | String | |
phone | The contact number of the visitor | String |
os | Operating System of the machine that the visitor is using. | String |
countryCode | Country code of the visitor. | String |
ip | The IP address of the visitor | String |
region | Region of the visitor (APAC/CANADA/EMEA/NA/SA). | String |
city | City of the visitor. | String |
state | State of the visitor | String |
numberOfChats | The number of previously closed chats | long |
numberOfVisits | The number of visits. | long |
noOfDaysVisited | Number of days that the visitor had visited your site. | long |
totalTimeSpent | The total time duration that the visitor had spent on your site(in milliseconds). | String |
firstVisitTime | The first time (Unix time) that the visitor visited your site. | Date |
lastVisitTime | Last visited time of the visitor | Date |
Syntax:
Copiedpublic void handleTrigger(String triggerName, SIQVisitor visitor) {
//your code goes here
}
Example:
Copiedpublic class MySalesIQListener implements SalesIQListener{
@Override
public void handleTrigger(String triggerName, SIQVisitor visitor) {
if (triggerName.equals("LoginPage")){
String name = visitor.getName();
String email = visitor.getEmail();
}
}
}