You are previewing FreeSWITCH 1.0.6.
O'Reilly logo
FreeSWITCH 1.0.6

Book Description

Build robust high-performance telephony systems using FreeSWITCH

  • Install and configure a complete telephony system of your own even if you are using FreeSWITCH for the first time

  • In-depth discussions of important concepts like the dialplan, user directory, and the powerful FreeSWITCH Event Socket

  • The first ever book on FreeSWITCH, packed with real-world examples for Linux/Unix systems, Mac OSX, and Windows, along with useful screenshots and diagrams

  • Best practices and expert tips from the FreeSWITCH experts, including the creator of FreeSWITCH, Anthony Minessale

  • In Detail

    FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat-driven products scaling from a soft-phone to a PBX and even up to an enterprise-class soft-switch. It is always exciting to design and build your own telephony system to suit your needs, but the task is time consuming and involves a lot of technical skills.This book comes to your rescue, helping you to set up a telephony system fast and easily using FreeSWITCH. It will take you from being a novice to creating a fully-functional telephony system of your own. It is rich with practical examples and will give you all of the information and skills needed to implement your own PBX system.The book begins by introducing the architecture and working of FreeSWITCH before detailing how to plan a telephone system and moving on to the installation, configuration, and management of a feature-packed PBX. You will learn about maintaining a user directory, XML dial plan and advanced dial plan concepts, call routing, and the extremely powerful Event Socket. You will finally learn about the online community and history of FreeSWITCH.

    A step-by-step guide to building, managing, and maintaining an efficient FreeSWITCH telephony system

    Table of Contents

    1. FreeSWITCH 1.0.6
      1. FreeSWITCH 1.0.6
      2. Credits
      3. About the Authors
      4. About the Reviewer
      5. Preface
        1. What this book covers
        2. Who this book is for
        3. Conventions
        4. Reader feedback
        5. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. Architecture of FreeSWITCH
        1. A revolution has begun and secrets have been revealed
        2. The FreeSWITCH design: modular, scalable, and stable
        3. Important modules: Endpoint and Dialplan
        4. Complex applications made simple
          1. Voicemail
          2. Multi-party conferencing
          3. The FreeSWITCH API (FSAPI)
          4. The XML registry
          5. Language modules
          6. The default configuration
        5. Summary
      7. 2. Building and Installation
        1. Setting up the FreeSWITCH environment
          1. Operating system
          2. Operating system prerequisites
            1. Linux/Unix
          3. Mac OS X
            1. Windows
            2. Text editors and XML
        2. Downloading the source
          1. Building from the latest code
        3. Compiling FreeSWITCH for Linux/Unix/Mac OS X
          1. Compiling FreeSWITCH
            1. Step 1: Edit modules.conf
            2. Step 2: Run configure script
            3. Step 3: Run make and make install
            4. Step 4: Edit modules.conf.xml
            5. Step 5: Install sound and music files
        4. Compiling FreeSWITCH for Windows
          1. Building the solution with MSVC/MSVCEE
        5. Starting FreeSWITCH
          1. Running FreeSWITCH in the background
        6. Summary
      8. 3. Test Driving the Default Configuration
        1. Important concepts to understand
        2. Putting FreeSWITCH to work
          1. Controlling FreeSWITCH with the CLI
          2. Configuring a SIP phone to work with FreeSWITCH
            1. SIP settings
              1. X-Lite softphone
              2. Hard phones
                1. Aastra phones
                2. Polycom phones
                3. Snom phones
          3. Testing the default Dialplan
            1. Test calls for a single phone
              1. The "Tetris" extension
              2. Echo test
              3. Music on hold
              4. Demonstration IVR
              5. The "Information" application
            2. Test calls for two or more phones
              1. Calling another telephone
              2. Parking a call
              3. Calling a conference
        3. Summary
      9. 4. SIP and the User Directory
        1. Understanding the FreeSWITCH user directory
        2. Working with the FreeSWITCH user directory
          1. User features
          2. Adding a user
          3. Testing voicemail
          4. Groups of users
        3. Connecting to the world with gateways
          1. Setting up a new gateway
            1. Making calls
            2. Receiving calls
          2. Making calls without a gateway
        4. SIP profiles and user agents
        5. Summary
      10. 5. Understanding the XML Dialplan
        1. FreeSWITCH XML Dialplan elements
          1. Call legs and channel variables
            1. Accessing channel variables
          2. Regular expressions
          3. Contexts
            1. Default
            2. Public
            3. Features
          4. Extensions
          5. Conditions
          6. Actions and anti-actions
        2. How Dialplan processing works
        3. Creating a new extension
        4. Important Dialplan applications
          1. bridge
          2. playback
          3. say
          4. play_and_get_digits
          5. ivr
          6. sleep
          7. answer
          8. hangup
          9. set
        5. Dialstring formats
        6. Summary
      11. 6. Using the Built-in XML IVR Engine
        1. IVR engine overview
        2. IVR XML configuration file
        3. IVR menu definitions
          1. greet-long
          2. greet-short
          3. invalid-sound
          4. exit-sound
          5. timeout
          6. inter-digit-timeout
          7. max-failures
          8. max-timeouts
          9. digit-len
          10. tts-voice
          11. tts-engine
          12. confirm-key
        4. IVR menu destinations
          1. menu-exec-app
          2. menu-exec-api
          3. menu-play-sound
          4. menu-back
          5. menu-top
        5. Routing calls to your IVR
        6. Nesting IVRs
        7. Using phrases with IVRs
          1. Calling Phrase Macros
          2. Phrase Macro examples: voicemail
        8. Advanced routing
        9. Summary
      12. 7. Building IVR Applications with Lua
        1. Getting started with Lua
          1. Running Lua scripts from the Dialplan
          2. Basic Lua syntax
        2. Building voice applications
          1. Simple IVR—interacting with the caller
          2. Conditions and looping
          3. Advanced IVR concepts
            1. Connecting to a database with LuaSQL
            2. Making a web call with curl
            3. Lua patterns versus regular expressions
          4. Scripting tips
        3. Summary
      13. 8. Advanced Dialplan Concepts
        1. Dialplan overview
        2. General Dialplan concepts
          1. Contexts
          2. Conditions
          3. Actions
          4. Putting it all together
        3. XML Dialplan module review
          1. Extensions
          2. Conditions
          3. Special condition variables
          4. Inline execution
          5. Actions and anti-actions
          6. Pitfalls to avoid
        4. XML Dialplan commands
        5. Hunting versus executing
        6. Utilizing variables
          1. Testing variables with regular expressions
          2. Caller profile fields
          3. Channel variables
            1. Channel variables and call setup
          4. Global variables
        7. Dialplan functions
          1. Real-time condition evaluation
          2. String conditioning
          3. Database queries
          4. SIP contact parameters
        8. Set, export, and legs
          1. Set versus export
          2. Passing variables via call headers
        9. XML Dialplan cookbook
          1. Match by IP address and call a number
          2. Match IP address and Caller ID
          3. Match number and strip digits
          4. Match number, strip digits, and add prefix
          5. Call registered device
          6. Try party A, then party B
          7. Check for authenticated user
          8. Route DIDs to extensions
          9. Try a local extension, failback to voicemail
          10. Alternate outbound gateways
        10. Alternatives to XML
          1. YAML
          2. Asterisk Dialplan
        11. Summary
      14. 9. Controlling FreeSWITCH Externally
        1. General overview
        2. Event system architecture
        3. Event-based modules
          1. mod_event_socket
            1. Configuring event socket settings
            2. Reading events
              1. Minimum event information
            3. Sending events
            4. Events from the Dialplan
          2. mod_event_multicast
            1. Port/address
            2. Bindings
            3. TTL
          3. mod_erlang_event
        4. FreeSWITCH event system commands
          1. auth <password>
          2. api
          3. bgapi
          4. event
          5. divert_events
          6. filter
          7. filter delete
          8. sendevent
          9. sendmsg <uuid>
            1. execute
            2. hangup
          10. nomedia
          11. log <level>
          12. nolog
          13. noevents
        5. Event-based applications
          1. FreeSWITCH Console application
          2. PHP Socket connections
          3. Perl Socket connections
        6. Event Socket Library
          1. Supported libraries
          2. ESLObject
            1. eslSetLogLevel($loglevel)
          3. ESLevent object
            1. serialize([$format])
            2. setPriority([$number])
            3. getHeader($header_name)
            4. getBody()
            5. getType()
            6. addBody($value)
            7. addHeader($header_name, $value)
            8. delHeader($header_name)
            9. firstHeader()
            10. nextHeader()
          4. ESLconnection object
            1. new($host, $port, $password)
            2. new($fd)
            3. socketDescriptor()
            4. connected()
            5. getInfo()
            6. send($command)
            7. sendRecv($command)
            8. api($command[, $arguments])
            9. bgapi($command[, $arguments])
            10. sendEvent($send_me)
            11. recvEvent()
            12. recvEventTimed($milliseconds)
            13. filter($header, $value)
            14. events($event_type,$value)
            15. execute($app[, $arg][, $uuid])
            16. executeAsync($app[, $arg][, $uuid])
            17. setAsyncExecute($value)
            18. setEventLock($value)
            19. disconnect()
        7. Events in practice
          1. Event Socket Library example: running a command
          2. Examples of sending events to FreeSWITCH
            1. Setting phone lights
              1. Turn lights on
              2. Turn lights off
            2. Rebooting a phone
            3. Requesting phone reconfiguration
            4. Custom notify messages
        8. Summary
      15. 10. Advanced Features and Further Reading
        1. Multi-user conferencing
          1. Configuration
            1. Conference profiles
            2. Caller controls
            3. Advertise
            4. Sending and receiving XMPP events
          2. Connecting callers to the conference
          3. Controlling active conferences
        2. Nibblebill
          1. Use cases
            1. Billing (pre-pay)
            2. Billing (post-pay)
            3. Pay-per-call service billing
            4. Maximum credit and/or fraud prevention
          2. Design goals
          3. Installation and configuration
            1. Database tables
          4. Creating the database table for PostgreSQL
          5. Creating the database table for MySQL
          6. Billing a call
            1. Nibble method (default)
            2. Alternative to nibble billings
          7. Examples
            1. Different rates per user
            2. Single rate for all users
            3. Different rates per area code
            4. Different rates per service delivery
            5. Hang up the call when the balance is depleted
          8. Application/CLI/API commands
            1. Check
            2. Flush
            3. Pause
            4. Resume
            5. Reset
            6. Adding and deducting funds
            7. Enabling session heartbeat
            8. Bill based on B leg only
        3. XML/Curl
          1. Installation
          2. Configuration
            1. Bindings
            2. HTTP requests
            3. HTTP response
            4. Optimization
            5. Order of requests
            6. Request/response examples
              1. mod_sofia
              2. ACL
              3. Authorization
              4. Voicemail request
          3. Dialplan bindings
            1. Request
            2. Reply
          4. Other bindings
          5. General "Not found" reply
          6. Debugging
          7. Failing back
        4. Alternative endpoints
          1. Skype and GSM endpoints
          2. Skype with mod_skypopen
          3. GSM with mod_gsmopen
          4. TDM with OpenZAP and FreeTDM
        5. Configuration tools and related projects
          1. Web GUIs
            1. WikiPBX
            2. FreePBX v3
            3. FusionPBX
            4. 2600hz
          2. Supporting libraries
            1. Liverpie (Ruby)
            2. FreeSWITCHeR (Ruby)
            3. Librevox (Ruby)
            4. EventSocket (Python/Twisted)
            5. FSSocket (Perl)
        6. Summary
      16. A. The FreeSWITCH Online Community
        1. The FreeSWITCH mailing lists
        2. Talking in real-time via IRC
        3. The FreeSWITCH main website and wiki
          1. The main FreeSWITCH page— www.freeswitch.org
          2. The FreeSWITCH Wiki page— wiki.freeswitch.org
        4. The annual ClueCon open source developer conference
      17. B. The History Of FreeSWITCH