CRM Integration Snippets

The information on this help page applies to both CXone Studio and Desktop Studio.

You can integrate your CRM application with CXone Agent, CXone Agent Embedded, or CXone Agent Integrated. The following snippets are required in your integration script. Information about adding these snippets to your script is available in the online help for setting up data memorialization for CXone Agent, for CXone Agent Embedded, or for CXone Agent Integrated.

Workflow Inputs

This code introduces some variables to the script to hold the CRM integration's configuration ID and the ID of the workflow you want the script to handle.

The code also creates a dynamic data object called searchInput. The object holds the workflow input and the payload that's passed from the CRM to the agent application. In the example code, the object is named for the search workflow. For other workflows, use relevant names.


//this is the ID of the CRM integration from the CXone Agent Integrations page
ASSIGN integrationConfigId="[integration configuration ID]"

//This is the ID of the workflow you want to use
ASSIGN searchWorkflowId="[workflow ID]"

DYNAMIC searchInput
searchInput.workflowInput.phoneNumber="{ANI}"
//Include the following variable if you want to establish a timeout.
//Connect the OnTimeout branch of the Workflow Execute Studio action if you create a timeout. 
searchInput.timeoutMilliSec = "6000"

ASSIGN searchJson = "{searchInput.asjson()}"			
			

Workflow Inputs #2

This action creates a current interaction record. This record stores information about the contact the agent is currently handling. By default, it links between the agent application and your CRM.

To create the current interaction record, this action creates a dynamic data object called create[Record]. You replace [Record] with the name of the CRM record type you want to use, such as Phonecall or Account. The create[Record] object's pinnedRecord parameter pins the current interaction record for the agent. This means that it appears in the Current Interaction section of the customer card for easy access.


DYNAMIC create[Record]
create[Record].subject="{CONTACTID}-{SKLNAME}"
create[Record].phoneNumber="{ANI}"
create[Record].directionCode="incoming"
create[Record].pinnedRecord="true" // set as true for pinning this record in the CXone Agent app, string variable

DYNAMIC create[Record]Payload
create[Record]Payload.workflowInput=create[Record]

ASSIGN create[Record]Json= "{create[Record]Payload.asjson()}"			
			

Workflow Response

This action passes information that the first CustomEvent action needs.

The code in this Snippet adds the contact ID to the variable set in the resultSet (out) property of the Workflow Execute action. It also creates a variable to hold the results of the workflow returned from the CRM in JSON.


// WorkflowResult Out parameter from workflow execute action
workflowResultSet.contactId = "{ContactID}"
ASSIGN searchWorkflowOutputJson = "{workflowResultSet.asjson()}"