Awesome Open Source
Awesome Open Source


asyncio_ powered FreeSWITCH_ cluster control using pure Python_ 3.6+

|pypi| |github_actions| |versions| |license| |docs|

.. |versions| image:: :target: .. |pypi| image:: :target: .. |github_actions| image:: :target: .. |license| image:: :target: .. |docs| image:: :target:

switchio (pronounced Switch Ee OoH) is the next evolution of switchy_ (think Bulbasaur -> Ivysaur) which leverages modern Python's new native coroutine_ syntax and, for now, asyncio_.

API-wise the project intends to be the flask_ for VoIP but with a focus on performance and scalability more like sanic_.

.. _asyncio: .. _FreeSWITCH: .. _Python: .. _switchy: .. _coroutine: .. _flask: .. _sanic: .. _docs:

Use the power of async and await!

Build a routing system using Python's new coroutine_ syntax:

.. code:: python

from switchio.apps.routers import Router

router = Router(
        'Call-Direction': 'inbound',
        'variable_sofia_profile': 'external'},
    subscribe=('PLAYBACK_START', 'PLAYBACK_STOP'),

async def welcome(sess, match, router):
    """Say hello to inbound calls.
    await sess.answer()  # resumes once call has been fully answered"Answered call to {}".format(match.groups(0)))

    sess.playback(  # non-blocking
    await sess.recv("PLAYBACK_START")"Playing welcome message")

    await sess.recv("PLAYBACK_STOP")
    await sess.hangup()  # resumes once call has been fully hungup

Run this app (assuming it's in from the shell::

$ switchio serve fs-host1 fs-host2 fs-host3 --app ./

You can also run it from your own script:

.. code:: python

if __name__ == '__main__':
    from switchio import Service
    service = Service(['fs-host1', 'fs-host2', 'fs-host3'])
    service.apps.load_app(router, app_id='default')

Spin up an auto-dialer

Run thousands of call flows to stress test your service system using the built-in auto-dialer_::

$ switchio dial fs-tester1 fs-tester2 --profile external --proxy --rate 100 --limit 3000

.. _auto-dialer:



pip install switchio


Oh we've got them docs_!

How do I deploy my FreeSWITCH cluster?

  • Enable inbound ESL_ connections
  • Add a park-only_ dialplan (Hint: we include one here_)

See the docs_ for the deats!

.. _inbound ESL: .. _park-only: .. _here:

What's included?

  • A slew of built-in apps_
  • A full blown auto-dialer_ originally built for stress testing VoIP service systems
  • Super detailed ESL event logging

.. _built-in apps: .. _auto-dialer:

How can I contribute?

Have an idea for a general purpose switchio app or helper? Make a PR here on GitHub!

Also, if you like switchio let us know on Riot_!

.. _Riot:

Wait, how is switchio different from other ESL clients?

switchio differentiates itself by supporting FreeSWITCH process cluster control as well as focusing on leveraging the most modern Python language features. switchio takes pride in being a batteries included framework that tries to make all the tricky things about FreeSWITCH a cinch.

What if I'm stuck on Python 2?

Check out these other great projects:

  • greenswitch_
  • eventsocket_
  • pySWITCH_
  • python-ESL_

.. _greenswitch: .. _eventsocket: .. _pySWITCH: .. _python-ESL:

Performance monitoring

If you'd like to record performance measurements using the CDR_ app, some optional numerical packages can be used:

.. _CDR:

=============== ================ ================================ Feature Dependency Installation =============== ================ ================================ Metrics Capture pandas_ pip install switchio[metrics] Graphing matplotlib_ pip install switchio[graphing] HDF5 pytables_ [#]_ pip install switchio[hdf5] =============== ================ ================================

.. [#] pytables support is a bit shaky and not recommended unless you intend to locally process massive data sets worth of CDRs. The default CSV backend is usually sufficient on a modern file system.

.. _pandas: .. _matplotlib: .. _pytables:


All files that are part of this project are covered by the following license, except where explicitly noted.

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (53,634
asyncio (278
coroutines (183
voip (75
telephony (20
aio (19