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.

AttributeDescriptionDatatype
nameName of the visitorString
emailThe email address of the visitorString
phoneThe contact number of the visitorString
osOperating System of the machine that the visitor is using.String
countryCodeCountry code of the visitor.String
ipThe IP address of the visitorString
regionRegion of the visitor (APAC/CANADA/EMEA/NA/SA).String
cityCity of the visitor.String
stateState of the visitorString
numberOfChatsThe number of previously closed chats long
numberOfVisitsThe number of visits.long
noOfDaysVisitedNumber of days that the visitor had visited your site.long
totalTimeSpentThe total time duration that the visitor had spent on your site(in milliseconds).String
firstVisitTimeThe first time (Unix time) that the visitor visited your site.Date
lastVisitTimeLast visited time of the visitorDate

 

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();
        }
    }
}