How to Create a Voice Call Meeting Reminder App with CakePHP and Twilio

September 17, 2024
Written by
Oluseye Jeremiah
Contributor
Opinions expressed by Twilio contributors are their own
Reviewed by

How to Create a Voice Call Meeting Reminder App with cakePHP and Twilio

Effective communication is vital for any team's success. In today's fast-paced environment, staying on top of schedules and deadlines can be challenging. Missed meetings can disrupt workflows and hinder progress. This is where integrating Twilio Programmable Voice with your CakePHP application can be a game-changer.

By leveraging this powerful combination, you can automate team meeting call reminders, ensuring everyone is informed and prepared beforehand. This not only improves punctuality and participation but also fosters a culture of accountability and organization within your team. In this tutorial, you will learn how to integrate Twilio Programmable Voice with a CakePHP application to create an automated meeting reminder system for your team.

Benefits of the app

An automated meeting reminders app offers numerous benefits for both team leads and members, including the following:

  • Improved Attendance: By sending automated voice call meeting reminders, team members receive a reminder call. This ensures they are notified even if their phone is not connected to a network.
  • Reduced Missed Meetings: Automated voice call reminders minimize the chances of team members missing out meetings, leading to better attendance and participation.
  • Streamlined Communication: This allows the team lead to convey important messages to team members before the meeting starts.
  • Increased Productivity: By reducing scheduling conflicts and ensuring everyone is on the same page, team productivity can be significantly boosted.

Prerequisites

Create a CakePHP project

To begin, let’s create a new CakePHP project using Composer by running the command below:

composer create-project --prefer-dist cakephp/app:~5.0 team_meeting_call_reminder_app

After the installation is successful, you will be asked to "Set Folder Permissions ? (Default to Y) [Y,n]?", answer with Y. then run the command below to navigate to the project's working directory.

cd team_meeting_call_reminder_app

Connect to the database

To set up the application database, open the project in your code editor and navigate to the config folder. Inside the folder, open the app_local.php file, and in the Datasources > default section, update the database options with the following:

An example of configuring data sources in CakePHP

Create the database

To start, we need to create a database that will store the team member's information. To do this, in your database server, create a database named my_app.

After creating the database, run the CakePHP migration command in your terminal to generate the migration file for the database.

bin/cake bake migration members

Then, in the config/Migrations/ folder open the migration file ending with _Members.php, and update the change() function to match the following code:

public function change(): void
{
    $table = $this->table('members');
    $table->addColumn('email', 'string', [
        'default' => null,
        'limit' => 255,
        'null' => false,
    ]);
    $table->addColumn('username', 'string', [
        'default' => null,
        'limit' => 255,
        'null' => false,
    ]);
    $table->addColumn('phone', 'string', [
        'default' => null,
        'limit' => 255,
        'null' => false,
    ]);
    $table->create();
}

Then, run the database migration by running the command below:

bin/cake migrations migrate

Now, check the MySQL server. You should have a members table with the id, email, username and phone fields, as shown in the screenshot below with phpMyAdmin:

Next, start the application by running the command below:

bin/cake server

After starting the application, open http://localhost:8765 in your browser. It should look similar to the screenshot below.

Create the application model and entity

To create a model and entity, open up a new terminal window or tab and run the command below:

bin/cake bake model members --no-validation --no-rules

The entity file Member.php and the model file MembersTable.php will be available inside the /src/Model/Table and /src/Model/Entity folders, respectively.

Retrieve your Twilio credentials

To retrieve them, open the Twilio Console dashboard. There, in the Account Info section, you will see your Account SID and Auth Token, as shown in the image below.

Store the access token in .env file

To use environment variables in CakePHP applications, you need to create a .env file from .env.example. This can be done by running the command below.

cp config/.env.example config/.env

Now, navigate to the config folder and open .env. Then add the following Twilio variables to the end of it.

TWILIO_ACCOUNT_SID=<your_account_sid>
TWILIO_AUTH_TOKEN=<your_auth_token>
TWILIO_PHONE_NUMBER=<your_twilio_phone_number>

From the code above, replace <your_account_sid>, <your_auth_token> and <your_twilio_phone_number>, respectively, with your corresponding Twilio values.

To finish the environment variable configuration, next, navigate to config/bootstrap.php and uncomment the following section.

if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
     $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
     $dotenv->parse()
         ->putenv()
         ->toEnv()
         ->toServer();
 }

Install Twilio's PHP Helper Library

After retrieving your Twilio credentials, you need to install Twilio's PHP Helper Library, by running the command below:

composer require twilio/sdk

Create the core controller

Next up, the CakePHP bake console can be used to generate the application controller, by running the command below:

bin/cake bake controller Meeting

Next, navigate to the src/Controller folder, open the new MeetingController.php file, and add the following code to it:

<?php
declare(strict_types=1);

namespace App\Controller;

use Twilio\Rest\Client;

class MeetingController extends AppController
{
    public function register()
    {
        if ($this->request->is('post')) {
            $data = $this->request->getData();
            $email = $data['email'];
            $username = $data['username'];
            $phone = $data['phone'];
            $membersTable = $this->getTableLocator()->get('Members');
            $member = $membersTable->newEntity([
                'email' => $email,
                'username' => $username,
                'phone' => $phone,
            ]);
            if ($membersTable->save($member)) {
                $this->Flash->success('Team member added successfully');
            } else {
                $this->Flash->error('Unable to register the member.');
            }
        }
    }
    public function sendReminder()
    {
        if ($this->request->is('post')) {
            $message = $this->request->getData('message');
            $membersTable = $this->getTableLocator()->get('Members');
            $teamMembers = $membersTable->find()->select(['phone'])->toArray();
            $accountSid = getenv('TWILIO_ACCOUNT_SID');
            $authToken = getenv('TWILIO_AUTH_TOKEN');
            $twilioNumber = getenv('TWILIO_PHONE_NUMBER');
            $twilioClient = new Client($accountSid, $authToken);
            foreach ($teamMembers as $teamMember) {
                $call = $twilioClient->calls->create(
                    $teamMember->phone,
                    $twilioNumber,
                    [
                        'twiml' => '<Response><Say>' . htmlspecialchars( $message, ENT_QUOTES, 'UTF-8') . '</Say></Response>'
                    ]
                );
            }
            $this->Flash->success('Meeting call reminders sent successfully');
        }
    }
}

From the code above:

  • The register() method is used to handle the team member registration page.
  • The sendReminder() method is used to send the reminder message. Inside this function, we retrieve our Twilio access token from the .env file and send the voice call message using the $twilioClient->calls->create() method.

Create the application templates

Next, navigate to the templates directoryandcreatea Meeting folder inside it. Then, create a file named register.php in that directory and add the following registration form template code to it.

<h2>Add new team member</h2>
<?= $this->Form->create() ?>
<?= $this->Form->control('username') ?>
<?= $this->Form->control('phone') ?>
<?= $this->Form->control('email') ?>
<?= $this->Form->submit('Add member') ?>
<?= $this->Form->end() ?>

After that, to create the verification page template, inside the Meeting folder, create a file named send_reminder.php and add the following code to it.

<h2>Send reminder voice call to team members</h2>
<?= $this->Form->create() ?>
<?= $this->Form->control('message', ['type' => 'textarea']) ?>
<?= $this->Form->submit('Send') ?>
<?= $this->Form->end() ?>
<?= $this->Html->link('add new member', ['controller' => 'Meeting', 'action' => 'register'], ['class' => 'btn btn-primary']) ?>

The final step is to add the register and verify routes to the application configuration. To do that, navigate to the config directory and open routes.php. Inside it, add the following routes just before $builder->fallbacks();:

$builder->connect('/register', ['controller' => 'Meeting', 'action' => 'register', '   register Page']);
$builder->connect('/sendreminder', ['controller' => 'Meeting', 'action' => 'sendReminder', '   send Reminder Page']);

Test the application

To test the application, you need to register your team members' details. To do that, open http://localhost:8765/register in your browser and enter enter member details as shown in the screenshot below:

After entering the member's username, phone number, and email address, click on the ADD MEMBER button to register the team member in the database. You can register as many team members as you have.

To send the meeting voice call reminder to registered team members, open http://localhost:8765/sendreminder in your browser and enter the reminder message as shown in the screenshot below:

After filling out the meeting message, click on the SEND button. This will place a voice call to all registered team members, providing them with details about the meeting.

That's how to create a voice call meeting reminder app with CakePHP and Twilio

In this article, we discuss how to integrate Twilio Programmable Voice with CakePHP application to build efficient automated team meeting call reminders. This integration streamlines communication and fosters a culture of punctuality, accountability, and improved overall team productivity.

Key takeaways:

  • Improved Attendance: By sending automated voice call meeting reminders, team members receive a reminder call. This ensures they are notified even if their phone is not connected to a network.
  • Reduced Missed Meetings: Automated voice call reminders minimize the chances of team members missing out on meetings, leading to better attendance and participation.
  • Streamlined Communication: This allows the team lead to convey important messages to team members before the meeting starts.
  • Increased Productivity: By reducing scheduling conflicts and ensuring everyone is on the same page, team productivity can be significantly boosted.

Remember to customize the reminders to suit your specific needs and consider incorporating additional features like calendar integration or escalation options for missed calls.

I'm Oluseye Jeremiah, a dedicated technical writer with a proven track record in creating engaging and educational content.