Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

TwilioDevEd/block-spam-calls-ruby

Repository files navigation

Twilio

Block Spam Calls. Powered by Twilio - Ruby/Sinatra

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.

About

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

Set up

Requirements

  • Ruby 2.6.x version.

Create a TwiML App

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.

Install Add-ons

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

Local development

  1. First clone this repository and cd into it.

    git clone https://github.com/TwilioDevEd/block-spam-calls-ruby.git
    cd block-spam-calls-ruby
  2. Install dependencies:

    make install
  3. Run the application (will run on port 9292).

    make serve
  4. 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
  5. 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!

Docker

If you have Docker already installed on your machine, you can use our docker-compose.yml to setup your project.

  1. Make sure you have the project cloned.
  2. Run docker-compose up.
  3. 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.

Tests

You can run the tests locally by typing

bundle exec rspec

Cloud deployment

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 Deploy

Resources

  • The CodeExchange repository can be found here.

Contributing

This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.