| 1 | <extension name="signalwire sms curl"> |
| 2 | <condition field="destination_number" expression="^792$"> |
| 3 | |
| 4 | <!-- setup bleg uuid of this call so we we know it before hand --> |
| 5 | <action application="set" inline="true" data="bleg_uuid=${create_uuid()}"/> |
| 6 | |
| 7 | <!-- setup signalwire credentials --> |
| 8 | <action application="set" inline="true" data="space_name=XXXXXX"/> |
| 9 | <action application="set" inline="true" data="project_key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"/> |
| 10 | <action application="set" inline="true" data="api_token=PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/> |
| 11 | |
| 12 | <!-- not using '+' here, just the 11 digit number itself, see curl line below --> |
| 13 | <action application="set" inline="true" data="signalwire_number=1XXXXXXXXXX"/> |
| 14 | <action application="set" inline="true" data="cellphone=1XXXXXXXXXX"/> |
| 15 | |
| 16 | <!-- urlencode your 'spaces' to '%20' so the text body will work in the url, may need to consider other untested puncuations --> |
| 17 | <action application="set" inline="true" data="sms_body=${system(printf 'aleg ${uuid} is calling bleg ${bleg_uuid}' | sed -r 's/ /%20/g')}"/> |
| 18 | |
| 19 | <!-- We need to base64 encode the basic authorization --> |
| 20 | <action application="set" inline="true" data="auth=${system(printf '${project_key}:${api_token}' | base64 --wrap 0)}"/> |
| 21 | |
| 22 | <!-- notice for E.164 formatting we encode the '+' to '%2B' for the 'From' and 'To' params on the URL --> |
| 23 | <action application="curl" data="https://${space_name}.signalwire.com/api/laml/2010-04-01/Accounts/${project_key}/Messages.json?From=%2B${signalwire_number}&To=%2B${cellphone}&Body=${sms_body} append_headers Authorization:'basic ${auth}' post"/> |
| 24 | |
| 25 | <action application="hangup"/> |
| 26 | </condition> |
| 27 | </extension> |