Feedback

  • Contents
 

Writing custom scripts for Interaction Connect or Scripter .NET

Starting with PureConnect 2018 R3, Dialer agents can use Interaction Connect or Interaction Scripter .NET to process outbound calls that use custom scripts. As before, both clients support base scripts.

Base scripts run in both clients

  • Base scripts do not require programming expertise to create. With appropriate access rights, anyone can use the Scripts container in Interaction Administrator to design a base script.

  • Every base script is compatible with Interaction Connect and Interaction Scripter .NET. The same base script may be used by a pool of agents running either or both applications.

Custom scripts run in one client or the other

Programmers develop custom scripts using HTML and JavaScript, in accordance with the Interaction Scripter Developer Guide. The script appears on an agent’s screen when a call is previewed or routed to the agent.

Scripter .NET and Connect process JavaScript statements differently–either synchronously or asynchronously. This requires developers to implement different coding techniques. The resulting custom script is compatible with one client or the other. A custom script cannot be compatible with both clients.

Generally, web applications that perform tasks concurrently (asynchronously) are faster and more responsive than applications that perform tasks consecutively (synchronously). A synchronous application waits for something to finish before moving to another task. An asynchronous application starts the next task before a previous task finishes.

Scripter .NET is synchronous

Scripter .NET executes one JavaScript statement at a time, waiting for each consecutive statement to complete before moving to the next.

Suppose that you want Scripter .NET to transfer a call and then print a message. The pseudocode below uses the IS_Action_Transfer action. Since Scripter .NET is synchronous, it executes the IS_Action_Transfer action, waits until that action is complete, and then prints a message.

IS_Action_Transfer(CallId, false, "222-3333");
print('Transfer Success');

Interaction Connect is asynchronous

Interaction Connect executes JavaScript statements concurrently and independently from one another.

To tailor a script for Connect, programmers must ensure that the next operation does not begin until a signal is received indicating that the previous operation has completed. This is accomplished by implementing a custom callback (if required by a method) or by using a callback property of an IS_Action, which will be explained in a moment. When the function completes, the callback receives a signal telling it when to execute subsequent statements in its code block.

In Connect, the example above would not execute as the developer intended. Connect would execute both statements concurrently. Without a callback to tell Connect that the Transfer action is completed, it has no way to know that the developer's intent is to print a message after the transfer is completed.

To wait until the transfer ends, pass a callback function as a method parameter. In the code block for the callback, add any statements you want to execute after the calling method completes.

The callback property ensures that IS_Actions execute properly in Interaction Connect

Starting with 2018 R3, all Interaction Scripter actions (IS_Actions) provide a callback property for use in Connect scripts only. Each custom script action has a new callback attribute named "callback". If the action fails, the callback will be invoked with an error. If the action is successful, the callback will be invoked with no error. Customers can use this to determine how to proceed in the event that the action failed or completed successfully. For example:

IS_Action_Transfer.callback = function(error) {
     if(error) {
          console.error("IS_Action_Transfer failed");
     } else {
          console.log("IS_Action_Transfer performed successfully");
     }
}

In practice, you'll want to define a function to pass to the action any attributes it needs. In the example below, IS_Action_Transfer's callback property won't execute statements in its function code block until the transfer completes.

function IS_Action_Transfer() {
  IS_Action_Transfer.callid = 1234;
  IS_Action_Transfer.consult = False;
  IS_Action_Transfer.recipient = '377-522-2222';
  IS_Action_Transfer.callback = function(error) {
    if (error) {
      console.error("The Transfer action failed.");
    } else {
      console.log("The Transfer action was a success");
    }
  }
}

This is the key to writing scripts that run asynchronously in  Interaction Connect. Statements inside the callback function block (highlighted above) execute only after the action completes. The callback will return an error if the action fails. If the action was successful, no error is returned.

In this documentation, callbacks that apply exclusively to Interaction Connect are individually noted.

Additional callbacks added to support Interaction Connect

In addition to callbacks for actions, you can use callbacks designed for scripting objects—such as calls and chats.

CallObject.callObjectInitializedHandler

Allows a script to dial a number after waiting asynchronously for a call object to be created.

ChatObject.requestedAttributeReturnHandler

Allows a script to asynchronously get a chat attribute by first setting this callback and then calling the chatObject.getAttribute method.

ChatObject.chatObjectInitializedHandler

Allows a script to start a chat after waiting asynchronously for a ChatObject to be created.

ConferenceObject.conferenceObjectInitializedHandler

This callback is invoked when the conference object has initialized.

ConferenceObject.conferenceStartedHandler

This callback is invoked when the conference call has started.

Other scripting modifications to support Interaction Connect

  • The IS_Action_Transfer action supports an "audience" parameter, used to toggle between different parties on a consult transfer call.

  • A new standard action, IS_Action_CompleteConsult ends a consult call in scripts for Interaction Connect only.

  • IS_Action_CallComplete has a new Boolean parameter named makefollowupcall. It indicates whether the user should be put into "Additional Follow Up status", in support of a feature that allows an agent to dial additional calls while in that status.

  • For custom scripts in Scripter Connect, the wav file specified for the IS_Action_PlayWav action must be located in the Resource Path directory on the CIC server (I3\IC\Resources by default).

  • The Queue.connect method is now asynchronous, meaning that it can accept a single optional callback argument that takes no parameters. In addition, Queue.connect no longer supports Line Queue as a Type parameter. Scripts for Scripter .NET do not need to specify a callback, but scripts for Connect must specify it.

  • The Queue.startCallObjectsEnum, Queue.startChatObjectsEnum, Queue.startConferenceObjectsEnum and Queue.startObjectIdsEnum properties now accept an optional callback (for use with Connect scripts only) whose single parameter contains the result. User.startAccessibleQueuesEnum and User.startViewableWorkgroupsEnum work the same way.

  • See Revisions for a complete list of changes to this documentation.

Summary

Since Interaction Connect is a web application, it runs in a browser without the need to install software on agent desktops. The option to replace a desktop application with a cloud application is compelling. As a prerequisite to using Connect, customers must manually update legacy scripts (or write new scripts) to run asynchronously.

  • Legacy scripts written for Interaction Scripter .NET work as before in that client application.

  • Due to the general complexity of script programming, Genesys cannot provide a script migration utility. Fortunately, most JavaScript developers are familiar with callbacks. Implementing new callbacks to support asynchronous execution should not present an obstacle for most customers.

  • A custom script must be written for one client or the other.

  • The same custom script cannot be used by both Scripter .NET and Interaction Connect.

  • Scripts for Interaction Connect implement callback functions that wait for asynchronous operations complete.

  • Scripts for Scripter .NET should not implement callbacks designed for Connect.

See Also

Sample Interaction Connect scripts