How to use Asterisk Dialplan Functions on Oracle Linux 9.3
To Use Asterisk Dialplan Functions On Oracle Linux 9.3
Introduction
Asterisk functions are very similar to functions in many programming languages. Functions are Sophisticated subroutines that help you manipulate data in various ways. Callable from within Dialplan and Asterisk's various interfaces.
Procedure Steps
Step 1: Check the OS version by using the below command.
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2: Goto the following location by using the below command..
[root@linuxhelp ~]# cd /etc/asterisk/
[root@linuxhelp asterisk]#
Step 3: Edit the extensions.conf file for use dialplan functions by using the below command.
root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Result for my function: ${CALLERID(all)})
same => n,Dial(PJSIP/110, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
Step 4: Login to the asterisk console by using the below command.
[root@linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 7590)
linuxhelp*CLI>
Step 5: Reload the dialplan by using the below command.
linuxhelp*CLI> dialplan reload
Dialplan reloaded.
-- Time to scan old dialplan and merge leftovers back into the new: 0.000039 sec
-- Time to restore hints and swap in new dialplan: 0.000007 sec
-- Time to delete the old dialplan: 0.000009 sec
-- Total time merge_contexts_delete: 0.000055 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Step 6: Make a Call to Check Dialplan Functions by using Softphone Softwares.
linuxhelp*CLI>
-- Executing [110@internal:1] NoOp("PJSIP/111-0000000b", "Result for my function: "linuxhelp2" <111>") in new stack
-- Executing [110@internal:2] Dial("PJSIP/111-0000000b", "PJSIP/110, 20") in new stack
-- Called PJSIP/110
-- PJSIP/110-0000000c is ringing
-- Nobody picked up in 20000 ms
-- Executing [110@internal:3] Playback("PJSIP/111-0000000b", "sorry_didnt_get") in new stack
> 0x7f48000305a0 -- Strict RTP learning after remote address set to: 192.168.6.102:4010
-- <PJSIP/111-0000000b> Playing 'sorry_didnt_get.ulaw' (language 'en')
> 0x7f48000305a0 -- Strict RTP switching to RTP target address 192.168.6.102:4010 as source
-- Executing [110@internal:4] Hangup("PJSIP/111-0000000b", "") in new stack
== Spawn extension (internal, 110, 4) exited non-zero on 'PJSIP/111-0000000b'
Step 7: Check all the functions of asterisk by using the below command.
linuxhelp*CLI> core show functions
Installed Custom Functions:
--------------------------------------------------------------------------------
AMI_CLIENT AMI_CLIENT(loginname,field) Checks attributes of manager accounts
ARRAY ARRAY(var1[,var2[,...][,varN]]) Allows setting multiple variables at once.
AST_SORCERY AST_SORCERY(module_name,object_type Get a field from a sorcery object
CALLERID CALLERID(datatype[,CID]) Gets or sets Caller*ID data on the channel.
CDR CDR(name[,options]) Gets or sets a CDR variable.
CDR_PROP CDR_PROP(name) Set a property on a channel's CDR.
CONFBRIDGE CONFBRIDGE(type,option) Set a custom dynamic bridge, user, or menu profile on a channel for the ConfBridge application using the same options available in confbridge.conf.
CONFBRIDGE_CHANNELS CONFBRIDGE_CHANNELS(type,conf) Get a list of channels in a ConfBridge conference.
CONFBRIDGE_INFO CONFBRIDGE_INFO(type,conf) Get information about a ConfBridge conference.
CONNECTEDLINE CONNECTEDLINE(datatype[,i]) Gets or sets Connected Line data on the channel.
CSV_QUOTE CSV_QUOTE(string) Quotes a given string for use in a CSV file, escaping embedded quotes as necessary
DEVICE_STATE DEVICE_STATE(device) Get or Set a device state.
EVAL EVAL(variable) Evaluate stored variables
EXCEPTION EXCEPTION(field) Retrieve the details of the current dialplan exception.
FEATURE FEATURE(option_name) Get or set a feature option on a channel.
FEATUREMAP FEATUREMAP(feature_name) Get or set a feature map to a given value on a specific channel.
FIELDNUM FIELDNUM(varname,delim,value) Return the 1-based offset of a field in a list
FIELDQTY FIELDQTY(varname,delim) Count the fields with an arbitrary delimiter
FILTER FILTER(allowed-chars,string) Filter the string to include only the allowed characters
HASH HASH(hashname[,hashkey]) Implementation of a dialplan associative array
HASHKEYS HASHKEYS(hashname) Retrieve the keys of the HASH() function.
HINT HINT(extension[@context][,options]) Get the devices set for a dialplan hint.
KEYPADHASH KEYPADHASH(string) Hash the letters in string into equivalent keypad numbers.
LEN LEN(string) Return the length of the string given.
LISTFILTER LISTFILTER(varname,delim,value) Remove an item from a list, by name.
LOCAL LOCAL(varname) Manage variables local to the gosub stack frame.
LOCAL_PEEK LOCAL_PEEK(n,varname) Retrieve variables hidden by the local gosub stack frame.
LTRIM LTRIM(string) Trim leading whitespace in a string
MESSAGE MESSAGE(argument) Create a message or read fields from a message.
MESSAGE_DATA MESSAGE_DATA(argument) Read or write custom data attached to a message.
PASSTHRU PASSTHRU([string]) Pass the given argument back as a value.
PJSIP_DIAL_CONTACTS PJSIP_DIAL_CONTACTS(endpoint[,aor[, Return a dial string for dialing all contacts on an AOR.
PJSIP_DTMF_MODE PJSIP_DTMF_MODE() Get or change the DTMF mode for a SIP call.
PJSIP_ENDPOINT PJSIP_ENDPOINT(name,field) Get information about a PJSIP endpoint
PJSIP_HEADER PJSIP_HEADER(action,name[,number]) Gets headers from an inbound PJSIP channel. Adds, updates or removes the specified SIP header from an outbound PJSIP channel.
PJSIP_HEADERS PJSIP_HEADERS([prefix]) Gets the list of SIP header names from an INVITE message.
PJSIP_HEADER_PARAM PJSIP_HEADER_PARAM(header_name,para Get or set header/URI parameters on a PJSIP channel.
PJSIP_MEDIA_OFFER PJSIP_MEDIA_OFFER(media) Media and codec offerings to be set on an outbound SIP channel prior to dialing.
PJSIP_MOH_PASSTHROUG PJSIP_MOH_PASSTHROUGH() Get or change the on-hold behavior for a SIP call.
PJSIP_PARSE_URI PJSIP_PARSE_URI(uri,type) Parse an uri and return a type part of the URI.
PJSIP_RESPONSE_HEADE PJSIP_RESPONSE_HEADER(action,name[, Gets headers of 200 response from an outbound PJSIP channel.
PJSIP_RESPONSE_HEADE PJSIP_RESPONSE_HEADERS([prefix]) Gets the list of SIP header names from the 200 response of INVITE message.
PJSIP_SEND_SESSION_R PJSIP_SEND_SESSION_REFRESH([update_ W/O: Initiate a session refresh via an UPDATE or re-INVITE on an established media session
POP POP(varname[,delimiter]) Removes and returns the last item off of a variable containing delimited text
PUSH PUSH(varname[,delimiter]) Appends one or more values to the end of a variable containing delimited text
QUEUE_EXISTS QUEUE_EXISTS([queuename]) Check if a named queue exists on this server
QUEUE_GET_CHANNEL QUEUE_GET_CHANNEL(queuename[,positi Return caller at the specified position in a queue.
QUEUE_MEMBER QUEUE_MEMBER([queuename],option[,in Provides a count of queue members based on the provided criteria, or updates a queue member's settings.
QUEUE_MEMBER_COUNT QUEUE_MEMBER_COUNT(queuename) Count number of members answering a queue.
QUEUE_MEMBER_LIST QUEUE_MEMBER_LIST(queuename) Returns a list of interfaces on a queue.
QUEUE_MEMBER_PENALTY QUEUE_MEMBER_PENALTY(queuename,inte Gets or sets queue members penalty.
QUEUE_VARIABLES QUEUE_VARIABLES(queuename) Return Queue information in variables.
QUEUE_WAITING_COUNT QUEUE_WAITING_COUNT([queuename]) Count number of calls currently waiting in a queue.
QUOTE QUOTE(string) Quotes a given string, escaping embedded quotes as necessary
REDIRECTING REDIRECTING(datatype[,i]) Gets or sets Redirecting data on the channel.
REGEX REGEX("regular expression" string) Check string against a regular expression.
REPLACE REPLACE(varname,find-chars[,replace Replace a set of characters in a given string with another character.
RTRIM RTRIM(string) Trim trailing whitespace in a string
SHIFT SHIFT(varname[,delimiter]) Removes and returns the first item off of a variable containing delimited text
STACK_PEEK STACK_PEEK(n,which[,suppress]) View info about the location which called Gosub
STRBETWEEN STRBETWEEN(varname,insert-string) Inserts a substring between each character in a string.
STRFTIME STRFTIME([epoch][,timezone[,format] Returns the current date/time in the specified format.
STRPTIME STRPTIME(datetime,timezone,format) Returns the epoch of the arbitrary date/time string structured as described by the format.
STRREPLACE STRREPLACE(varname,find-string[,rep Replace instances of a substring within a string with another string.
TESTTIME TESTTIME(date,time[,zone]) Sets a time to be used with the channel to test logical conditions.
TOLOWER TOLOWER(string) Convert string to all lowercase letters.
TOUPPER TOUPPER(string) Convert string to all uppercase letters.
TRIM TRIM(string) Trim leading and trailing whitespace in a string
UNSHIFT UNSHIFT(varname[,delimiter]) Inserts one or more values to the beginning of a variable containing delimited text
VM_INFO VM_INFO(mailbox[@context],attribute Returns the selected attribute from a mailbox.
70 custom functions installed.
Conclusion
We have reached the end of this article. In this guide, we have walked you through the steps required to use Asterisk Dialplan Functions on Oracle Linux 9.3. Your feedback is much welcome.
Comments ( 0 )
No comments available