PathFinder SDK
Table of Contents
As already discussed on the PathFinder - An Overview page, you can
configure various touchpoints to capture every user interaction as a signal
have different states that depict the stages in your business that users must access in a certain order
have unique identifiers(parameters) to identify users each time they access and resume their journey with your business.
While you can do all this through the UI, the PathFinder SDK allows you to do it all through code. The SDK comes with a set of ready-to-use code snippets that allow you to set the states, identifiers, other parameters when an event occurs, and make API calls to raise signals.
The SDK is available in Java, NodeJS, and PHP, for now, while other languages will be supported in future updates.
To use the SDK to track the events and raise a signal, you must choose Receiving event from SDK, while creating a touchpoint.
Pre-requisites of using the SDK
The SDK must have the following details to successfully capture the events and raise a signal:
PathFinder name
State name(only one)
Identifier(multiple identifiers are supported)
Other parameters, if needed(these will be saved as variables)
SDK Flow
Initialize the SDK using the Initializer class to set the right DC, hit the APIs, and receive the response
Use the parameter map class to add parameters like process name, state name, identifiers, and extra parameters.
Use the method getAPITriggerWithParam in the ApiTriggerOperations class
to make the API call and raise a signal and receive it's response.
Org information is available as a digest and the domain needs to be set only once before calling the SDK.
Duplicate parameters are not allowed in the SDK.
Use only the reserved keys in the SDK for processname, statename, digestkey, and identifiers.
Do not use other reserved keywords like digest for parameters.
You can have only one state per event, one touchpoint per state, two parameters per SDK call, and configure up to five identifiers. Exceeding this limit will lead to not storing the additional parameters and eventually, data loss.
The allowed data types for the parameters are integer, date, datetime, boolean, and string.
The combined limit of API and SDK for an org per day is 10,000.
Limits on parameters per process for specific datatypes are as follows. Exceeding this limit stops the SDK execution.
"string" - 90
"datetime" - 15
"date" - 15
"boolean" - 10
"integer" - 20
Java
Java SDK is available through Maven and Girdle distributions. You can include the SDK to your project using the following:
Maven
<repositories> <repository> <id>zohocrm-pf-sdk</id> <url>https://maven.zohodl.com</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.zoho.crm</groupId> <artifactId>zohocrm-pf-sdk</artifactId> <version>1.0.0</version> </dependency> </dependencies>
Gradle
repositories{ maven { url "https://maven.zohodl.com" } } dependencies{ implementation 'com.zoho.crm:zohocrm-pf-sdk:1.0.0' }
Sample
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import com.zoho.Initializer;
import com.zoho.Param;
import com.zoho.ParameterMap;
import com.zoho.crm.apitrigger.APIGET;
import com.zoho.crm.apitrigger.ApiTriggerOperations;
import com.zoho.crm.apitrigger.ApiTriggerOperations.GetAPIParam;
import com.zoho.dc.DataCenter.Environment;
import com.zoho.dc.USDataCenter;
import com.zoho.util.APIResponse;
public class MainClass {
public static void main(String args[]) throws Exception {
new Initializer.Builder()
.environment(USDataCenter.PRODUCTION)
.initialize();
ApiTriggerOperations primaryOperations = new ApiTriggerOperations();
ParameterMap paramInstance = new ParameterMap();
paramInstance.add(GetAPIParam.PROCESSNAME, "sdkprocess");
paramInstance.add(GetAPIParam.STATENAME, "state1");
paramInstance.add(GetAPIParam.DIGESTKEY, "641xxxe64a");
paramInstance.add(GetAPIParam.IDENTIFIER1, "test11");
paramInstance.add(GetAPIParam.IDENTIFIER2, "test2");
paramInstance.add(GetAPIParam.IDENTIFIER3, "test3");
paramInstance.add(GetAPIParam.IDENTIFIER4, "test4");
paramInstance.add(GetAPIParam.IDENTIFIER5, "test5");
paramInstance.add(new Param<String>("stringparam", null), "ak2");
OffsetDateTime datetimeParam = OffsetDateTime.of(2022, 11, 15, 11, 00, 00, 01, ZoneOffset.of("+05:30"));
paramInstance.add(new Param<OffsetDateTime>("datetimeparam", null), datetimeParam);
paramInstance.add(new Param<Integer>("integerparam", null), 10);
paramInstance.add(new Param<Boolean>("booleanparam", null), true);
LocalDate date = LocalDate.of(2022,10,15);
paramInstance.add(new Param<LocalDate>("dateparam", null), date);
APIResponse<APIGET> apiResponse = primaryOperations.getAPITriggerWithParam(paramInstance);
}
}
NodeJS
You can download the SDK form the below links:
Sample
const fs = require("fs");
const path = require("path");
const InitializeBuilder = require("cc-nodejs-sdk/routes/initialize_builder").InitializeBuilder;
const USDataCenter = require("cc-nodejs-sdk/routes/dc/us_data_center").USDataCenter;
const SDKConfigBuilder = require("cc-nodejs-sdk/routes/sdk_config_builder").SDKConfigBuilder;
const HeaderMap = require("cc-nodejs-sdk/routes/header_map").HeaderMap;
const ParameterMap = require("cc-nodejs-sdk/routes/parameter_map").ParameterMap;
const Param = require("cc-nodejs-sdk/routes/param").Param;
const ApiTriggerOperations = require("cc-nodejs-sdk/core/com/zoho/crm/api_trigger/api_trigger_operations").ApiTriggerOperations;
const GetAPITriggerParam = require("cc-nodejs-sdk/core/com/zoho/crm/api_trigger/api_trigger_operations").GetAPITriggerParam;
class Initializer {
static async initialize() {
/*
* Configure the environment
* which is of the pattern Domain.Environment
* Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter
* Available Environments: PRODUCTION()
*/
let environment = USDataCenter.PRODUCTION();
/*
* By default, the SDK creates the SDKConfig instance
*/
let sdkConfig = new SDKConfigBuilder().build();
try {
/*
* Set the following in InitializeBuilder
* environment -> Environment instance
* SDKConfig -> SDKConfig instance
*/
(await new InitializeBuilder())
.environment(environment)
.SDKConfig(sdkConfig)
.initialize();
} catch (error) {
console.log(error);
}
let paramInstance = new ParameterMap();
//Pass Processname, Statename, Digestkey configured in the CRM PathFinder and pass dynamic Identifiers and Params to that PathFinder Process
await paramInstance.add(GetAPITriggerParam.PROCESSNAME, "sdkprocess");
await paramInstance.add(GetAPITriggerParam.STATENAME, "state1");
await paramInstance.add(GetAPITriggerParam.DIGESTKEY, "15542307");
await paramInstance.add(GetAPITriggerParam.IDENTIFIER1, "a1");
await paramInstance.add(GetAPITriggerParam.IDENTIFIER2, "a2");
await paramInstance.add(GetAPITriggerParam.IDENTIFIER3, "a3");
//Supported dataTypes for Param: String, Integer, Boolean, DateTime, Date
await paramInstance.add(new Param("stringparam", "String"), "xyz");
await paramInstance.add(new Param("integerparam", "Integer"), 12345678901);
//await paramInstance.add(new Param("booleanparam", "Boolean"), true);
//await paramInstance.add(new Param("dateparam", "Date"), new Date(2022, 11, 15));
//let startDateTime = new Date(2022, 11, 15, 18, 1, 10, 0);
//await paramInstance.add(new Param("datetimeparam", "DateTime"), startDateTime);
let apiTrigOperations = new ApiTriggerOperations();
try{
//Checks the response of an API
let response = await apiTrigOperations.getAPITriggerWithParam(paramInstance);
console.log(response.getObject().getMessage());
}catch (ex) {
console.log(ex);
}
}
}
Initializer.initialize();
PHP
You can download the SDK form the below links:
Sample
<<?php
use com\zoho\dc\USDataCenter;
use com\zoho\InitializeBuilder;
use com\zoho\SDKConfigBuilder;
use com\zoho\crm\apitrigger\GetAPITriggerParam;
use com\zoho\crm\apitrigger\ApiTriggerOperations;
use com\zoho\Param;
use com\zoho\ParameterMap;
require_once "vendor/autoload.php";
class PFSDKInitialize
{
public static function initialize()
{
$environment = USDataCenter::PRODUCTION();
$sdkConfig = (new SDKConfigBuilder())->build();
(new InitializeBuilder())
->environment($environment)
->SDKConfig($sdkConfig)
->initialize();
try {
$paramInstance = new ParameterMap();
$paramInstance->add(GetAPITriggerParam::PROCESSNAME(), "pftest");
$paramInstance->add(GetAPITriggerParam::STATENAME(), "state1");
$paramInstance->add(GetAPITriggerParam::DIGESTKEY(), "641xxxe64a");
$paramInstance->add(GetAPITriggerParam::IDENTIFIER3(), "test1");
$paramInstance->add(GetAPITriggerParam::IDENTIFIER4(), "test2");
$paramInstance->add(GetAPITriggerParam::IDENTIFIER5(), "test3");
$paramInstance->add(new Param("stringparam", "string"), "xyz");
$paramInstance->add(new Param("integerparam", "Integer"), 10);
$paramInstance->add(new Param("booleanparam", "Boolean"), false);
$paramInstance->add(new Param("datetimeparam", "DateTime"), date(DATE_ATOM, mktime(13, 30, 20, 8, 11, 2022)));
$paramInstance->add(new Param("dateparam", "Date"), date_create("2022-11-10"));
$primaryOperations = new ApiTriggerOperations();
$response = $primaryOperations->getAPITriggerWithParam($paramInstance);
print_r($response->getObject()->getMessage());
}catch(\Exception $exception) {
print_r($exception);
}
echo("\n");
}
}
PFSDKInitialize::initialize();