Search code examples
pattern-matchingasteriskvoip

How do I match two or more numbers in a dialplan?


I have two DID numbers I want to forward to the same IVR on inbound calls:

  • 1234
  • 4321

How can I do this? I've tried:

exten => ^(1234|4321),1,Answer()

but it does not work - it cannot find the extension and falls to the catchall trap. It basically does not match and this part of my dialplan, placed at the bottom, is executed:

exten => _X.,1,Answer()
exten => _X.,2,agi(googletts.agi,"No extension found",en)
exten => _X.,3,Hangup()

Using a single number instead of that expression works just fine. Any hints?

Thanks


Solution

  • Asterisk dialplan is not fully compliant with GNU regexp

    http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns

    There are no "or"(|) operation in asterisk dialplan. Recommended way do something like this

    [incoming]
    exten => 1234,1,Goto(special_routine,s,1)
    exten => 4321,1,Goto(special_routine,s,1)
    include =>other; include other context, have less priority
    [special_routine]
    exten => s,1,Answer; do something for both numbers
    [other];do this if no extension
    exten => s,1,Answer()
    exten => s,2,agi(googletts.agi,"No extension found",en)
    exten => s,3,Hangup()