Remove prefix on destination number

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

Remove prefix on destination number

Postby vinsbg » Fri Jan 29, 2016 4:23 am

How to put condition if dialed number is abcXXXXXXXXXXX to remove abc, leave only the number and redirect to voicemail.?I tried this but doesn't work..
Code: Select all
exten => _[a-z]XXXXXXXXXXXX,1,Voicemail({EXTEN}=${EXTEN:3}@VoiceMail)
exten => _[a-z]XXXXXXXXXXXX,2,Playback(Goodbye)
exten => _[a-z]XXXXXXXxXXXX,3,Hangup
Last edited by vinsbg on Fri Jan 29, 2016 6:26 am, edited 1 time in total.
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby Lexus45 » Fri Jan 29, 2016 6:26 am

This is explained here: https://wiki.asterisk.org/wiki/display/ ... les+Basics

In fact it seems that you do everything in the right way. Just pay attention that ${EXTEN} is a pre-defined Asterisk variable.

You may change your diaplan to something like:
Code: Select all
exten => _[a-z]XXXXXXXXXXXX,1,Voicemail(${EXTEN:3}@VoiceMail)
    same => n,Playback(Goodbye)
    same => n,Hangup
Last edited by Lexus45 on Fri Jan 29, 2016 6:30 am, edited 2 times in total.
Lexus45
Oldsterisk
 
Posts: 138
Joined: Tue Jul 10, 2012 11:22 pm

Re: Remove prefix on destination number

Postby vinsbg » Fri Jan 29, 2016 6:27 am

I have edited my question since i was wrote it wrong.
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby vinsbg » Fri Jan 29, 2016 6:34 am

Now if I dial "abc1111111111" I get response that 'abc1111111111' is not found in context. I have '1111111111' in context.. thats why I need to remove 'abc'.
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby david55 » Fri Jan 29, 2016 7:22 am

The only ways of setting ${EXTEN} are GoTo and GoSub!
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: Remove prefix on destination number

Postby vinsbg » Fri Jan 29, 2016 7:37 am

david55 wrote:The only ways of setting ${EXTEN} are GoTo and GoSub!


Can you provide me some example? How to call to number abc123456789 -> remove abc -> call to 123456789
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby david55 » Fri Jan 29, 2016 7:53 am

It's too obvious to require examples.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: Remove prefix on destination number

Postby vinsbg » Fri Jan 29, 2016 7:58 am

david55 wrote:It's too obvious to require examples.

But {EXTEN} is the caller, right? I don't care the number of the caller.. I know how to cut/remove digits from the caller but don't know from the number B ( called number )
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby david55 » Fri Jan 29, 2016 8:11 am

Wrong.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: Remove prefix on destination number

Postby vinsbg » Mon Feb 01, 2016 6:07 am

Tried with something like this
Code: Select all
exten => _X.,1,Set(SAFE_EXTEN=${FILTER(0-9,${EXTEN})})
exten => _X.,n,Voicemail(${EXTEN}@VoiceMail)
exten => _X.,n,Playback(Goodbye)
exten => _X.,n,Hangup

also with this
Code: Select all
exten => _[a-z]XXXXXXXXXXXX,1,Goto{${EXTEN:3},1)
exten => _XXXXXXXXXXXX,1,Dial(SIP/${EXTEN},1)
exten => _XXXXXXXXXXXX,n,Voicemail(${EXTEN}@VoiceMail)

Still when I try to make test call to 'asd12345' I got that this number is not found in the context... number 12345 is in the context.
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby david55 » Mon Feb 01, 2016 6:48 am

X only matches digits.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: Remove prefix on destination number

Postby vinsbg » Mon Feb 01, 2016 6:51 am

Well second dialplan as I understand should match chars+digits and will cut first 3 from number:
Code: Select all
exten => _[a-z]XXXXXXXXXXXX,1,Goto{${EXTEN:3},1)

but it doesn't.. Any idea why?
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am

Re: Remove prefix on destination number

Postby vinsbg » Mon Feb 01, 2016 7:51 am

I's solved thank's.
vinsbg
Newsterisk
 
Posts: 13
Joined: Wed Dec 09, 2015 6:34 am


Return to Asterisk Support

Who is online

Users browsing this forum: Google [Bot] and 18 guests