For Chan Dongle, How to forward incoming sms / ussd from each dongle to different email addresses?

1.6k Views Asked by At

I have two dongles connected to asterisk. Calls are routing fine. It's sms/ussd I am having issues with. How do I forward sms/ussd from each dongle to different email address? Currently, sms from both Dongles are forwarded to one email address.

Following is my current configuration in extensions_custom.conf

[from-trunk-dongle]
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\n${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: " > /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 => ussd,1,Verbose(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()

exten => _.,1,Set(CALLERID(name)=${CALLERID(num)})
exten => _.,n,Goto(from-trunk,${EXTEN},1)

Following is my current configuration in dongle.conf

[dongle0]
exten=+15141234567               ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)
audio=/dev/ttyUSB1              ; tty port for audio connection;        no default value
data=/dev/ttyUSB2               ; tty port for AT commands;             no default value

[dongle1]
exten=+14161234567               ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)
audio=/dev/ttyUSB4              ; tty port for audio connection;        no default value
data=/dev/ttyUSB5               ; tty port for AT commands;             no default value

Is it possible to have individual setting for each dongle in [from-trunk-dongle] and then have sms/ussd forwarded based on the dongle/sim it's coming from (routed to each email address).

Thanks

1

There are 1 best solutions below

1
arheops On

Simplest way(for beginners) - create different contexts each set context name.

Or check CONTEXT variable.

More complex way - use DumpChan and see the difference or rewrite chan_dongle to put name of dongle into variable.