This template is part of Twilio CodeExchange. If you encounter any issues with this code, please open an issue at github.com/twilio-labs/code-exchange/issues.
Learn how to use Twilio add-ons to block spam calls. This application was build with Sinatra. If you more information about how to use Twilio add-ons to block spam calls click here.
Implementations in other languages:
.NET | Java | Python | PHP | Node |
---|---|---|---|---|
Done | Done | Done | Done | Done |
- Ruby 2.6.x version.
This project is configured to use a TwiML App, which allows us to easily set the voice URLs for all Twilio phone numbers we purchase in this app.
To create a new TwiML app click here.
The following guide will help you to install Add-ons. You can access the Add-ons in the Twilio console here. The Spam Filtering Add-ons that are used on this application are:
Once you've selected the Add-on, just click on Install
button. Then, you will see a pop-up window where you should read and agree the terms, then, click the button Agree & Install
. For this application, you just need to handle the incoming voice calls, so make sure the Incoming Voice Call
box for Use In
is checked and click Save
-
First clone this repository and
cd
into it.git clone https://github.com/TwilioDevEd/block-spam-calls-ruby.git cd block-spam-calls-ruby
-
Install dependencies:
make install
-
Run the application (will run on port 9292).
make serve
-
To actually forward incoming calls, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.
ngrok http 9292
-
Once you have started ngrok, update your TwiML app's Voice URL setting to use your ngrok hostname, so it will look something like this:
http://88b37ada.ngrok.io/
Finally, click on
Call
to test your application. See Create a TwiML App to set the Voice URL.
That's it!
If you have Docker already installed on your machine, you can use our docker-compose.yml
to setup your project.
- Make sure you have the project cloned.
- Run
docker-compose up
. - Follow the steps in Local Development on how to expose your port to Twilio using a tool like ngrok and configure the remaining parts of your application.
You can run the tests locally by typing
bundle exec rspec
Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.
Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.
Service | |
---|---|
Heroku |
- The CodeExchange repository can be found here.
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
No warranty expressed or implied. Software is as is.