Test Driving FreeSWITCH example configuration - Omid-Mohajerani/freeswitch GitHub Wiki
After a default installation, out of the box, you'll find that FreeSWITCH is already able to do a lot of things. Example demo configuration is not intended at all to be used in a production system but it gives us a way to test and learn FreeSWITCH. In today's tutorial we will learn:
- how to use FreeSWITCH Command-Line Interface(fs_cli)
- Configuring a phone to work with FreeSWITCH
- Calling various extensions in the system
The fs_cli program is a Command-Line Interface that allows a user to connect to a running FreeSWITCH™ instance. The fs_cli program can connect to the FreeSWITCH™ process on the local machine or on a remote system. (Network connectivity to the remote system is, of course, required.)
In order to run the fs_cli if you have already created bash_profile as I described here you just need to run fs_cli command. If you have installed freeSWITCH from source fs_cli program is located in /usr/local/freeswitch/bin folder.
Here are some useful commands in FreeSWITCH Command-Line Interface:
Command | Meaning. |
---|---|
... (three consecutive points) | exit fs_cli. |
ctrl-d or /exit | exit fs_cli. |
shutdown | shutdown FreeSWITCH |
hupall | hangup all calls |
fsctl loglevel [0-7] or /log | change which log messages are visualized |
/nolog | Disable logging. |
status | tells some basic statistics |
version | which code base |
show channels | visualize all call legs grouped by complete bridged calls (A+B) |
help | List available fs_cli commands. |
You will normally use a loglevel of 3: all messages categorized as "ERROR" or even more important (eg, level 2, "CRITICAL") are visualized. Many admins like to run their FreeSWITCHes at log level 4, visualizing messages starting at level "WARNING". But when you want to understand the cause of a problem or report a bug, you pump up the log level to 7, "DEBUG" and then copy and paste all that will scroll by in your terminal (or that gets written in logfile).
The first thing to do with a new installation is to change the default password for the demo users. The default password is 1234 and it is saved in /usr/local/freeswitch/vars.xml. Change to a complex password and restart FreeSWITCH using "systemctl restart freeswitch" command.
In order to generate a complex password, you can use. uuid-runtime program.
apt-get install uuid-runtime
Example demo users are named by the 20 consecutive numbers 1000-1019. That is 1001, 1002...1019. Their collective password is the one we just edited in vars.xml
TO Be updated
<extension name="laugh break">
<condition field="destination_number" expression="^9386$">
<action application="answer"/>
<action application="sleep" data="1500"/>
<action application="playback" data="phrase:funny_prompts"/>
<action application="hangup"/>
</condition>
</extension>
<!--
dial the extension (1000-1019) for 30 seconds and go to voicemail if the
call fails (continue_on_fail=true), otherwise hang up after a successful
bridge (hangup_after_bridge=true)
-->
<extension name="Local_Extension">
<condition field="destination_number" expression="^(10[01][0-9])$">
<action application="export" data="dialed_extension=$1"/>
<!-- bind_meta_app can have these args <key> [a|b|ab] [a|b|o|s] <app> -->
<action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
<action application="bind_meta_app" data="2 b s record_session::$${recordings_dir}/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
<action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
<action application="bind_meta_app" data="4 b s execute_extension::att_xfer XML features"/>
<action application="set" data="ringback=${us-ring}"/>
<action application="set" data="transfer_ringback=$${hold_music}"/>
<action application="set" data="call_timeout=30"/>
<!-- <action application="set" data="sip_exclude_contact=${network_addr}"/> -->
<action application="set" data="hangup_after_bridge=true"/>
<!--<action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION"/> -->
<action application="set" data="continue_on_fail=true"/>
<action application="hash" data="insert/${domain_name}-call_return/${dialed_extension}/${caller_id_number}"/>
<action application="hash" data="insert/${domain_name}-last_dial_ext/${dialed_extension}/${uuid}"/>
<action application="set" data="called_party_callgroup=${user_data(${dialed_extension}@${domain_name} var callgroup)}"/>
<action application="hash" data="insert/${domain_name}-last_dial_ext/${called_party_callgroup}/${uuid}"/>
<action application="hash" data="insert/${domain_name}-last_dial_ext/global/${uuid}"/>
<!--<action application="export" data="nolocal:rtp_secure_media=${user_data(${dialed_extension}@${domain_name} var rtp_secure_media)}"/>-->
<action application="hash" data="insert/${domain_name}-last_dial/${called_party_callgroup}/${uuid}"/>
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>
</condition>
</extension>
<!-- a sample IVR -->
<extension name="ivr_demo">
<condition field="destination_number" expression="^5000$">
<action application="answer"/>
<action application="sleep" data="2000"/>
<action application="ivr" data="demo_ivr"/>
</condition>
</extension>
https://freeswitch.org/confluence/pages/viewpage.action?pageId=1048948