Receiving SMS problem

I am using a file /etc/asterisk/extensions_custom.conf to send me a received SMS (SMS received by USB dongle). The content of a file is:

exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,System(echo "To: [email protected]\nSubject: Incoming SMS from ${CALLERID(num)}\n\nOn ${STRFTIME(${EPOCH},,%d. %m. %Y at %H:%M:%S)} you received SMS from number ${CALLERID(num)}.\n\nSMS content:\n " > /tmp/sms.txt)
exten => sms,n,Set(FILE(/tmp/sms.txt,,,a)=${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,System(sendmail -t < /tmp/sms.txt)
exten => sms,n,Hangup()
exten => _.,1,Set(CALLERID(name)=${CALLERID(num)})
exten => _.,n,Goto(from-trunk,${EXTEN},1)

No, I want this SMS to be sent to my Signal number via Signal API. (Signal is a secure messenger.) In terminal I can write this command:

echo "{\"message\": \"On $(date '+%m. %d. %Y at %H:%M:%S') you have received SMS message.\", \"number\": \"+XXXXXXXXXXX\", \"recipients\": [\"+YYYYYYYYYYY\"]}" | /usr/bin/curl --user 'user:password' -X POST -H "Content-Type: application/json" -d @- ''

This works, but from the terminal only. If I put this into the /etc/asterisk/extensions_custom.conf (after the line starting with exten => sms,1,Verbose, I do not receive any Signal message.

Any idea what could be a problem?

I would guess there is some problem with the escaping of that shell command because it is a bit complicated.

Asterisk has curl functions you can use from the dialplan.

bell2*CLI> core show function CURL

  -= Info about function 'CURL' =- 

Retrieve content from a remote web or ftp server 

When this function is read, a 'HTTP GET' (by default) will be used to retrieve
the contents of the provided <url>. The contents are returned as the result of
the function.
Example: Displaying contents of a page

 exten => s,1,Verbose(0, ${CURL(http://localhost:8088/static/astman.css)})
When this function is written to, a 'HTTP GET' will be used to retrieve the
contents of the provided <url>. The value written to the function specifies the
destination file of the cURL'd resource.
Example: Retrieving a file

 exten => s,1,Set(CURL(http://localhost:8088/static/astman.css)=/var/spool/aste
NOTE: If 'live_dangerously' in 'asterisk.conf' is set to 'no', this function
can only be written to from the dialplan, and not directly from external
protocols. Read operations are unaffected.


    The full URL for the resource to retrieve.
    *Read Only*
    If specified, an 'HTTP POST' will be performed with the content of
    <post-data>, instead of an 'HTTP GET' (default).

[See Also]


bell2*CLI> core show function CURLOPT

  -= Info about function 'CURLOPT' =- 

Set options for use with the CURL() function

  cookie         - Send cookie with request [none]
  conntimeout    - Number of seconds to wait for connection
  dnstimeout     - Number of seconds to wait for DNS response
  followlocation - Follow HTTP 3xx redirects (boolean)
  ftptext        - For FTP, force a text transfer (boolean)
  ftptimeout     - For FTP, the server response timeout
  header         - Retrieve header information (boolean)
  httpheader     - Add new custom http header (string)
  httptimeout    - Number of seconds to wait for HTTP response
  maxredirs      - Maximum number of redirects to follow
  proxy          - Hostname or IP to use as a proxy
  proxytype      - http, socks4, or socks5
  proxyport      - port number of the proxy
  proxyuserpwd   - A <user>:<pass> to use for authentication
  referer        - Referer URL to use for the request
  useragent      - UserAgent string to use
  userpwd        - A <user>:<pass> to use for authentication
  ssl_verifypeer - Whether to verify the peer certificate (boolean)
  hashcompat     - Result data will be compatible for use with HASH()
                 - if value is "legacy", will translate '+' to ' '
  failurecodes   - A comma separated list of HTTP response codes to be treated as errors


Not available

[See Also]
Not available

Hmm, do you maybe know where are the log files for commands running from /etc/asterisk/extensions_custom.conf?

Dialplan results are logged in /var/log/asterisk/full

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.