The ability to include custom JavaScript functions provides a method for creating custom logic and functionality that would otherwise not be available with the standard toolkit.
You can include JavaScript in the following places in your scripts:
- Script Level: JavaScript that may be used in multiple locations within a script and needs to be available to be called from any dialog.
- Dialog Level: JavaScript that will only be used within a specific dialog should be created within that Dialog.
This section focuses on adding JavaScript at the dialog Level; however, adding JavaScript to the script is done in the same fashion.
A user may access the area to add JavaScript by selecting either Script or Dialog from the main menu and then selecting JavaScript from the sub-menu.
If you choose to create the JavaScript at the dialog level, ensure that you have selected the appropriate dialog before clicking the JavaScript icon.
Once selected, the user is taken to a work area that has the basic structure of a properly formatted function defined. The user can either use this basic formatting, or replace it with their own. This feature is intended for a more advanced user who has an understanding of developing JavaScript code. Once the code is complete, the user should be sure to save their work by clicking the save icon in the upper-right corner of the form.
To call the custom function from the Script, the user should right-click the button, or object on the script that will be used to call the function, then select Input Properties. From here, the user should select the “Event” Icon and add the proper event to trigger the custom function.
The drop-down list should now contain the custom function that was developed and added to the script. If the JavaScript was developed at the Dialog level, the function will be listed at the end of the dropdown list, under the Local Dialog Functions. If it was developed as a Script JavaScript, it may be found in the drop-down list under the LiveVox Main functions.
Once the Event has been defined, and any required parameters associated, be sure to save the work by clicking Accept (located in the upper-right corner of the Events form).
Functions
This section describes the functions which are available to use in the buttons or in custom JavaScript code. All the methods below must be accessed using the prefix lvcore. in JavaScript. Example: lvcore.getAccountNumber(); will return the account number of the current call. If using the builder’s dropdown lists lvcore. is added automatically.
Getter Methods
These methods get current data from the script parent.
Name | getScriptSessionId |
Description | Gets the current script session id, can be used to call other LiveVox APIs |
Returns | scriptSessionId, String |
Name | getAccountNumber |
Description | Gets the call current account number |
Returns | accountNumber, String |
Name | getCallSessionId |
Description | Gets the current calls session id |
Returns | callSessionId, String |
Name | getAgentInfo |
Description | Gets currents agents info |
Returns | agentInfo, Object |
Name | getOriginalAgentInfo |
Description | Gets original agents info after a transfer event |
Returns | originalAgentInfo, Object |
Name | getScriptData | ||||||||
Description | Gets the current script data | ||||||||
Returns | Value of the key if provided, entire scriptData object if key is undefined | ||||||||
Parameters | Key
|
Name | setPendingStatus | ||||||||||||
Description | Sets the agents next status on the LiveVox platform after termination | ||||||||||||
Returns | ready, breakCode
|
Update Methods
These methods will update both the local and server values.
Name | updateAccountNumber | ||||||||||||||||
Description | Updates the account number of the current script. Useful for inbound calls when no account is found or for incorrect account numbers. | ||||||||||||||||
Parameters | newAccountNumber, success, failure
|
Name | updateScriptData | ||||||||||||||||||||
Description | Description Updates or sets a specific key value pair of script data | ||||||||||||||||||||
Parameters | Parameters key, value, mask, callback
|
Name | updateScriptDataAll | ||||||||||||
Description | Updates all script data elements with current form data and any new values set in JavaScript | ||||||||||||
Parameters | callback, mask
|
Navigation
These methods will move and end the script
Name | nextNode | ||||||||||||
Description | Navigates the script to the next page | ||||||||||||
Parameters | dialogName, mask
|
Name | movePrevious | ||||||||
Description | Navigates the script to the last page visited | ||||||||
Parameters | redrawPage
|
Name | endScriptWithTermCode | ||||||||||||||||
Description | Ends the current script and terminates the call | ||||||||||||||||
Parameters | lvResultId, agentAccountNumber, notReadyPrompt
|
Name | endScript |
Description | Ends the current script, recommended for use in preview scripts only. Agent will be unable to terminate call in script after this function is used. |
LiveVox API methods
These methods are used to access the LiveVox API from within a script.
Name | transferCall | ||||||||||||||||||||
Description | Used to transfer a call to an Agent entered 10 digit number | ||||||||||||||||||||
Parameters | phone, extension, delay, secure
|
Name | reconnectCall |
Description | Used by an Agent to reconnect to a caller. The call is essentially returned to the point before the Agent tried to transfer the call |
Name | completeConference |
Description | Used by an Agent to complete the conference, i.e., all three parties (Agent, caller, Supervisor) are on the same call |
Name | leaveConference |
Description | Used by an Agent to leave a conference, i.e., the Supervisor and caller are left on the call while the Agent is disconnected |
Name | previewDial | ||||||||
Description | Dials a preview call | ||||||||
Parameters | phone
|
Name | skipPreviewDial |
Description | Used to skip a preview dial call |
Name | findMatchingAgents | ||||||||||||||||||||||||||||||||
Description | Used to find the agent information for matching agents | ||||||||||||||||||||||||||||||||
Returns | List of matching agents | ||||||||||||||||||||||||||||||||
Parameters | loginId, lastName, phoneNumber, success, failure, sync, mask
|
Name | findMatchingAgents | ||||||||||||||||||||||||||||||||||||
Description | Used to search the LiveVox contact table for matching contacts Note: Search fields for contacts are OR conditions meaning that only one can be included in a single request. Including more than one will not cause an error but the results are unpredictable. | ||||||||||||||||||||||||||||||||||||
Returns | List of matching contacts | ||||||||||||||||||||||||||||||||||||
Parameters | account, name, phone, originalAccountNumber, success, failure, sync, mask
|
Name | setPendingStatus | ||||||||||||
Description | Sets the agents next status on the LiveVox platform after termination | ||||||||||||
Parameters | ready, breakCode
|
Helper Methods
These methods perform various functions within the script such as setting forms, validation, credit card checks, and more.
Name | checkActions |
Description | Triggers any actions that are set to load on “event” |
Name | getFormData |
Description | Gets the current html form data and sets it to script data. Does not return any values, use getScriptData to get the updated data |
Name | setFormData |
Description | Updates the current html textfields and objects with the current script data values |
Name | executeQuery | ||||||||||||
Description | Execute a query that has been setup for the script | ||||||||||||
Parameters | Name, parameters
|
Name | getCardType | ||||||||
Description | Simple helper function to determine if credit card is visa, amex, discover, or mastercard | ||||||||
Returns | VI MC AX DI or empty string | ||||||||
Parameters | cardNumber
|
Name | checkCreditCard | ||||||||
Description | Determines whether the given value represents a valid credit card number | ||||||||
Returns | boolean | ||||||||
Parameters | cardNumber
|
Name | checkCreditCardField | ||||||||
Description | Checks a credit card field and displays an alert if invalid | ||||||||
Parameters | fieldname
|
Name | checkRequiredFields |
Description | Validates html fields that are required, have regex, or matching elements |
Name | validateField | ||||||||||||
Description | Checks a field for regex, required, or matching elements | ||||||||||||
Parameters | Field, focus
|
Utility Methods
These are helpful utility methods.
Name | hideItem | ||||||||
Description | Hides an element | ||||||||
Parameters | id
|
Name | showItem | ||||||||
Description | Shows an element | ||||||||
Parameters | id
|
Name | mask | ||||||||
Description | Masks to the script page | ||||||||
Parameters | text
|
Name | unmask |
Description | Removes the mask if present |
Name | lvalert | ||||||||||||
Description | Displays a modal alert box | ||||||||||||
Parameters | Text, title
|