eli chen
eli chen

Reputation: 878

get the caller number after call is answered

I have a php script that run when call is answered it's in [macro-blkvm-clr] macro. the php get 3 parms the first param should be the caller number this is my line

exten => s,n,AGI(/var/lib/asterisk/agi-bin/alertcalls.php,${CALLERID(num)},1,${MASTER_CHANNEL(CONNECTEDLINE(num))})

I don't know why but when it asterisk send the parameter to php it set it to the answered phone. for example ext 300 call to ext 200 and in the log that what I see

Executing [s@macro-blkvm-clr:2] AGI("PJSIP/200-00000253", "/var/lib/asterisk/agi-bin/alertcalls.php,200,1,200") in new stack

why is that. and how can I send the real ext that call (in this case 300)

thks for all helper and sorry for my English I hope I was clear

Upvotes: 0

Views: 1843

Answers (3)

0cool
0cool

Reputation: 42

You can save the

exten => s,n,SET(VAR1=${CALLERID(num)})
exten => s,n,AGI(/var/lib/asterisk/agi-bin/alertcalls.php,${VAR1},1,${MASTER_CHANNEL(CONNECTEDLINE(num))})

Upvotes: 1

MichelV69
MichelV69

Reputation: 1212

Save the caller ID number into a channel variable before you Answer() the call, and then reference that. You should always be able to reference ${CALLERID(num)}, but if it's not working for you at that point, the above is an easy work around.

Upvotes: 0

arheops
arheops

Reputation: 15259

Becuase macro executed for CALLED party channel(it was invented to do privacy) before connect called and calling channel.

You can see all variables by do Dumpchan as first priority in macro.

Upvotes: 0

Related Questions