Telephony and PBX Specification¶
Overview¶
The current telephony stack is hybrid. Twilio remains deeply involved in SMS, delivery status, replay, and several call-related flows, while PBX/FreePBX files and Edge Functions support click-to-call and operational call synchronization.
Current Components¶
PBX-side assets¶
freepbx/gm-call.phpfreepbx/extensions_custom.conffreepbx/extensions_override_freepbx.conf
Twilio-side assets¶
twilio/call-handle-ib.jstwilio/call-handle-ob.jstwilio/send-sms-local-cid.jstwilio/voicemail-drop.jstwilio/supa-handle-ib.jstwilio/supa-handle-ob.js- supporting scripts such as
get-messages.pyandtest-sms.js
Supabase telephony functions¶
thread-call-dialthread-update-last-call-userthread-voicemail-openlead-pbx-actionslead-pbx-sms-actionscall-missed-answeredcall-recording-transcriptvoicemail-droptwilio-message-retrievetwilio-message-replay
Outbound Call Flow¶
Browser preflight¶
- The UI calls
thread-call-dialto: - verify no conflicting active caller
- stamp thread active caller metadata
- record analytics
Browser PBX URL generation¶
src/utils/callHelpers.tsbuilds the PBX click-to-call URL- The URL points at
https://pbx.glassmaster.app/gm-call.php - If both a lead phone and insurance phone are present, they are passed as
lead|insurance
PBX originate¶
gm-call.phpauthenticates to the Asterisk AMI- It originates a call to the user extension
- It passes the target number(s) into the
click-to-call-outdialplan context
FreePBX dialplan behavior¶
extensions_custom.confsplits thelead|insurancepayload- It selects whether the call is a lead call or insurance call
- It fires async webhooks back to Supabase
- It dials out through
PJSIP/...@Twilio
Inbound and Voicemail Flow¶
- FreePBX override files contain macros that fire webhooks on inbound answer and voicemail entry
thread-voicemail-openis used to reopen or mark thread/message state when voicemail occurscall-missed-answeredhandles call lifecycle updates from webhook traffic
SMS Flow Reality¶
- The message path is still predominantly Twilio-based
message-inbound,message-send,message-delivery-status,campaign-lead-send, and related functions are central to SMS operations- PBX helper functions exist, but they do not replace the current Twilio-centered messaging pipeline
Architectural Assessment¶
What is true today¶
- PBX is a real operational part of click-to-call and some webhook flows
- Twilio is still a real operational part of messaging and portions of calling/transcript behavior
- The system is not yet a clean “PBX replaced Twilio” architecture
Risks¶
- Provider split increases debugging complexity
- Telephony config is partly encoded in repo files with environment-specific assumptions
- Some webhook wiring appears operationally brittle because behavior is distributed across PHP, dialplan, Twilio scripts, and Edge Functions
Documentation Rule¶
When changing telephony behavior, document both: - the UI/API entrypoint - the provider-specific execution path after handoff