Skip to content

Scripts for sending and receiving SMS between FreePBX and Telnyx

License

Notifications You must be signed in to change notification settings

simontelephonics/freepbx-telnyx-sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

freepbx-telnyx-sms

Scripts for sending and receiving SMS between FreePBX and Telnyx

Installation

Add the dialplan blocks to /etc/asterisk/extensions_custom.conf, adjusting them according to your environment:

  • extension length
  • catch-all e-mail to receive undeliverable texts
  • number normalization

Make a directory under (wwwroot) called sms and ensure it can be reached by HTTPS from outside.

Place the out.php and telnyx.php scripts into sms and adjust them according to your environment.

out.php:

  • add your Telnyx APIv2 API key

telnyx.php:

  • note the instructions in the comments at the top of the file

Place the included php-sip library in a directory of that name under sms.

FreePBX configuration

Trunk

Set up a PJSIP trunk for 127.0.0.1 as follows:

PJSIP trunk

Set the Message Context:

PJSIP advanced tab

...

PJSIP message context field

Extensions

For each extension that will participate in SMS, set the Account Code to the normalized DID this extension will send and receive as, and set the Message Context:

Extension settings

...

Extension account code

...

Extension message context

Telnyx configuration

Set up a Messaging Profile (APIv2) in Telnyx:

Telnyx messaging profile

Specify the path to the telnyx.php script in Inbound Settings:

Messaging profile inbound settings

Copy the Profile Secret from the Outbound Settings section and use it as the token in your out.php script.

Save this profile and assign it to the DIDs you want to enable for SMS.

Usage

SMS from Telnyx will be delivered to the telnyx.php script specifying a DID. Any extension whose Account Code has that DID will receive the SMS.

SMS from extensions will be sent to Telnyx using the caller ID in the extension's Account Code field. You can only send from numbers that are on your account.

Extensions can text among themselves through the Asterisk dialplan without engaging Telnyx.

These scripts are normalized for US/CAN 10-digit DIDs and would need to be adjusted for international SMS or handling of short codes.

About

Scripts for sending and receiving SMS between FreePBX and Telnyx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages