How to extract the mobile number ("follow my" module) from the astdb for the AGI-script?


(Snaggy) #1

Hello
I have a script that runs when the call hang up

[macro-dial-ringall-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dial-ringall-predial-hook in extensions_custom.conf)
exten => s,n,Set(CHANNEL(hangup_handler_push)=send_sms,s,1)
exten => s,n,MacroExit

[macro-dial-hunt-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dial-hunt-predial-hook in extensions_custom.conf)
exten => s,n,Set(CHANNEL(hangup_handler_push)=send_sms,s,1)
exten => s,n,MacroExit

[send_sms]
exten => s,1,Noop(Entering user defined context send_sms in extensions_custom.conf)
exten => s,n,AGI(sms/sms.php,${CONNECTEDLINE(num)},${DIALSTATUS},${CDR(dstchannel)})
exten => s,n,Return

when the call ends with the status CANCEL and ANSWER
in the logs I see the corresponding entries and my script works

Executing [s@send_sms:2] AGI("SIP/646832-sip-0000014e", "sms/sms.php,113,ANSWER,Local/XXXXXXXXXXX@from-internal-00000067;1") in new stack

or

Executing [s@send_sms:2] AGI("SIP/646832-0000004b", "sms/sms.php,113,CANCEL,Local/XXXXXXXXXXX@from-internal-0000001a;1") in new stack

XXXXXXXXXXX - operator’s mobile phone recorded in the “follow me” module

however, if the call ends with a BUSY status I get this message

Executing [s@send_sms:2] AGI("SIP/646832-sip-00000198", "sms/sms.php,113,CHANUNAVAIL,") in new stack

and my script doesn’t work

in this regard, I have a question for respected experts
how can I take from the astdb the mobile phone number (“follow me” module) corresponding to the internal number (${CONNECTEDLINE(num)}) and pass it as an argument when starting the script?
instead of this entry ${CDR(dstchannel)}

 [send_sms]
    exten => s,1,Noop(Entering user defined context send_sms in extensions_custom.conf)
    *here is some command to extract a mobile number from the astdb*
    exten => s,n,AGI(sms/sms.php,${CONNECTEDLINE(num)},${DIALSTATUS},${Mobile Number})
    exten => s,n,Return

Thanks for attention


(Lorne Gaetz) #2

The follow me destinations for a particular extension are in the database key:

/AMPUSER/xxxx/followme/grplist

where the x’s are the ext number. It will return a list of numbers separated by a - character. I’m not sure this approach will get you anywhere, since you won’t be able to tell which of the numbers in the list answered.