10
SNIPPET
Update Data
IF sObjectId!=''
{
// set request body
DYNAMIC agent_Details_update
agent_Details_update.KAA__status__c = 'false'
reqBody = "{agent_Details_update.asJSON()}"
existingUserProxy = GetRESTProxy()
existingUserProxy.ContentType = "application/json" // set content type
// set Authorization
ASSIGN requestAuth = "Bearer "
requestAuth.append("{access_token}")
existingUserProxy.AddHeader("Authorization",requestAuth)
existingUserProxy.ContentType = "application/json"
ASSIGN SobjectName = "KAA__CxoneData__c" //set sobject name
ASSIGN salesforcesobjectURI = "{salesforceBaseURI}/services/data/v58.0/sobjects/{SobjectName}/{sObjectId}"
// set endpoint url
existingUserProxy.MakeRestRequest(salesforcesobjectURI, reqBody ,0, "PATCH")
}
Limit2K
6
0
912
608
5
0
b333da63-33c8-4297-a58a-e9546cf7f0f2
6
0
0
8
SNIPPET
User Auth
//User Authentication
ASSIGN global:access_token = "" // assign global varible for set access token
ASSIGN global:sObjectId = "" // assign global varible for set id
ASSIGN global:salesforceBaseURI = "TO-BE-FILLED-IN" // set baseurl
// set credentials
ASSIGN salesforcekey ="{salesforce_key}"
ASSIGN salesforcesecret ="{salesforce_secret}"
ASSIGN salesforceusername ="{salesforce_username}"
ASSIGN salesforcepassword ="{salesforce_password}"
// urlencoded form
ASSIGN salesforcekey=salesforcekey.urlencode
ASSIGN salesforcesecret=salesforcesecret.urlencode
ASSIGN salesforceusername=salesforceusername.urlencode
ASSIGN salesforcepassword=salesforcepassword.urlencode
tokenproxy=GetRESTProxy()
//create local variable and append credentials
ASSIGN tokenRequestParms=""
tokenRequestParms.append("grant_type=password")
tokenRequestParms.append("&client_id={salesforcekey}")
tokenRequestParms.append("&client_secret={salesforcesecret}")
tokenRequestParms.append("&username={salesforceusername}")
tokenRequestParms.append("&password={salesforcepassword}")
ASSIGN salesforceAuthURI="{salesforceBaseURI}/services/oauth2/token" // set endpoint url
tokenResult = tokenproxy.MakeRestRequest(salesforceAuthURI, tokenrequestParms, 0, "POST")
//call api and store responsed in local variable
// check status code and get access token
IF tokenproxy.StatusCode = 200
{
access_token = "{tokenResult.access_token.$value}"
}
Limit2K
7
0
912
416
2
0
b333da63-33c8-4297-a58a-e9546cf7f0f2
7
0
0
7
SNIPPET
Send Data to Salesforce
// Insert the records after authentication
IF access_token!=''
{
// set request body
DYNAMIC agent_Details
agent_Details.KAA__contact__c = "{contactid}"
agent_Details.KAA__agentId__c = "{agentid}"
agent_Details.KAA__status__c = "true"
agent_Details.KAA__screenPopup__c="false"
agent_Details.KAA__customData__c="{customdata_string}"
requestBody = "{agent_Details.asJSON()}"
existingUserProxy = GetRESTProxy()
existingUserProxy.ContentType = "application/json" // set content type
// set Authorization
ASSIGN requestAuth = "Bearer "
requestAuth.append("{access_token}")
existingUserProxy.AddHeader("Authorization",requestAuth)
existingUserProxy.ContentType = "application/json"
ASSIGN SobjectName = "KAA__CxoneData__c" //set sobject name
ASSIGN salesforceSobjectURI = "{salesforceBaseURI}/services/data/v58.0/sobjects/{SobjectName}" //set endpoint url
responsedBody = existingUserProxy.MakeRestRequest(salesforceSobjectURI, requestBody ,0, "POST")
//ASSIGN global:bearerToken = "{global:existingResult.autoSuggestResults}"
sObjectId = "{responsedBody.id.$value}"
}
Limit2K
3
0
1072
416
4
0
b333da63-33c8-4297-a58a-e9546cf7f0f2
3
0
0
6
END
End
1088
608
3
0
93fb8888-30cf-4df3-8ed9-1f2986819080
-1
0
0
5
SNIPPET
Send endOfConversation event to Agent AI widget
DYNAMIC params
params.conversationId = "{contactid}"
params.botid = "{botid}"
params.clientid="{clientid}"
params.clientsecret="{clientsecret}"
params.baseurl="{baseurl}"
params.language="{language}"
requestBody = "{params.asJSON()}"
existingUserProxy = GetRESTProxy()
existingUserProxy.ContentType = "application/json" // set content type
ASSIGN tempArr = "{baseurl.split('/')}"
ASSIGN baseURI = "{tempArr[1]}"
baseURI.append("/")
baseURI.append("{tempArr[2]}")
baseURI.append("/")
baseURI.append("{tempArr[3]}")
ASSIGN summaryURI = "{baseURI}/integrations/nice/triggerSummary" //set endpoint url
responsedBody = existingUserProxy.MakeRestRequest(summaryURI, requestBody ,0, "POST")
ASSIGN responseString="{responsedBody.asJSON()}"
Limit2K
10
0
752
608
7
0
b333da63-33c8-4297-a58a-e9546cf7f0f2
10
0
0
4
ONRELEASE
Onrelease
5
0
592
608
1
0
ea1363d4-fade-4cac-b15e-c4c514c2f9b5
5
0
0
3
AgentAssistV1_LIBID_b2aedee9-ab1e-4923-9d64-04cee8118482
Agent Assist
KAA
1232
416
8
1
b2aedee9-ab1e-4923-9d64-04cee8118482
-1
0
0
2
SNIPPET
Set Credentials
//NICEOPENCTI ORG
//NICEOPENCTIPACKAGER ORG
ASSIGN global:salesforce_key="TO-BE-FILLED-IN" //ClientID
ASSIGN global:salesforce_secret="TO-BE-FILLED-IN" //ClientSecret
ASSIGN global:salesforce_username="TO-BE-FILLED-IN" //SF Username
ASSIGN global:salesforce_password="TO-BE-FILLED-IN" //SF Password
//Agent AI Configuration
ASSIGN global:clientsecret="Kore.ai ClientSecret"
ASSIGN global:clientid="Kore.ai ClientID"
ASSIGN global:botid="Kore.ai BotID"
ASSIGN global:baseurl="kore.ai AgentAI Widget URL"
ASSIGN global:language="en"
//'customdata' object can be utilized to pass information to Agent AI Bot
//For example, customdata.agentId = "{agentid}"
DYNAMIC customdata
ASSIGN global:customdata_string = "{customdata.asJSON()}"
Limit2K
8
0
744
416
6
0
b333da63-33c8-4297-a58a-e9546cf7f0f2
8
0
0
1
BEGIN
Begin
Unnamed0
2
0
592
416
0
0
b2f794c5-0232-40e7-9830-76d573bf57d7
2
0
0
nicecti_aa_sf_outbound
2025-05-02T10:42:43.217
2025-05-02T10:42:43.217
44030417
Kore.ai
Mountain Standard Time
Unnamed0
-1
4
0001-01-01T00:00:00