Skip to Content
API v1IntegrationsTwilio Integration

Twilio Integration

Overview

Twilio is used for sending SMS messages — OTPs, viewing notifications, friend invitations, and agent alerts.

Configuration

Twilio credentials are hardcoded/stored as globals:

// Account SID $sid = "ACb82f79aecb94132848c1c7b40cfc3d36"; // Auth token (from configdb.php) $ttoken = "4ea7d07a2987e497774d559c1ba60432";

The auth token ($ttoken) is set in api/include/configdb.php and available globally.

Sending SMS

Via notificationUtils.php

function sendText(array $numbers, string $text) { $client = new Twilio\Rest\Client($sid, $ttoken); foreach ($numbers as $number) { $client->messages->create( normaliseNumber($number), [ 'from' => $USA ? '+14027611623' : 'Housr', 'body' => $text ] ); } }

Via sendSMS.php (standalone)

function sendSMS(array $numbers, string $text)

Identical logic to sendText(), implemented in a separate file for inclusion by endpoints that don’t use the notification utils.

Via otpUtils.php (OTP-specific)

function sendText($token, $phoneNumber, $otp)

Slightly different signature (single number, not array). Used specifically for OTP delivery.

Regional Differences

AspectUKUS
SenderHousr (alphanumeric sender ID)+14027611623 (phone number)
OTP messageOTP: 123456\n\nThanks,\n\nHousr TeamOTP: 123456\n\nThanks,\n\nmyhousr Team
Agent SMSLinks to housrportal.co.ukLinks to portal.myhousr.com

Phone Number Normalisation

File: api/utils/normaliseNumber.php

All phone numbers are normalised before sending via the normaliseNumber() function. This handles various input formats and converts them to E.164 format required by Twilio.

Usage Contexts

ContextTrigger
OTPsend_otp.php - Password reset/verification
Viewing RequestrequestViewing.php - SMS to agent (if opted in via landlord_preferences.contact_through_sms)
Friend InvitationsendInviteSMS.php - Invite someone to join Housr
Scheduled NotificationsaddScheduledViewingText.php - Pre/post viewing reminders

Dependencies

"twilio/sdk": "^7.0"
Last updated on