How to know the extension number

Hi,

I’m using .call files, to call for exemple an extension 1002.

In my extensions.conf, i want to know the extension i’m currently calling.

[code][appel-sortant]

exten => s,1,AGI(/var/lib/asterisk/agi-bin/getNext.php, ${EXTEN})
; Do some stuff here, like a Dial
exten => s,n,Hangup[/code]

The ${EXTEN} is equal to “s”, but i want to know which one i’m calling

[quote]-- Executing [s@appel-sortant:11] AGI(“SIP/1002-0000005f”, “/var/lib/asterisk/agi-bin/getNext.php,s”) in new stack
[/quote]

Any way to get the variable containing my 1002 extension id ?

If the value is s, you are calling s.

If you want to know the destination extension number, you need to copy it into a variable before you call the s extension in your macro or subroutine.

I think you need to provide verbose CLI output so one can see what dialplan is actually being run.

Yes, i’m calling s, but the dial line call the 1002 extension

exten => s,n,Dial(SIP/${EXTEN}@forfait-ovh,30,gtr)

With my .call file :

[quote]
Channel: SIP/1002@forfait-ovh
Callerid: 09XXXXXXXX
MaxRetries: 0
RetryTime: 10
WaitTime: 20
Context: appel-sortant
Extension: s
Priority: 1[/quote]

Can i get a variable from my .call file in the extension.conf ?

I want to know in the extensions.conf file the number i’m calling, to execute a AGI script with the number in argument, to get the next number i have to call.

It doesn’t call an extension at all, it calls a device. You can get the device name by parsing ${CHANNEL}.

Other options exist if you know the device technology (SIP, IAX, DAHDI, etc.)

[quote=“david55”]It doesn’t call an extension at all, it calls a device. You can get the device name by parsing ${CHANNEL}.

Other options exist if you know the device technology (SIP, IAX, DAHDI, etc.)[/quote]

Ok, thanks, i’ll parse the ${CHANNEL} to get the device name.

Thanks :smile:

Hi,

Parsing the ${CHANNEL} works fine if the callee answer the call, but if he do nothing or decline, the ${CHANNEL} is egal to : OutgoingSpoolFailed

[quote] == Using SIP RTP CoS mark 5
– Got SIP response 603 “Decline” back from 192.168.21.52
> Channel SIP/1002-00000025 was never answered.
– Executing [failed@appel-sortant:1] NoOp(“OutgoingSpoolFailed”, “appel-sortant failed”) in new stack
– Executing [failed@appel-sortant:2] Set(“OutgoingSpoolFailed”, “NEXT=0”) in new stack
– Executing [failed@appel-sortant:3] AGI(“OutgoingSpoolFailed”, “/var/lib/asterisk/agi-bin/getNext.php,OutgoingSpoolFailed”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/getNext.php
– AGI Script /var/lib/asterisk/agi-bin/getNext.php completed, returning 0
– Executing [failed@appel-sortant:4] System(“OutgoingSpoolFailed”, “/var/lib/asterisk/outbound/callPeople.sh 0”) in new stack
– Executing [failed@appel-sortant:5] Hangup(“OutgoingSpoolFailed”, “”) in new stack
== Spawn extension (appel-sortant, failed, 5) exited non-zero on ‘OutgoingSpoolFailed’
[/quote]

I must know the number I call in order to determine the next number to call with my agi script

Use a local channel. You can then explicitly dial the target channel, and handle any failures.

Ok, then, i do not have to use the “s” extension, but something like “_X.” ? (I have some number to call like 09XXXXXXXX or other like 06XXXXXXXX)

That’s what I woudl do for the part A side. You can probably keep the same B side logic.

I can’t figure out why i got the same problem with the _X. extension

[quote][appel-sortant]
exten => _X.,1,Answer
exten => _X.,n,Set(LOOP=0)
exten => _X.,n,Set(MAX=3)
exten => _X.,n,Set(ACCEPT_INTER=0)
exten => _X.,n,Set(NEXT=0)
exten => _X.,n,Goto(test,${EXTEN},1)

exten => failed,1,NoOp(appel sortant failed)
exten => failed,n,NoOp(${EXTEN}) ; print “failed”

[test]
exten => _X.,1,NoOp(${EXTEN})
exten => _X.,n,Hangup[/quote]

[quote] == Using SIP RTP CoS mark 5
– Executing [failed@appel-sortant:1] NoOp(“OutgoingSpoolFailed”, “appel sortant failed”) in new stack
– Executing [failed@appel-sortant:2] NoOp(“OutgoingSpoolFailed”, “failed”) in new stack
– Auto fallthrough, channel ‘OutgoingSpoolFailed’ status is ‘UNKNOWN’
[Aug 20 16:30:37] NOTICE[10147]: pbx_spool.c:339 attempt_thread: Call failed to go through, reason (3) Remote end Ringing
[/quote]

My generate .call file :

[quote]Channel: SIP/1002
Callerid: 09XXXXXXXX
MaxRetries: 0
RetryTime: 10
WaitTime: 20
Context: appel-sortant
Extension: 1002
Priority: 1[/quote]

[quote]Channel: [color=#FF0000]Local/1002@OriginateContext[/color]
Callerid: 09XXXXXXXX
MaxRetries: 0
RetryTime: 10
WaitTime: 20
Context: appel-sortant
Extension: [color=#FF0000]s[/color]
Priority: 1[/quote]