Skip to content

joshuafleck/talkbox

Repository files navigation

Talkbox

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.

Why?

  • 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.

What does it do?

  • Make a call from the browser
  • Receive a call from another browser
  • Make a conference call
  • Receive a call from a telephone

Design

This project serves as an umbrella enclosing some smaller applications.

Goals

  • Small, loosely coupled components, each with a narrow set of responsibilities
  • Components that can be tested in isolation

Components

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.

Architecture

  • 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

Set up

  1. Install dependencies

    brew bundle
    mix deps.get
    
  2. Install Node packages

    # within the `apps/contact_centre/assets` directory:
    npm install
    
  3. Set environment variables

    export TWILIO_ACCOUNT_SID=<account sid>
    export TWILIO_AUTH_TOKEN=<auth token>
    
  4. Run the tests

    mix test
    
  5. Start the applications

    iex -S mix phx.server
    
  6. Open the application

    open http://localhost:5000/?client_name=yourname
    

Docker

To run Talkbox in a container:

  1. Ensure Docker is installed and running

  2. Compile Elm files

    MIX_ENV=prod mix package_ui
    
  3. Build the image

    docker build -t talkbox .
    
  4. Ensure the following environment variables are set

    • TWILIO_AUTH_TOKEN
    • TWILIO_ACCOUNT_SID
    • SECRET_KEY_BASE Secret key base for Phoenix
    • COOKIE Erlang cookie
    • TELEPHONY_CLI Must be a verified phone number in Twilio
    • TELEPHONY_WEBHOOK_URL A public url that points to port 4000 on the docker container
  5. 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
    
  6. Open the application

    open http://localhost:5000/?client_name=yourname
    

Proposed enhancements

  • 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)

About

A proof of concept in building browser-based telephony applications using functional programming languages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published