A proof of concept in building browser-based telephony applications using functional programming languages. The back-end is implemented with Elixir, the front-end implemented with Elm.
- To improve my knowledge of functional programming.
- To learn what types of problems are more/less difficult to solve in the telephony domain using functional languages vs. object oriented languages.
- To gain more experience with event-driven architectures.
- Make a call from the browser
- Receive a call from another browser
- Make a conference call
- Receive a call from a telephone
This project serves as an umbrella enclosing some smaller applications.
- Small, loosely coupled components, each with a narrow set of responsibilities
- Components that can be tested in isolation
Each of these components is implemented as a child-project under the /apps
directory. This was done to promote the abovementioned design goals. Communication between components is achieved by publishing and subscribing to events.
- ContactCentre A Phoenix application that serves the interface allowing the user to make and receive calls. Contains the core business logic for managing calls and conferences.
- Telephony Encapsulates the logic for communicating with the telephony provider. Makes API calls and accepts webhook requests from the telephony provider (also uses Phoenix).
- Events Contains event definitions used to communicate between applications and facilitates publishing of events
-
Install dependencies
brew bundle mix deps.get
-
Install Node packages
# within the `apps/contact_centre/assets` directory: npm install
-
Set environment variables
export TWILIO_ACCOUNT_SID=<account sid> export TWILIO_AUTH_TOKEN=<auth token>
-
Run the tests
mix test
-
Start the applications
iex -S mix phx.server
-
Open the application
open http://localhost:5000/?client_name=yourname
To run Talkbox in a container:
-
Ensure Docker is installed and running
-
Compile Elm files
MIX_ENV=prod mix package_ui
-
Build the image
docker build -t talkbox .
-
Ensure the following environment variables are set
TWILIO_AUTH_TOKEN
TWILIO_ACCOUNT_SID
SECRET_KEY_BASE
Secret key base for PhoenixCOOKIE
Erlang cookieTELEPHONY_CLI
Must be a verified phone number in TwilioTELEPHONY_WEBHOOK_URL
A public url that points to port 4000 on the docker container
-
Run the container
docker run -p 4000:4000 -p 5000:5000 --env TWILIO_ACCOUNT_SID --env TWILIO_AUTH_TOKEN --env SECRET_KEY_BASE --env TELEPHONY_CLI --env TELEPHONY_WEBHOOK_URL --env COOKIE -it talkbox
-
Open the application
open http://localhost:5000/?client_name=yourname
- Resilience to client crash (fetch state from server at load)
- Resilience to server crash (fetch call state from Twilio at boot)
- Rolling deploys (proposing Docker with Consul)