Sending an SMS from FreeSWITCH XML dialplan
In order to send an SMS from a FreeSWITCH dialplan extension, we need to do a few things:
-
Fill out the space_name, project_key, api_token, signalwire_number, and cellphone channel variables.
-
Substitute all the spaces in the sms_body for the url encoded equivalent of %20:
sms_body=${system(printf 'aleg ${uuid} is calling bleg ${bleg_uuid}' | sed -r 's/ /%20/g')} -
Calculate the base64 equivalent of your authorization credentials so auth is properly setup for curl header append_headers
Authorization:'basic ${auth}':
auth=${system(printf '${project_key}:${api_token}' | base64 --wrap 0)
- Then, you have the Dialplan Extension. Dial 792 from any registered sip phone, or from bash do: fs_cli -x ‘originate loopback/792 echo inline’. Then, your cellphone should receive a text. Review the comments in the extension for additional notes.
From this example, your cellphone should receive an SMS that looks like this:
aleg 0739c067-c8b3-4a1d-bc8d-76f4a7e71c55 is calling bleg 426cd62b-fbcf-4fb2-a10a-9226dff5ac5d