tSIP - custom Lua functions

Generated by tSIP 0.03.14.05, built Sep 9 2026, 20:11:46 (with video support)

Answer

Answer current or specified incoming call

Takes call UID as optional argument to answer specific call.

AppendContactNoteText

Add text to note from currently opened contact popup

ApplicationClose

Close this program

ApplicationHide

Hide application to tray

ApplicationShow

Show application (restoring minimized or from tray)

Example: ApplicationShow(focused)

AttendedTransfer

Attended transfer using two already established calls

Example: AttendedTransfer(callUid1, callUid2)

Beep

Equivalent of WinAPI Beep(frequency, time)

Example: Beep(400, 250).

BlindTransfer

Send REFER during the current call

Example: BlindTransfer(target)

BlindTransfer2

Send REFER for specific call

Example: BlindTransfer2(callUid, target)

Call

Call to specified number or URI

Returns status (0 on success) and allocated call ID. May fail if current call number reaches limit.

CheckBreak

Check if "Break" button was pressed by the user

Allowing to interrupt scripts. Returns 0 or 1.

CheckSoftphoneVideoSupport

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");

ClearAllVariables

Delete/unset all variables

ClearCustomRequests

Delete status info of custom SIP requests

ClearVariable

Delete/unset variable with specified name

Example: ClearVariable("runcount")

DeleteCustomRequest

Delete single custom request info

FileExists

Check if specified file exists

Returning bool.
Example: local exists = FileExists(filename)

FindWindowByCaptionAndExeName

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)

ForceDirectories

Make sure directory path exists, possibly creating folders recursively

Equivalent of VCL function with same name.

GenerateTones

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)

GenerateTones2

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)

GetAudioDevice

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.

GetAudioDevicesList

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).

GetAudioErrorCount

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.

GetAudioRxSignalLevel

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.

GetBlfState

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.

GetButtonBlfState

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.

GetButtonDown

Check if button is down

Example state = GetButtonDown(buttonId) -- returning 0 or 1.

GetButtonHandle

Get Windows HANDLE for specified button

GetButtonMouseDown

Check is mouse button is pressed on programmable button

GetButtonNumber

Get number/URI from button configuration

GetButtonType

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) = ...").

GetCallButtonId

Get button ID assigned to current or specified call

Takes one, optional argument: call UID.

GetCallCodecName

Get name of codec used during current or specified call

Takes one, optional argument: call UID.

GetCallDurationFromConfirmed

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.

GetCallDurationFromStart

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.

GetCallInitialRxInvite

Get full text of initial received INVITE

Takes one, optional argument: call UID.

GetCallPeer

Get number/URI of caller/callee from current or specified call

Takes one, optional argument: call UID.

GetCallPeerName

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.

GetCallReason

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"

GetCallState

Get state of current or specified call

Takes one, optional argument: call UID.

GetCallStateDescription

Get the description of specified call state value

GetCallStateName

Get the name of specified call state value

GetCallStateTranslatedDescription

Get the translated description of specified call state value

GetCallStateTranslatedName

Get the translated name of specified call state value

GetCallUidFromLineButton

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)

GetCalls

Get a table with UIDs of currently active calls

GetClipboardText

Get clipboard content as text

GetContactId

Get contact ID for specified number/URI

GetContactName

Get number description from phonebook

GetCurrentCallUid

Get UID of current call, 0 = invalid/none

GetCustomRequest

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.

GetCustomRequestReply

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)

GetCustomRequestReplyText

Get full text of received reply for custom request

GetDial

Get number (string) from softphone dial edit

GetExeName

Get name and full path of this executable

GetExecSourceId

Get ID of object that triggered script (depending on trigger type)

See also: GetExecSourceType().

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().

GetExecSourceTypeName

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

GetHold

Get hold state for current or specified call

Examples:
local state = GetHold()
local state2 = GetHold(callUid)

GetInitialCallTarget

Get number/URI that was initially dialed by the user

GetMute

Get mute state for current call or specified call

Takes callUid as optional argument, returns 0/1.

GetPreviousCallReplyLine

Get SIP reply line from the call that ended

GetPreviousCallStatusCode

Get status code of call that ended

GetProfileDir

Get folder name where settings and other files are stored

GetRecordFile

Get name of recording file from current call or call that ended

GetRecorderState

Check if recording is running for current or specified call

Takes one, optional argument: call UID.

GetRecordingState

Check if softphone is recording at the moment

GetRegStateDescription

Get the description of specified registration state value

GetRegStateName

Get the name of specified call registration value

GetRegStateTranslatedDescription

Get the translated description of specified registration state value

GetRegStateTranslatedName

Get the translated name of specified registration state value

GetRegistrationState

Check if softphone is registered

GetRxDtmf

Get DTMF from receiving queue, empty string if queue is empty

GetSimpleMessageBody

Get body text of the incoming SIP SIMPLE MESSAGE that triggered this script

To be used in "on SIP SIMPLE message (RX)" event only.

GetSimpleMessageContentType

Get Content-Type of the incoming SIP SIMPLE MESSAGE that triggered this script

To be used in "on SIP SIMPLE message (RX)" event only.

GetSimpleMessageFrom

Get sender of the incoming SIP SIMPLE MESSAGE that triggered this script

To be used in "on SIP SIMPLE message (RX)" event only.

GetStreamingState

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.

GetUserName

Get user name from account settings

GetVariable

Get variable value and isSet flag for variable with specified name

Example: local count, var_isset = GetVariable("runcount")

GetZrtpState

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.

Hangup

Disconnect or reject current incoming call

Examples:
    Hangup()
    Hangup(sipCode, reasonText)

Hangup2

Disconnect or reject specific incoming call

Examples:
    Hangup2(callUid)
    Hangup2(callUid, sipCode, reasonText)

HangupAll

Disconnect all calls

Example: HangupAll()

HideTrayNotifier

Hide tray notifier window

InputQuery

Display modal dialog allowing to take text input from the user

Example: local text, isAccepted = InputQuery(caption, prompt, defaultText).

IsCallIncoming

Check if current or specified call is incoming

Takes one, optional argument: call UID.

Show/hide main menu (e.g. in kiosk applications)

MessageBox

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  

PluginEnable

Enable/disable specified plugin

Example: PluginEnable("TTS.dll", 0/1)

PluginSendMessageText

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")

ProgrammableButtonClick

Programmatically press button

QueueClear

Clear specified queue

QueueGetSize

Get number of elements in specified queue

QueuePop

Get value from specified queue

Example: local value, isValid = QueuePop(queueName)

QueuePush

Push string value to queue with specified name

ReadContacts

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.

ReadXmlContacts

Read contacts from XML Yealink-like file

RecordStart

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

Redial - action identical to redial button

Make call using number/URI from last outgoing call.

RefreshAudioDevicesList

Rescan available audio devices

Reregister

Re-register SIP account

ResetCall

Clear whole call state

Use with care!

Resubscribe

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.

SendCustomCallRequest

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

SendCustomRequest

Send custom SIP request

Example: requestUid = SendCustomRequest(uri, method, extraHeaderLines)
requestUid is > 0 on success
extraHeaderLines parameter is optional

SendDtmf

Send DTMF symbols during the call

Accepts single DTMF or whole string

SendTextMessage

Send SIP SIMPLE message

Example: SendTextMessage(target, text, sendImmediately)
Opens text messaging window and optionally sends immediately text.

SetAppStatus

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")

SetApplicationExitCode

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.

SetButtonCaption

Set text for the first line of the button

Example: SetButtonCaption(buttonId, text).

SetButtonCaption2

Set text for the second line of the button

Example: SetButtonCaption2(buttonId, text).

SetButtonDown

Change button state to down/pressed

Example: SetButtonDown(buttonId, buttonState).

SetButtonImage

Set button bitmap

SetButtonInactive

Prevent button from being pressed, set its state to inactive

SetButtonVisible

Show/hide button

SetCallTarget

Overwrite both initial call target and current URI of the call

SetClipboardText

Copy text to clipboard

SetCurrentCallUid

Set current call to call with specified UID

Returns 0 on success.

SetDial

Set text on softphone dialing edit control

SetHandled

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).

SetHold

Set hold state for specified call

Example: SetHold(callUid, 1).

SetInitialCallTarget

Override number dialed by the user

SetMute

Set mute state for transmitted audio (microphone) of the specified call

Examples:
SetMute(callUid, 1) -- mute
SetMute(callUid, 0) -- unmute

SetTrayIcon

Change tray icon bitmap

SetVariable

Set value for variable with specified name

Example: SetVariable("runcount", count).

ShellExecute

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)

ShowLogWindow

Show and bring to front log window

ShowMessage

Show simple message dialog

Example: ShowMessage("text")

ShowTrayNotifier

Show tray notifier window with specified description, URI, incoming state, call UID

Example: ShowTrayNotifier(description, uri, dirIncoming, callUid)

Sleep

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).

SleepWithCheckBreak

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.

SwitchAudioPlayer

Change audio output during the call

Example: SwitchAudioPlayer("winwave2", "Headphones").

SwitchAudioPlayer2

Change audio output for the specified call

Example: SwitchAudioPlayer2(callUid, "winwave2", "Headphones").

SwitchAudioSource

Change audio source during the call

Example: SwitchAudioSource("aufile", "file.wav").

SwitchAudioSource2

Change audio source for the specified call

Example: SwitchAudioSource2(callUid, "aufile", "file.wav").

SwitchAudioSourceToConfigured

Change audio source for current or specified call to default/configured

Example: SwitchAudioSourceToConfigured(optional_callUid).

SwitchVideoSource

Change video source during the call

Example: SwitchVideoSource("avformat", "file.mp4").

SwitchVideoSource2

Change video source for the specified call

Example: SwitchVideoSource2(callUid, "avformat", "file.mp4").

ToggleHold

Toggle hold state for current or specified call

Examples:
ToggleHold(callUid)
ToggleHold()

ToggleMute

Toggle (reverse) mute state for current or specified call

Takes callUid as optional argument.

Unregister

Unregister SIP account

UpdateButton

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"}')

UpdateButtons

Update buttons settings with JSON

Provisioning for buttons or changing settings while running. JSON is merged. Example:
UpdateButtons('{"btnConf":[{"caption":"    REDIAL"}]}')

UpdateSettings

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

WinAPI Beep equivalent

Same as Beep, example: Beep(frequencyHz, timeMs)

winapi.FindWindow

WinAPI FindWindow equivalent

winapi.GetAdaptersInfoIp

Function returning array of computer IPs

winapi.GetAsyncKeyState

WinAPI GetAsyncKeyState equivalent

Example use: modify button behavior depending on Ctrl/Alt/Shift state.

winapi.MessageBox

WinAPI MessageBox equivalent

winapi.PlaySound

WinAPI PlaySound equivalent

winapi.SendMessage

WinAPI SendMessage equivalent

Example use: sending WM_CLOSE to other application

winapi.keybd_event

WinAPI keybd_event equivalent but without 4th parameter