Page tree

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.

NamegetScriptSessionId 
DescriptionGets the current script session id, can be used to call other LiveVox APIs
ReturnsscriptSessionId, String
NamegetAccountNumber
DescriptionGets the call current account number
ReturnsaccountNumber, String
NamegetCallSessionId
DescriptionGets the current calls session id
ReturnscallSessionId, 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
NamegetScriptData
Description Gets the current script data
ReturnsValue of the key if provided, entire scriptData object if key is undefined
Parameters

Key

NameRequiredTypeDescription
keyfalseStringThe name of the script data object toretrieve
NamesetPendingStatus
DescriptionSets the agents next status on the LiveVox platform after termination
Returns

ready, breakCode

NameRequiredTypeDescription
ReadytrueBooleanBoolean to indicate if the agents next status should be ready (true) or not ready (false)
breakCodeFalseEnumValid values include:
  • Break
  • Lunch
  • Meeting
  • Other
  • Tech Difficulties
  • Training
  • Voice Mail

Update Methods

These methods will update both the local and server values.

NameupdateAccountNumber
DescriptionUpdates 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

NameRequiredTypeDescription
newAccountNumbertrueStringThe new account number
successfalseFunctionFunction executed after a success response from the server
failureFalseFunctionFunction executed after an unsuccessful response from the server
NameupdateScriptData
DescriptionDescription Updates or sets a specific key value pair of script data
Parameters

Parameters key, value, mask, callback

NameRequiredTypeDescription
keytrueStringThe key
valuetrueString/NumberThe new value
callbackfalseFunctionFunction executed after a response from the server
maskfalseBooleanCover the current page with a recommend loading mask, defaults to true if not provided
NameupdateScriptDataAll
DescriptionUpdates all script data elements with current form data and any new values set in JavaScript
Parameters

callback, mask

NameRequiredTypeDescription
callbackfalseFunctionFunction executed after a response from the server
maskfalseBooleanCover the current page with a recommend loading mask, defaults to true if not provided

Navigation

These methods will move and end the script

Name

nextNode
Description Navigates the script to the next page
Parameters

 dialogName, mask

NameRequiredTypeDescription
dialogNamefalseStringThe name of the dialog to navigate to. If empty uses nextNode branching
maskfalseBooleanCover the current page with a recommend loading mask, defaults to true if not provided
Name movePrevious
Description Navigates the script to the last page visited
Parameters

 redrawPage

NameRequiredTypeDescription
redrawPagefalseBooleanRedraws the page with current script data, rather than the previous data
Name endScriptWithTermCode
Description Ends the current script and terminates the call
Parameters

 lvResultId, agentAccountNumber, notReadyPrompt

NameRequiredRequiredDescription
lvResultIdfalseIntThe lvResultId of the termination code used to end the call. Provided using the builder tool or found in the LiveVox portal
agentAccountNumberfalseStringThis account number will be used to override the LiveVox provided account number when terminating. If no LiveVox account number is provided this value may be required.
maskfalseBooleanCover the current page with a recommend loading mask, defaults to true if not provided
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

NameRequiredTypeDescription
phonetrueStringPhone to dial
extensionfalseStringThe extension of the person who will accept the transfer
delayfalseNumberThe delay between the 10 digit number being dialed and the extension being entered
securefalseBooleanIndicates if transfer is secure
NamereconnectCall
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
NamecompleteConference
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
NamepreviewDial
DescriptionDials a preview call
Parameters

phone

NameRequiredTypeDescription
phonetrueStringPhone to dial
NameskipPreviewDial
DescriptionUsed to skip a preview dial call
NamefindMatchingAgents
DescriptionUsed to find the agent information for matching agents
ReturnsList of matching agents
Parameters

loginId, lastName, phoneNumber, success, failure, sync, mask

NameRequiredTypeDescription
loginIdOnly provide one of threeStringThe agent’s login id
lastNameOnly provide one of threeStringThe agent’s last name
phoneNumberOnly provide one of threeStringThe agent’s phone number
successfalseFunctionA callback function invoked with a success response from the server
failurefalseFunctionA callback function invoked with a failure response from the server
SyncFalseBooleanSend the request synchronized instead  of asynchronized. This is not
recommended and is deprecated
maskfalseBooleanCover the current page with a recommend loading mask, defaults to
true if not provided
NamefindMatchingAgents
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.

ReturnsList of matching contacts
Parameters

account, name, phone, originalAccountNumber, success, failure, sync, mask

NameRequiredTypeDescription
AccountOnly provide one of fourStringThe account to search
nameOnly provide one of fourStringThe first and last name to search
phoneOnly provide one of fourStringThe phone to search
originalAccountNumberOnly provide one of fourStringThe original account number if setup in LiveVox
successfalseFunctionA callback function invoked with a success response from the server
failurefalseFunctionA callback function invoked with a failure response from the server
SyncFalseBooleanSend the request synchronized instead of asynchronized. This is not recommended and is deprecated
maskfalseBooleanCover the current page with a recommend loading mask, defaults to true if not provided
NamesetPendingStatus
DescriptionSets the agents next status on the LiveVox platform after termination
Parameters

ready, breakCode

NameRequiredTypeDescription
ReadytrueBooleanBoolean to indicate if the agents next status should be ready (true) or not ready (false)
breakCodeFalseEnum

Valid values include:

  • Break
  • Lunch
  • Meeting
  • Other
  • Tech Difficulties
  • Training
  • Voice Mail

Helper Methods

These methods perform various functions within the script such as setting forms, validation, credit card checks, and more.

NamecheckActions
DescriptionTriggers any actions that are set to load on “event”
NamegetFormData
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
NameexecuteQuery
DescriptionExecute a query that has been setup for the script
Parameters

Name, parameters

NameRequiredTypeDescription
nametrueStringName of the query to execute
parametersFalseObjectKey value object of parameters to execute
NamegetCardType
DescriptionSimple helper function to determine if credit card is visa, amex, discover, or mastercard
ReturnsVI MC AX DI or empty string
Parameters

cardNumber

NameRequiredTypeDescription
cardNumbertrueStringCredit card number
NamecheckCreditCard
DescriptionDetermines whether the given value represents a valid credit card number
Returnsboolean
Parameters

cardNumber

NameRequiredTypeDescription
cardNumbertrueStringCredit card number
NamecheckCreditCardField
DescriptionChecks a credit card field and displays an alert if invalid
Parameters

fieldname

NameRequiredTypeDescription
fieldnametrueStringThe name of the html field to check
NamecheckRequiredFields
DescriptionValidates html fields that are required, have regex, or matching elements
NamevalidateField
DescriptionChecks a field for regex, required, or matching elements
Parameters

Field, focus

NameRequiredTypeDescription
fieldtrueElementThe html element to check
FocusFalseBooleanIf we should focus on an object

Utility Methods

These are helpful utility methods.

Name

hideItem

Description

Hides an element

Parameters

id

Name

Required

Type

Description

id

true

String

Id of element to hide

Name

 showItem

Description

 Shows an element

Parameters

 id

Name

Required

Type

Description

id

true

String

Id of element to show

Name

mask

Description

 Masks to the script page

Parameters

 text

Name

Required

Type

Description

text

true

String

Message to display while masking

Name

 unmask

Description

 Removes the mask if present

Name

 lvalert

Description

 Displays a modal alert box

Parameters

 Text, title

Name

Required

Type

Description

text

true

String

Message to display

title

False

String

Title of the modal box

  • No labels