Answer current or specified incoming call
Takes call UID as optional argument to answer specific call.
Add text to note from currently opened contact popup
Close this program
Hide application to tray
Show application (restoring minimized or from tray)
Example: ApplicationShow(focused)
Attended transfer using two already established calls
Example: AttendedTransfer(callUid1, callUid2)
Equivalent of WinAPI Beep(frequency, time)
Example: Beep(400, 250).
Send REFER during the current call
Example: BlindTransfer(target)
Send REFER for specific call
Example: BlindTransfer2(callUid, target)
Call to specified number or URI
Returns status (0 on success) and allocated call ID. May fail if current call number reaches limit.
Check if "Break" button was pressed by the user
Allowing to interrupt scripts. Returns 0 or 1.
Check if softphone is built with video support
Can be used inside script requiring video support if it is not accidentally started with softphone version without video. Returns bool.
local videoSupported = CheckSoftphoneVideoSupport()
print("Video support: ".. tostring(videoSupported) .."\n");
Delete/unset all variables
Delete status info of custom SIP requests
Delete/unset variable with specified name
Example: ClearVariable("runcount")
Delete single custom request info
Check if specified file exists
Returning bool. Example: local exists = FileExists(filename)
Search for window by exact caption text and/or full exe path
windowName: exact window title text to match, case-sensitive (nil to not filter by title); exeName: full path of the executable that created the window, case-insensitive (nil to not filter by exe). At least one of the two must be given.
Both checks require an exact match, not partial/substring matching.
Returns window handle (as a number) if a matching window is found, 0 otherwise.
Example: local hwnd = FindWindowByCaptionAndExeName("Calculator", nil)
Make sure directory path exists, possibly creating folders recursively
Equivalent of VCL function with same name.
Generate up to 4 tones with specified amplitude and frequency
Tone generator is able to generate up to 4 sine waves at the same time, each one with separate amplitude and frequency setting. Sum of sine waves is saturated. Tone generator is placed before softvol module (software volume control sliders) in transmit chain and replaces "regular" audio source when is activated. GenerateTones function takes up to 8 parameters (up to 4 pairs of amplitude + frequency). Amplitude is interpreted as a fraction of full-scale. Calling this function without arguments stops generator. Example generating 1000 Hz at 0.2 FS + 3000 Hz at 0.1 FS: GenerateTones(0.2, 1000, 0.1, 3000)
Second version of GenerateTones function, taking call ID as first argument
Tone generator is able to generate up to 4 sine waves at the same time, each one with separate amplitude and frequency setting. Sum of sine waves is saturated. Tone generator is placed before softvol module (software volume control sliders) in transmit chain and replaces "regular" audio source when is activated. GenerateTones2 function takes up to 9 parameters (call ID + up to 4 pairs of amplitude + frequency). Amplitude is interpreted as a fraction of full-scale. Calling this function without arguments stops generator. Example generating 1000 Hz at 0.2 FS + 3000 Hz at 0.1 FS: GenerateTones2(callUid, 0.2, 1000, 0.1, 3000)
Get the name of selected audio input or output device
name, valid = GetAudioDevice(moduleName, direction, id) Enumerating audio devices one by one; moduleName = "winwave", "winwave2" or "portaudio", direction = "in" (recording device) or "out" (playback device), id = index starting from 0; returning name (string) of the device and valid (int): 1 if name is valid / device exists, 0 otherwise.
Get table/array of audio device names for specified module and direction
local devices = GetAudioDevicesList(moduleName, direction) where: moduleName = "winwave", "winwave2" or "portaudio", direction = "in" (recording device) or "out" (playback device).
Get number of audio device errors during the call
Used to detect end-of-file event for wave input files. Takes one, optional argument: call UID.
Get amplitude of received audio from the call
Returns the peak absolute value of received (RX) 16-bit PCM audio samples over the last ~100 ms, so the range is 0-32767 (linear, not dB or a normalized 0-1 value). Useful for VAD/Lenny/IVR-like applications detecting speech vs. silence.
Get BLF state of specified contact (by contact ID)
To be used in "on BLF change" (GetExecSourceId() as contact id / argument) or together with GetContactId(number). Returning number, state, remote identity number/URI, remote identity display name and call direction.
Get BLF (dialog-info) state from the button
Takes button id as argument. Returns dialog-info state as an integer: 0 = unknown (not subscribed / subscription failed), 1 = terminated, 2 = early (ringing), 3 = confirmed (in call). See also: GetBlfState() for a richer, contact-based version also returning remote identity and call direction.
Check if button is down
Example state = GetButtonDown(buttonId) -- returning 0 or 1.
Get Windows HANDLE for specified button
Check is mouse button is pressed on programmable button
Get number/URI from button configuration
Get type of the button with specified id (see enum Button::Type)
Returns button type as an integer matching enum Button::Type (buttons/ButtonType.h) - e.g. 0 = DISABLED, 1 = SPEED_DIAL, 2 = BLF, 3 = DTMF; many more types exist. When selecting a type in the "Type" dropdown of the button editor ("Edit button") window, its numeric value is shown in the help text next to the dropdown ("Numeric type value (for scripting or provisioning) = ...").
Get button ID assigned to current or specified call
Takes one, optional argument: call UID.
Get name of codec used during current or specified call
Takes one, optional argument: call UID.
Get time in ms from the call confirmation
Returns milliseconds passed since call was confirmed. If call was not confirmed or does not exist, nothing is returned. Takes one, optional argument: call UID.
Get time in ms from the call start/creation
Returns milliseconds passed since call was created (call incoming event or making call). Takes one, optional argument: call UID.
Get full text of initial received INVITE
Takes one, optional argument: call UID.
Get number/URI of caller/callee from current or specified call
Takes one, optional argument: call UID.
Get name of caller/callee from current or specified call
Takes one, optional argument: call UID. Returns 0 results if the call is not found, otherwise 1 result: display name or (depending on settings) PAI display name.
Get SIP Reason associated with current or specified call
Takes one, optional argument: call UID. Returns reason from request line or from Reason line like "Call completed elsewhere"
Get state of current or specified call
Takes one, optional argument: call UID.
Get the description of specified call state value
Get the name of specified call state value
Get the translated description of specified call state value
Get the translated name of specified call state value
Get call UID assigned to specified line button
Allows to e.g. create answer/hangup button associated with specified line button. Example: local callUid = GetCallUidFromLineButton(buttonId)
Get a table with UIDs of currently active calls
Get clipboard content as text
Get contact ID for specified number/URI
Get number description from phonebook
Get UID of current call, 0 = invalid/none
Get details of a sent custom SIP request
Takes custom request UID (from SendCustomRequest()) as argument. Returns 3 values: uri (target URI), method (SIP method), extraHeaderLines (extra header lines sent with the request). Returns no values if the given UID is unknown (e.g. already removed via DeleteCustomRequest()). See also: GetCustomRequestReply() for the reply to this request.
Get reply for custom SIP request
Takes custom request UID (from SendCustomRequest()) as argument. Returns 3 values: haveReply (1 if a reply or timeout was already received, 0 if still waiting), error (0 = reply received normally, non-zero = transport/timeout error), sipStatusCode (valid only if error == 0). Returns no values if the given UID is unknown (e.g. already removed via DeleteCustomRequest()). Example: local haveReply, err, sipStatusCode = GetCustomRequestReply(requestUid)
Get full text of received reply for custom request
Get number (string) from softphone dial edit
Get name and full path of this executable
Get ID of object that triggered script (depending on trigger type)
See also: GetExecSourceType().
Get type of event that triggered script execution (see: enum ScriptSource)
Returns a ScriptSource enum value (see ScriptSource.h) identifying why this script is running - e.g. button press, incoming call state change, timer, etc. Use GetExecSourceTypeName() (called with no argument) to get this as a human-readable name instead of a number. See also: GetExecSourceId().
Get name of type of script execution source
GetExecSourceTypeName(typeId) - get name of specific type GetExecSourceTypeName() - get name of source type that triggered this script execution
Get hold state for current or specified call
Examples: local state = GetHold() local state2 = GetHold(callUid)
Get number/URI that was initially dialed by the user
Get mute state for current call or specified call
Takes callUid as optional argument, returns 0/1.
Get SIP reply line from the call that ended
Get status code of call that ended
Get folder name where settings and other files are stored
Get name of recording file from current call or call that ended
Check if recording is running for current or specified call
Takes one, optional argument: call UID.
Check if softphone is recording at the moment
Get the description of specified registration state value
Get the name of specified call registration value
Get the translated description of specified registration state value
Get the translated name of specified registration state value
Check if softphone is registered
Get DTMF from receiving queue, empty string if queue is empty
Get body text of the incoming SIP SIMPLE MESSAGE that triggered this script
To be used in "on SIP SIMPLE message (RX)" event only.
Get Content-Type of the incoming SIP SIMPLE MESSAGE that triggered this script
To be used in "on SIP SIMPLE message (RX)" event only.
Get sender of the incoming SIP SIMPLE MESSAGE that triggered this script
To be used in "on SIP SIMPLE message (RX)" event only.
Get current state of audio paging ("streaming") feature
Returns 0 (idle) or 1 (actively sending paging audio). Not tied to a specific call - reflects the audio paging/broadcast feature shown as "Streaming..." in the main window, started via a "paging TX" button.
Get user name from account settings
Get variable value and isSet flag for variable with specified name
Example: local count, var_isset = GetVariable("runcount")
Get current state of ZRTP encryption for current or specified call
Returns session ID, active/inactive state, SAS code, cipher, verification state. Takes one, optional argument: call UID.
Disconnect or reject current incoming call
Examples:
Hangup()
Hangup(sipCode, reasonText)
Disconnect or reject specific incoming call
Examples:
Hangup2(callUid)
Hangup2(callUid, sipCode, reasonText)
Disconnect all calls
Example: HangupAll()
Hide tray notifier window
Display modal dialog allowing to take text input from the user
Example: local text, isAccepted = InputQuery(caption, prompt, defaultText).
Check if current or specified call is incoming
Takes one, optional argument: call UID.
Show/hide main menu (e.g. in kiosk applications)
Show standard WinAPI MessageBox
Examples:
MessageBox("message with just [OK] button", "message title", 0)
MessageBox("message with ICON_INFORMATION", "message title", 64)
local res = MessageBox("message with MB_YESNO and question icon", "message title", 4+32)
if res == 6 then
ShowMessage("\"Yes\" was pressed")
else
ShowMessage("Result is other than \"Yes\"")
end
Enable/disable specified plugin
Example: PluginEnable("TTS.dll", 0/1)
Send text to specified plugin
PluginSendMessageText(dllName, buffer).
dllName: file name of the plugin DLL that should receive the message.
buffer: arbitrary text, interpreted by the plugin itself - there is no fixed protocol/format, it depends on the specific plugin.
Returns -1 if dllName or buffer is missing.
Example: PluginSendMessageText("myplugin.dll", "some text")
Programmatically press button
Clear specified queue
Get number of elements in specified queue
Get value from specified queue
Example: local value, isValid = QueuePop(queueName)
Push string value to queue with specified name
Read again contacts from default JSON file
This function can be used to reload phonebook from file after provisioning, e.g. after fetching JSON file using curl using provisioning script.
Read contacts from XML Yealink-like file
Start recording current or specified call
RecordStart(filename, channels, side, fileFormat, bitrate, optionalCallUid). channels: 1 = mono, 2 = stereo. side: 0 = both parties mixed, 1 = local/microphone only, 2 = remote only. fileFormat: 0 = WAV, 1 = Opus/OGG. bitrate: bits/sec, used for Opus only; 0 or omitted defaults to 64000. optionalCallUid: current call if omitted.
Redial - action identical to redial button
Make call using number/URI from last outgoing call.
Rescan available audio devices
Re-register SIP account
Clear whole call state
Use with care!
Force an immediate re-SUBSCRIBE of presence and dialog-info (BLF) subscriptions
Useful e.g. to recover after the SIP server loses subscription state without waiting for the normal retry/refresh interval.
Send custom SIP request within an existing call's dialog
Unlike SendCustomRequest(), this reuses the call's own dialog (Call-ID, tags), so the peer recognizes it as belonging to the call - required by most peers for in-call signaling such as sending INFO, otherwise they may reply 481 Call/Transaction Does Not Exist. Example: requestUid = SendCustomCallRequest(callUid, method, extraHeaderLines) requestUid is > 0 on success extraHeaderLines parameter is optional
Send custom SIP request
Example: requestUid = SendCustomRequest(uri, method, extraHeaderLines) requestUid is > 0 on success extraHeaderLines parameter is optional
Send DTMF symbols during the call
Accepts single DTMF or whole string
Send SIP SIMPLE message
Example: SendTextMessage(target, text, sendImmediately) Opens text messaging window and optionally sends immediately text.
Set part of application status (status bar text + tray icon hint)
SetAppStatus(id, priority, text).
id: any string of your choosing that identifies this particular status entry, so a later call with the same id replaces it (or removes it, if text = "").
priority: lower number = higher priority.
text: the status text itself.
The status bar shows only the highest-priority (lowest-numbered) active status, while the tray icon hint lists all active statuses combined.
Example: SetAppStatus("myPlugin", 10, "Connected")
Set the process exit code returned to the OS on exit
Does not close the application by itself - combine with ApplicationClose(). Note: Lua's own os.exit(code) is unreliable in this application (it may not propagate the requested code) - use this function instead. Example: SetExitCode(1); ApplicationClose() To test from the Windows command line: launch with "start /wait "" softphone.exe" (running the exe directly does not work - it must be launched via start /wait), trigger the script that calls SetExitCode()+ApplicationClose(), then once the prompt returns run "echo %errorlevel%" to see the code. The empty "" after /wait is a required placeholder window title, needed so start does not mistake a quoted exe path for the title.
Set text for the first line of the button
Example: SetButtonCaption(buttonId, text).
Set text for the second line of the button
Example: SetButtonCaption2(buttonId, text).
Change button state to down/pressed
Example: SetButtonDown(buttonId, buttonState).
Set button bitmap
Prevent button from being pressed, set its state to inactive
Show/hide button
Overwrite both initial call target and current URI of the call
Copy text to clipboard
Set current call to call with specified UID
Returns 0 on success.
Set text on softphone dialing edit control
Set "handled" flag associated with script trigger event
Possibility of skipping default event handling after script was called (replacing default behavior with script), Example: SetHandled(1).
Set hold state for specified call
Example: SetHold(callUid, 1).
Override number dialed by the user
Set mute state for transmitted audio (microphone) of the specified call
Examples: SetMute(callUid, 1) -- mute SetMute(callUid, 0) -- unmute
Change tray icon bitmap
Set value for variable with specified name
Example: SetVariable("runcount", count).
Run another application or open a file/URL (WinAPI ShellExecute wrapper)
Direct wrapper for the WinAPI ShellExecute(NULL, verb, file, parameters, directory, showCmd) function - see its documentation for exact parameter/return value meaning.
verb: operation, e.g. "open", "explore", "print" (nil/"" for default)
file: file, folder, URL or executable to run
parameters: command-line parameters if file is an executable (nil if none)
directory: working directory (nil for current)
showCmd: window show state, e.g. 0 = hidden, 1 = normal (SW_* constant)
Returns instance handle (> 32) on success, or an error code (<= 32) on failure.
Example: ShellExecute("open", "https://example.com", nil, nil, 1)
Show and bring to front log window
Show simple message dialog
Example: ShowMessage("text")
Show tray notifier window with specified description, URI, incoming state, call UID
Example: ShowTrayNotifier(description, uri, dirIncoming, callUid)
Pause script for specified time (miliseconds)
Function returns 1 if it exited due to user break, returns 0 if full delay passed. Example: Sleep(100).
Pause script for specified time (miliseconds)
Function returns 1 if it exited due to user break, returns 0 if full delay passed. Example: SleepWithCheckBreak(100). Works same way as Sleep(delay), it is alias with more meaningful name.
Change audio output during the call
Example: SwitchAudioPlayer("winwave2", "Headphones").
Change audio output for the specified call
Example: SwitchAudioPlayer2(callUid, "winwave2", "Headphones").
Change audio source during the call
Example: SwitchAudioSource("aufile", "file.wav").
Change audio source for the specified call
Example: SwitchAudioSource2(callUid, "aufile", "file.wav").
Change audio source for current or specified call to default/configured
Example: SwitchAudioSourceToConfigured(optional_callUid).
Change video source during the call
Example: SwitchVideoSource("avformat", "file.mp4").
Change video source for the specified call
Example: SwitchVideoSource2(callUid, "avformat", "file.mp4").
Toggle hold state for current or specified call
Examples: ToggleHold(callUid) ToggleHold()
Toggle (reverse) mute state for current or specified call
Takes callUid as optional argument.
Unregister SIP account
Update single button settings with JSON
Provisioning or changing settings while running for a single button. JSON is merged. Example:
UpdateButton(BUTTON_ID, '{"caption":" REDIAL"}')
Update buttons settings with JSON
Provisioning for buttons or changing settings while running. JSON is merged. Example:
UpdateButtons('{"btnConf":[{"caption":" REDIAL"}]}')
Update main settings with JSON
Application provisioning or changing settings while running. JSON is merged. Example:
local settings = [[
{
"uaConf" : {
"audioCfgAlert" : {
"volume" : 0.1
},
"audioCfgRing" : {
"volume" : 0.2
}
}
}
]]
UpdateSettings(settings)
WinAPI Beep equivalent
Same as Beep, example: Beep(frequencyHz, timeMs)
WinAPI FindWindow equivalent
Function returning array of computer IPs
WinAPI GetAsyncKeyState equivalent
Example use: modify button behavior depending on Ctrl/Alt/Shift state.
WinAPI MessageBox equivalent
WinAPI PlaySound equivalent
WinAPI SendMessage equivalent
Example use: sending WM_CLOSE to other application
WinAPI keybd_event equivalent but without 4th parameter