Application built with Laravel 10. It includes a call management system that processes incoming calls.
- PHP >= 8.2.0
- Composer >= 2.7.1
- Docker Desktop >= 4.27.2 (Docker version 25.0.3 && Docker Compose version v2.24.5-desktop.1)
- Create a Ngrok account https://ngrok.com and get a new Static Domain
- Run in terminal
ngrok http --domain=<static domain from ngrok> 80
- Create a Twilio account https://www.twilio.com and rent a new phone number.
- Go to PhoneNumbers->Manager->ActiveNumbers and configure the phone numnber.
- Under Voice Configuration:
- A comes in:
<webhook url>
HTTP POST
- Call status changes:
<webhook url>
HTTP POST
- A comes in:
- Clone the repository:
git clone https://github.com/keynertyc/voip-test-app.git
- Navigate to the project directory:
cd voip-test-app
- Install dependencies:
composer install
- Copy the
.env.example
file to create your own.env
file:cp .env.example .env
- Set up your Twilio credentials in the
.env
file
CPAAS_PROVIDER=twilio
TWILIO_SID=<from twilio>
TWILIO_TOKEN=<from twilio>
TWILIO_NUMBER=<from twilio>
TWILIO_AGENT_NUMBER=+51941884743
- Start Application with Sail:
./vendor/bin/sail up
Using Docker, it will install Mysql, Laravel Application
- Generate an application key:
./vendor/bin/sail artisan key:generate
- Run the migrations:
./vendor/bin/sail artisan migrate
Call from a Verified Number in Twilio to the Rented Number TWILIO_NUMBER
and listen the instructions given by the call.
Run tests: ./vendor/bin/sail pest
This application was developed using the Facade and Strategy Design Patterns
.
This allows me to create a class CallManager.php
, as a facade and create a service TwilioProvider.php
, that implements the CallProviderInterface.php
contract.
This enables us, in the future, to change or implement another CPASS Provider such as VONAGE or any other. Following the Strategy Design Pattern, we would create a VonageProvider.php
class that implements the methods of the CallProviderInterface.php
contract. Simply changing it in the configuration file would make everything transparent since CallManager.php
is the class that manages the functionality under Dependency Injection of the CallProviderInterface within the constructor.
Additionally, it is registered within the Service Container/Provider: AppServiceProvider and CallServiceProvider
- A call is made from a number to the rented Twilio number.
- Twilio launches it to the configured webhook (which is our application).
- We receive the information and generate the voice response (from the code) with the two options (forward call or leave a voicemail).
- If option 1 (forward call) is selected, we forward it to the defined agent's number.
- If option 2 (leave a voicemail) is selected, a beep will be heard, and the person will speak, recording the message. Finally, we send "Thank you, goodbye," and close the call.
- As we also have the CallStatus webhook configured, when the call ends, it launches to the webhook (another endpoint) where we receive all the final status of the call and record it in the database.