Scripting best practices and recommendations

The following are important notes, best practices, and recommendations for scripting. 

Queue Name variable

  • The script does not know the Scripter.Queue Name variable value when the page loads. The script must request the data for the variable from the platform. As a result, the Scripter.Queue Name variable might not be available for anything other than displaying, including using its value inside a complex action. If you want to use the queue name for some conditional logic inside a script, for example, you want to use the queue name in your logic, you might have an issue. This issue is because the variable might be empty or changed by some other logic when the script runs. If you choose to use the queue name and the name changes, the action can be broken. Only use Scripter.Queue Namefor display purposes. When the data must be immediately available, we recommend relying on the Scripter.Queue IDvariable in place of Scripter.Queue Name. To directly load the queue name before calling external actions that require the name, use Scripter.Queue ID.

Contact List Data

  • Contact list data is fetched on script load during a campaign. To trigger an action after the data is retrieved, use the Contact Data Load action, not the Script Page load action. When scripter fetches the contact who is calling, or got called, it affects their data. When the data is requested from the platform, it might not available when the script loads. If you attempt to use contact data during a script load or page load action of the start page, the data might not be loaded in the variables. When you want to use contact data in a script, we recommend you use the Contact Data Load action that is available in Script Properties under the Outbound feature.

Page load action

  • It is important to note that the Page Load action is triggered every time you switch pages, however, the Page Load action is not triggered every time you switch interactions and come back to that interaction.
  • To write a Page Load action that only triggers once and not on every page change, use a TrueFalse custom script variable such as hasTriggered. Wrap the logic that runs once with a check to that variable. 

Refreshing browser

  • When a browser is refreshed, the platform does not retry actions that are in flight. When you are triggering a long-polling action through the platform, note that if an agent refreshes their browser and the action hasn’t finished, the action stops where it is, the script reloads, and the action is not retried. Even when an action is not long running, there’s a chance that the browser could refresh in the middle of an action. This refresh cannot be controlled, and the action cannot be recovered or retried.

Input variables

  • Input variables are only fetched once on script load. These variables do not update as conversation updates come in. Use the Scripter.Refresh Input Variablesaction to re-fetch the values from a conversation and update the input variables.