How to know the extension number

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

How to know the extension number

Postby piron_t » Fri Aug 17, 2012 8:48 am

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: Select all
[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


The ${EXTEN} is equal to "s", but i want to know which one i'm calling

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


Any way to get the variable containing my 1002 extension id ?
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby david55 » Fri Aug 17, 2012 9:04 am

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.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: How to know the extension number

Postby piron_t » Fri Aug 17, 2012 9:25 am

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

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


With my .call file :

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


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.
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby david55 » Fri Aug 17, 2012 9:37 am

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.)
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: How to know the extension number

Postby piron_t » Fri Aug 17, 2012 9:39 am

david55 wrote: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.)


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

Thanks :)
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby piron_t » Mon Aug 20, 2012 7:47 am

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



== 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
-- <OutgoingSpoolFailed>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'


I must know the number I call in order to determine the next number to call with my agi script
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby david55 » Mon Aug 20, 2012 7:50 am

Use a local channel. You can then explicitly dial the target channel, and handle any failures.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: How to know the extension number

Postby piron_t » Mon Aug 20, 2012 7:56 am

david55 wrote: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)
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby david55 » Mon Aug 20, 2012 7:59 am

That's what I woudl do for the part A side. You can probably keep the same B side logic.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: How to know the extension number

Postby piron_t » Mon Aug 20, 2012 8:36 am

david55 wrote: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

[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


== 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


My generate .call file :

Channel: SIP/1002
Callerid: 09XXXXXXXX
MaxRetries: 0
RetryTime: 10
WaitTime: 20
Context: appel-sortant
Extension: 1002
Priority: 1
piron_t
Newsterisk
 
Posts: 11
Joined: Thu Aug 16, 2012 3:56 am

Re: How to know the extension number

Postby david55 » Mon Aug 20, 2012 8:48 am

Channel: Local/1002@OriginateContext
Callerid: 09XXXXXXXX
MaxRetries: 0
RetryTime: 10
WaitTime: 20
Context: appel-sortant
Extension: s
Priority: 1
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am


Return to Asterisk Support

Who is online

Users browsing this forum: No registered users and 1 guest