DEV Community

loading...
Cover image for How we created an open-source alternative to Twilio and why it matters

How we created an open-source alternative to Twilio and why it matters

Pedro Sanders
Enthusiast Telematics Engineer. Building the next generation of communication software. Co-founder at @fonoster.
Updated on ・4 min read

Last year, around the time I started assembling Team Fonos, I published a post on Reddit that sparked a great conversation and placed Project Fonos on Github’s trending list even though we didn’t have much to show.

GitHub logo fonoster / fonos

🚀 An open-source alternative to Twilio.

As a result, I had the opportunity to interview dozens of CTOs from companies worldwide and speak with several VCs who were interested in the idea of an open-source stack for Programmable Telecommunications.

In the interviews, I found we need an innovative approach to a cloud-based stack for Programmable Telecommunications.

Why we needed CPaaS in the first place?

Building an application that takes advantage of the existing Telecom network has always been a difficult task compared with, for example, building a web-based application.

This is difficult because it involves a particular set of skills that is challenging to find and can get really costly.

Let’s face it, no one wants to read through dozens of RFCs to program a phone call.

So, when the API era arrived along with UCaaS and CPaaS providers, it was a no-brainer to use one of those providers to deploy a solution within weeks instead of spending months only to get a simple use-case.

So what's wrong with traditional CPaaS?

There is nothing wrong with traditional CPaaS. In fact, in most cases, using a CPaaS is a great option to deploy a Telecommunications solution.

However, even though the concept of using a CPaaS to go to market quickly is fantastic, it comes at a high price for some use-cases. After all, if something goes wrong, you will have no other option but to migrate to another CPaaS or build your own solution and start again on square zero.

Some companies complain about the high prices for using a CPaaS. A startup CTO once told me, “It almost feels that we are paying for a lot of features we don’t need.” This is because, with a traditional CPaaS, you start on a pay-as-you-go model, but costs can quickly get out of control.

Other companies find themselves limited by their providers’ features because with traditional CPaaS you have no option but to use what they have available. There is no chance for customization. And even though that’s not a problem for most companies, it is a deal-breaker for technology companies.

Then you have use-cases, especially in the healthcare industry, that can’t benefit from using a traditional CPaaS due to privacy concerns and local regulations.

In which of those categories does your company fall?

How can we make this better?

The primary innovation of Project Fonos lies in researching and developing the means for creating a highly portable, cloud-based Programmable Telecommunications stack.

This Programmable Telecommunications stack will allow businesses to call an API to dial, answer a call, establish a video session, send SMS, etc. There won’t be any concern about what servers and networks are doing with that information in the background.

Our overall approach to building Project Fonos is to use existing open-source solutions that are best in their class when possible and make our own when necessary. We then integrate this individual open-source software into a cohesive set of APIs that resembles a traditional CPaaS.

For example, to start a simple Voice Application one could write a Javascript code like the one below:

const { VoiceServer } = require("@fonos/voice");
const voiceServer = new VoiceServer();

voiceServer.listen((req, res) => {
  console.log(req);
  res.play("sound:hello-world");
});
Enter fullscreen mode Exit fullscreen mode

Or to make a call to the telephone network, you could use the SDK and write a simple script like this:

const Fonos = require("@fonos/sdk");
const callManager = new Fonos.CallManager();

callManager.call({
 from: "9842753574",
 to: "17853178070",
 webhook: "https://5a2d2ea5d84d.ngrok.io"
})
.then(console.log)
.catch(console.error);
Enter fullscreen mode Exit fullscreen mode

Want to create a reminders application? No problem, in few easy steps, you can create and deploy a Cloud Function that will run based on a given Cron schedule.

First, initialize your Cloud Function with:

fonos funcs:init
Enter fullscreen mode Exit fullscreen mode

Then, edit the handler with the following code:

const Fonos = require("@fonos/sdk");
const callManager = new Fonos.CallManager();

// 🚀 Let's get started
// Use fonos funcs:deploy to send to the cloud functions
module.exports = async(request, response) => {
  await callManager.call({
    from: "9842753589",
    to: "17853178070",
    webhook: "https://5a2d2ea5d84d.ngrok.io"
  })
  return response.succeed("OK");
};
Enter fullscreen mode Exit fullscreen mode

Finally, deploy to the Cloud Functions subsystem with a Cron string.

fonos funcs:deploy --schedule "*/5 * * * *"
Enter fullscreen mode Exit fullscreen mode

You get the idea.

The Cloud Functions capability if offered by the integration with OpenFaaS (by Alex Ellis)

What's is next?

Be sure to check The essentials of building Voice Applications with Project Fonos to overview the Programmable Voice features available on Project Fonos. Star the project on Github and contact us via:

GitHub logo fonoster / fonos

🚀 An open-source alternative to Twilio.

Discussion (0)