WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 13. WPResidence / WPEstate CRM / WPResidence CRM Twilio SMS — Developer Reference

WPResidence CRM Twilio SMS — Developer Reference

11 views 0

Developer documentation for the Twilio SMS integration in the WPResidence real estate CRM. Entry point is libs/twilio.php.

Send API

wpestate_crm_send_notification_sms( $event, $data )

Flow:

  1. Check global flag crm_twilio_enabled. Abort if falsy.
  2. Check per-event flag crm_notify_sms_{event}_enabled. Defaults to true unless explicitly ‘0’.
  3. Validate all three credentials present (crm_twilio_account_sid, crm_twilio_auth_token, crm_twilio_from_number).
  4. Determine recipient phone: $data[‘agent_phone’], or user meta crm_phone, or user meta billing_phone.
  5. Resolve placeholders in the body template via wpestate_crm_resolve_placeholders().
  6. POST to Twilio REST API.
  7. Record sms_sent activity on the contact on success.

Twilio REST Call

  • Endpoint: https://api.twilio.com/2010-04-01/Accounts/{account_sid}/Messages.json
  • Method: POST via wp_remote_post()
  • Auth: Basic Auth header, value base64_encode(“account_sid:auth_token”).
  • Body: form-encoded with From, To, Body.

Settings

Key Default
crm_twilio_enabled false
crm_twilio_account_sid empty
crm_twilio_auth_token empty
crm_twilio_from_number empty
crm_notify_sms_new_contact_enabled true
crm_notify_sms_new_contact_body see below

Default body template: New lead: {contact_name} ({contact_email}). {listing_title}. View: {crm_contact_url}

Event Integration

Currently called from wpestate_crm_on_new_contact_notification() (libs/notifications.php) after email sending if the function exists. The design anticipates future events (deal_won, task_overdue) – add them by calling wpestate_crm_send_notification_sms($new_event, $data) from the relevant hook.

Test SMS AJAX

Property Value
Action wpestate_crm_send_test_sms (no _nopriv – admin-only)
Nonce via wpestate_crm_verify_ajax_nonce(‘send_test_sms’)
Capability manage_options
POST param phone
Test message Test SMS from {site_name} CRM. If you received this, Twilio is configured correctly.

Returns JSON success/error with the Twilio response body or a descriptive error (missing credentials, invalid phone, HTTP error code from Twilio).

Placeholder Support

Uses the shared wpestate_crm_resolve_placeholders() function – same 20 placeholders as the email module. No SMS-specific placeholders.

Error Handling

  • wp_remote_post() errors: logged, function returns false, no activity record.
  • HTTP >= 400: logged with response body, no activity record.
  • Missing phone on recipient: silent skip (expected – not every agent has a phone on file).

Security

Credentials stored plain-text in the CRM settings array (standard WordPress pattern). For production deployments, consider storing the crm_twilio_auth_token in wp-config.php as a constant and reading it via a filter rather than exposing it in the admin UI.

Extending

  • Add a new SMS event by registering a new settings pair (crm_notify_sms_{event}_enabled and crm_notify_sms_{event}_body) and calling the send API from the relevant hook.
  • Replace Twilio with another provider by forking libs/twilio.php into a child plugin and overriding wpestate_crm_send_notification_sms with your own implementation.
13. WPResidence / WPEstate CRM

Related Articles

  • WPResidence CRM Security Model — Developer Reference
  • CRM Security and Data Privacy
  • WPResidence CRM Installation and Updates — Developer Reference
  • Installing and Updating the WPResidence CRM

WP Residence Documentation

  • 01. Getting Started
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 02. Installation & Setup
  • 03. Installation FAQ
  • 06. Search & Filtering
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 09. Agent, Agency & Developers
  • 08. Property Pages & Layouts
  • 07. Property Lists, Categories & Archive
  • 14. WPResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • 04. Theme Options & Global Settings
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • 20. Translations & Languages
  • 26. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 19. Included Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 24. Technical how to | Custom Code Required
    • 25. Technical: Child Theme

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API