TONE_DETECT(freq[,duration_ms,options])
Description
The TONE_DETECT function detects a single-frequency tone and keeps track of how many times the tone has been detected.
When reading this function (instead of writing), supply tx to get the number of times a tone has been detected in the TX direction and rx to get the number of times a tone has been detected in the RX direction.
intercept2600
same => n,Set(TONE_DETECT(2600,1000,g(got-2600,s,1))=) ; detect 2600 Hz
same => n,Wait(15)
same => n,NoOp(${TONE_DETECT(rx)})
dropondialtone
same => n,Set(TONE_DETECT(0,,bg(my-hangup,s,1))=) ; disconnect a call if we hear a busy signal
same => n,Goto(somewhere-else)
same => n(myhangup),Hangup()
removedetector
same => n,Set(TONE_DETECT(0,,x)=) ; remove the detector from the channel
Arguments
freqrequired - Frequency of the tone to detect. To disable frequency detection completely (e.g. for signal detection only), specify 0 for the frequency.duration_ms- Minimum duration of tone, in ms. Default is 500ms. Using a minimum duration under 50ms is unlikely to produce accurate results.optionsa- Match immediately on Special Information Tones, instead of or in addition to a particular frequency.b- Match immediately on a busy signal, instead of or in addition to a particular frequency.c- Match immediately on a dial tone, instead of or in addition to a particular frequency.d- Custom decibel threshold to use. Default is 16.e- Automatically end detection after desired number of hits (as specified in thenoption.g- Go to the specified contextA named section of the dialplan that groups extensions. Calls enter a specific context and can only reach extensions visible from it, making contexts the basic unit of call routing and security.,exten,priority if tone is received on this channelA single call leg passing through Asterisk. Channels represent connections to endpoints and are what dialplan applications act on.. Detection will not end automatically, unless theeoption is also specified.h- Go to the specified context,exten,priority if tone is transmitted on this channel. Detection will not end automatically, unless theeoption is also specified.n- Number of times the tone should be detected (subject to the provided timeout) before going to the destination provided in thegorhoption. Default is 1.p- Match immediately on audible ringback tone, instead of or in addition to a particular frequency.r- Apply to received frames only. Default is both directions.s- Squelch tone.t- Apply to transmitted frames only. Default is both directions.x- Destroy the detector (stop detection).
User Notes
Know a tip or gotcha for this topic? Share it below and help others.
Contribute a note
Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.
Related
Functions
ABS()
AES_DECRYPT()
AES_ENCRYPT()
AGC()
AGENT()
AMI_CLIENT()
ARRAY()
AST_CONFIG()
AST_SORCERY()
BASE64_DECODE()
BASE64_ENCODE()
BASENAME()
BLACKLIST()
CALENDAR_BUSY()
CALENDAR_EVENT()
CALENDAR_QUERY()
CALENDAR_QUERY_RESULT()
CALENDAR_WRITE()
CALLCOMPLETION()
CALLERID()
CALLERPRES()
CDR()
CDR_PROP()
CHANNEL()
CHANNELS()
CHANNEL_EXISTS()
CHECKSIPDOMAIN()
CONFBRIDGE()
CONFBRIDGE_CHANNELS()
CONFBRIDGE_INFO()
CONNECTEDLINE()
CSV_QUOTE()
CURL()
CURLOPT()
CUT()
DAHDI_CHANNEL()
DB()
DB_DELETE()
DB_EXISTS()
DB_KEYCOUNT()
DB_KEYS()
DEC()
DELETE()
DENOISE()
DEVICE_STATE()
DIALGROUP()
DIALPLAN_EXISTS()
DIGIT_SUM()
DIRNAME()
DUNDILOOKUP()
DUNDIQUERY()
DUNDIRESULT()
ENUMLOOKUP()
ENUMQUERY()
ENUMRESULT()
ENV()
EVAL()
EVAL_EXTEN()
EVAL_SUB()
EXCEPTION()
EXISTS()
EXPORT()
EXTENSION_STATE()
FAXOPT()
FEATURE()
FEATUREMAP()
FIELDNUM()
FIELDQTY()
FILE()
FILE_COUNT_LINE()
FILE_FORMAT()
FILTER()
FRAME_DROP()
FRAME_TRACE()
GEOLOC_PROFILE()
GLOBAL()
GLOBAL_DELETE()
GLOBAL_EXISTS()
GROUP()
GROUP_COUNT()
GROUP_LIST()
GROUP_MATCH_COUNT()
HANGUPCAUSE()
HANGUPCAUSE_KEYS()
HASH()
HASHKEYS()
HINT()
HOLD_INTERCEPT()
IAXPEER()
IAXVAR()
ICONV()
IF()
IFMODULE()
IFTIME()
IMPORT()
INC()
ISNULL()
JABBER_RECEIVE()
JABBER_STATUS()
JITTERBUFFER()
JSON_DECODE()
KEYPADHASH()
LEN()
LISTFILTER()
LOCAL()
LOCAL_PEEK()
LOCK()
LOG_GROUP()
LTRIM()
MAILBOX_EXISTS()
MASTER_CHANNEL()
MATH()
MAX()
MD5()
MEETME_INFO()
MESSAGE()
MESSAGE_DATA()
MIN()
MINIVMACCOUNT()
MINIVMCOUNTER()
MIXMONITOR()
MUTEAUDIO()
ODBC()
ODBC_FETCH()
PARK_GET_CHANNEL()
PASSTHRU()
PERIODIC_HOOK()
PITCH_SHIFT()
PJSIP_AOR()
PJSIP_CONTACT()
PJSIP_DIAL_CONTACTS()
PJSIP_DTMF_MODE()
PJSIP_ENDPOINT()
PJSIP_HEADER()
PJSIP_HEADERS()
PJSIP_HEADER_PARAM()
PJSIP_INHERITABLE_HEADER()
PJSIP_MEDIA_OFFER()
PJSIP_MOH_PASSTHROUGH()
PJSIP_PARSE_URI()
PJSIP_PARSE_URI_FROM()
PJSIP_RESPONSE_HEADER()
PJSIP_RESPONSE_HEADERS()
PJSIP_SEND_SESSION_REFRESH()
PJSIP_TRANSFER_HANDLING()
POLARITY()
POP()
PP_EACH_EXTENSION()
PP_EACH_USER()
PRESENCE_STATE()
PUSH()
QUEUE_EXISTS()
QUEUE_GET_CHANNEL()
QUEUE_MEMBER()
QUEUE_MEMBER_COUNT()
QUEUE_MEMBER_LIST()
QUEUE_MEMBER_PENALTY()
QUEUE_VARIABLES()
QUEUE_WAITING_COUNT()
QUOTE()
RAND()
REALTIME()
REALTIME_DESTROY()
REALTIME_FIELD()
REALTIME_HASH()
REALTIME_STORE()
RECORDING_INFO()
REDIRECTING()
REGEX()
REPLACE()
RTRIM()
SAYFILES()
SCRAMBLE()
SET()
SHA1()
SHARED()
SHELL()
SHIFT()
SIPPEER()
SIP_HEADER()
SIP_HEADERS()
SMDI_MSG()
SMDI_MSG_RETRIEVE()
SORT()
SPEECH()
SPEECH_ENGINE()
SPEECH_GRAMMAR()
SPEECH_RESULTS_TYPE()
SPEECH_SCORE()
SPEECH_TEXT()
SPRINTF()
SQL_ESC()
SQL_ESC_BACKSLASHES()
SRVQUERY()
SRVRESULT()
STACK_PEEK()
STAT()
STIR_SHAKEN()
STIR_SHAKEN_ATTESTATION()
STRBETWEEN()
STRFTIME()
STRPTIME()
STRREPLACE()
SYSINFO()
TALK_DETECT()
TESTTIME()
TIMEOUT()
TOLOWER()
TONE_DETECT()
TOUPPER()
TRIM()
TRYLOCK()
TXTCIDNAME()
UNLOCK()
UNSHIFT()
URIDECODE()
URIENCODE()
UUID()
VALID_EXTEN()
VARIABLE_EXISTS()
VERSION()
VMCOUNT()
VM_INFO()
VOLUME()