Brekeke PBX Wiki

IVR Class

This class implements a basic IVR feature. An instance of this class will be created when IVR starts and will be passed to an IVR Script function as the first argument.

The methods below can be called in a flow in format: $ivr.<method_name>, such as $ivr.answer();

Since v3.10, please use the $ivr variable instead of ivr in a flow.  The ivr variable in a flow has been deprecated.

 

Methods:
void answer()

Description: Answer the call

This method is needed when extension [Auto Answer] field is set to ”no.”

 

void cancelTransfer()

Description: Back to the original party

 

String clearDTMFBuffer()

Description: Get DTMF signals from the signal buffer

Return: DTMF characters

 

boolean connected()

Description: Check if the session is connected

Return: “true” if the session has been established; “false” if not connected

 

void dropcall()

Description: Drop current call

 

void exec( String note, String function, String param )

Description: Execute another JavaScript function in another note

Parameters:

note: Note name

function: Function name

param: Only one parameter

 

ConnectionManager getDb( String name )

Description: Return the ConnectionManager object that is for JDBC connection pool

For details, please refer to ConnectionManager class.

Return: The ConnectionManager object

 

FlowRunner getFlowRunner()

Description: Return the FlowRunner object associated with the current IVR

For details, please refer to FlowRunner class.

Return: FlowRunner object associated with the current IVR, or “null” if the IVR type is not Flow

 

String getLanguage()

Description: Get a language code of the current language

Return: Current language code

“en” for English, “ja” for Japanese or another language code if you have localized Brekeke PBX into other languages.

 

apache.log4j.Logger getLogger()

Description: Return the Log4j Logger object for debug logging

Please refer to Log4j website: http://logging.apache.org/log4j/index.html. The default output will be saved in the webapps/pbx/WEB-INF/work/pbx/logs folder.

Return: Log4j Logger object

 

String getMyNumber()

Description: Get phone number that is used for current call

Return: The user’s phone number

Object getObject(String objectName)

Description: Get The object bound with the specified objectName in this session

Return: The object with the specified objectName

 

String getOtherNumber()

Description: Get phone number of the other party on current call

Return: The other party’s phone number

 

String getParameter()

Description: Get a parameter of this call, the parameter can be passed in format ivr<ivr_extension>*<parameter>

Return: The parameter of the call in string

Example:

If there is an IVR flow extension named 1000, the parameter 1234 can be passed in format: ivr1000*1234

The return value of ivr.getParameter() will be 1234.

 

String getProperty( String key )

Description: Retrieve a property value from Brekeke PBX

The parameters may be set at [Options] > [Advanced].

Parameters:

key: A string of a property name

Return: A string containing the property value

 

String getTempDir()

Description: Returns the pathname string of the temporary folder

Files under this folder will be deleted when restarting the PBX service.

Return: The temporary folder pathname

 

String getTenant()

Description: Returns the tenant name as string from which IVR script is called

Return: Tenant name if it is Multi-tenant Brekeke PBX; otherwise, return a hyphen:

 

String getUserProperty( String key )

Description: Retrieve a user property value

Parameters:

key: A string of property name

Return: A string containing the property value

 

Boolean isMultitenant()

Description: Whether or not it is Multi-tenant Brekeke PBX

Return: “true” if Brekeke PBX is the multi-tenant edition; otherwise “false”

 

String play(String playlist)

Description: Play a sequence of sound files

Parameters:

playlist =  *play-resource

play-resource = dtmf-character / prompt / voice-lib / ulaw-file

dtmf-character = DIGIT / “A” / “B” / “C” / “D” / “*” / “#”

prompt = “{” prompt-name “}”

voice-lib = “{” voice-lib-name “:” voice-lib-param “}”

voice-lib-name = “name” / “date” / “time” / “number”

voice-lib-param = 1*(ALPHA / DIGIT)

ulaw-file = “(” fullpath-ulaw-file “)”

Return: DTMF character, if a button was pressed

Example:

ivr.play(“{ring}1234”);

First play the file named “ring,” which is uploaded to Brekeke PBX from [VoicePrompts], then play 1234 as DTMF.

 

String play(string playlist, boolean ignoreDTMF)

Description: Play a sequence of sound files

Parameters:

playlist =  *play-resource

play-resource = dtmf-character / prompt / voice-lib / ulaw-file

dtmf-character = DIGIT / “A” / “B” / “C” / “D” / “*” / “#”

prompt = “{” prompt-name “}”

voice-lib = “{” voice-lib-name “:” voice-lib-param “}”

voice-lib-name = “name” / “date” / “time” / “number”

voice-lib-param = 1*(ALPHA / DIGIT)

ulaw-file = “(” fullpath-ulaw-file “)”

ignoreDTMF: true or false; Stop playing with DTMF

Return: DTMF characters if button was pressed; always empty if “ignoreDTMF” is set to “true”

 

String playAndInput(String playlist, int maxDtmfLength, int timeout, String terminateDtmf, boolean removeTerm )

Description: Play a sequence of sound files and retrieve DTMF signals

Parameters:

playlist =  *play-resource

play-resource = dtmf-character / prompt / voice-lib / ulaw-file

dtmf-character = DIGIT / “A” / “B” / “C” / “D” / “*” / “#”

prompt = “{” prompt-name “}”

voice-lib = “{” voice-lib-name “:” voice-lib-param “}”

voice-lib-name = “name” / “date” / “time” / “number”

voice-lib-param = 1*(ALPHA / DIGIT)

ulaw-file = “(” fullpath-ulaw-file “)”

maxDtmfLength:

Maximum length of DTMF signals

timeout:

Length of time (milliseconds) for detecting DTMF signals

terminateDtmf:

DTMF characters used to terminate to retrieve DTMF input

removeTerm:

If true, remove terminate characters from the return value

 

Return: Detected DTMF signals

The return value will include terminateDtmf character input if parameter “removeTerm” is set to false.

                

void record( String file, int timeout, String terminateDtmf )

Description:  Record sound data

Parameters:

file: File name to store the recorded sound

timeout: Length of record time (milliseconds)

terminateDtmf: DTMF characters input to terminate recording

 

public void recordVoicemail( String user, int timeout, String terminateDtmf, Properties prop )

Description: Record sound data and store it as a voicemail file

Parameters:

user: Owner of the voicemail inbox where sound data will be stored

timeout: Length of record time (milliseconds)

terminateDtmf: DTMF characters used to terminate recording

prop: Properties object that will be stored as voicemail properties

 

public void recordPrompt( String lang, String name, int timeout, String terminateDtmf, String filedesc )

Description: Record sound data and store as a prompt file

Parameters:

lang: Language code (“en”: English, “ja”: Japanese) or “common” if language is not specified

timeout: Length of record time (milliseconds)

terminateDtmf: DTMF characters used to terminate recording

filedesc: Description of the prompt file

 

void response18x( int rescode )

Description: Send 18x response without SDP

This method can be called before method answer().

Parameters:

rescode: Response code; set 180 or 183

 

void response18x( int rescode, boolean bSDP )

Description: Send 18x response

This method can be called before method answer().

Parameters:

rescode: Response code; set 180 or 183.

bSDP: Add SDP or not to the 18x response

 

void setLanguage( String lang )

Description: Set a language code for current language

Parameters:

lang: Language code, such as “en,” “ja” or another language code if you have localized Brekeke PBX into other languages.

 

void setObject(String objectName, Object anObject)

Description: Bind an object to this session with the specified objectName

Parameters:

objectName: a string represent the name of an object

anObject: an object to be bound

 

boolean transfer( String number, int timeout )

Description: Start attended transfer

Parameters:

number: Destination phone number

timeout: Length of time to ring the transfer recipient destination (milliseconds)

Return: “true” if connection made to transfer destination; otherwise, “false”

 

 

Yes No
Suggest Edit