Asterisk SMS转发/来电通知到Telegram

之前一直使用Raspi4配合RasPBX(http://www.raspberry-asterisk.org/)接收短信和电话,最近因为某些原因换掉了这套方案,但应该有不少人有这个需求,所以把我写的规则发布出来。

将#chatid#和#botkey#替换之后塞入extensions_custom.conf即可,telegram的bot和chatid请自行想办法获取。

[from-trunk-dongle]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,Set(FILE(/var/log/asterisk/sms.txt,,,a)=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})})
exten => sms,n,System(echo >> /var/log/asterisk/sms.txt)
exten => sms,n,System(curl -d 'chat_id=#chatid#&text=${URIENCODE(${BASE64_DECODE(${SMS_BASE64})})}\nForm:${DONGLENAME} - ${CALLERID(num)}' 'https://api.telegram.org/#botkey#/sendMessage')
exten => sms,n,Hangup()
exten => _X.,1,Set(CALLERID(name)=${CALLERID(num)})
exten => _X.,n,System(curl -d 'chat_id=#chatid#&text=${URIENCODE(Incoming Call:${CALLERID(num)} via ${DONGLENAME})}' 'https://api.telegram.org/#botkey#/sendMessa
ge')
exten => _X.,n,Goto(from-trunk,${EXTEN},1)

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注