.handleTrigger()
This delegate method allows you to handle custom triggers. The handleTrigger method provides the name of the custom trigger along with an instance of the SIQVisitor class, which contains information relating to the user.
Parameters:
name: Name of the trigger configured in the Invoke Client API trigger rule.
visitorInformation: An instance of the SIQVisitor class which holds visitor information.
The SIQVisitor class has the following properties:
Property | Description |
name | Name of the user |
Email ID of the user | |
phone | The contact number of the user |
os | The operating system in use |
ip | The IP address of the user |
countryCode | Country code of the user |
region | Region of the user[APAC/CANADA/EMEA/NA/SA] |
state | State of the user |
city | City of the user |
numberOfChats | Number of previously closed chats |
nubmerOfVisits | Number of visits by the user |
noOfDaysVisited | Number of days the user has used the app |
totalTimeSpent | Total app usage time |
firstVisitTime | Time at which the user first used the app |
lastVisitTime | Time at which the user last used the app |
Usage
To use the handleTrigger delegate method, you need to set up the Invoke JS API.
Invoke JS APIs are used to implement custom trigger actions. Set a custom trigger action by navigating to Settings > Automation > Intelligent Triggers, and select the "Invoke JS API" option from the dropdown, as shown below.
Use the same trigger name given in the Invoke JS API as your .handleTrigger() API's name to implement your app's custom action. Once the Invoke JS API trigger is activated, the custom action defined inside the .handleTrigger() API will start to execute.
Here, we have defined a custom trigger named "Engage" that triggers visitors who have visited more than ten times but haven't initiated any chat. So if a visitor satisfies these criteria, then the trigger will be activated. In this case, the visitor will see a discount banner.
Initial Setup
Copiedlet myEventHandler = MyEventHandler()
ZohoSalesIQ.delegate = myEventHandler
Implementation
Copiedclass MyEventHandler: ZohoSalesIQDelegate{
func handleTrigger(name: String, visitorInformation: SIQVisitor) {
if name == "Engage"{
// your code goes here
}else if name == "Show Discount Banner"{
// your code goes here
}
}
}