Friday, August 24, 2018

Receive SMS and USSD

You can handle received SMS and USSD using sms and ussd exten, respectively.
Example for received sms
[dongle-incoming-sms]
exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/sms.txt)
exten => sms,n,Hangup()
Example for received USSD
[dongle-incoming-ussd]
exten => ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
exten => ussd,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME}: ${BASE64_DECODE(${USSD_BASE64})}' >> /var/log/asterisk/ussd.txt)
exten => ussd,n,Hangup()
Also note, execution of this exten takes place in a “Local” channel.
Always define sms and ussd extens for context where you handle incoming calls for dongle device! Otherwise, incoming SMS or USSD can execute extensions for voice call with unpredictable results.
[dongle-incoming]
include => dongle-incoming-sms
include => dongle-incoming-ussd
Also note that h exten is executed for SMS/USSD just before Local channel is destroyed.

1 comment:

  1. How can we set it up for each dongle separately? Like for each dongle, we set up different settings.

    ReplyDelete