How to make Directory() more robust

Folks,

For an incoming call, we present the caller with directory menu:

exten => 8, 1, Directory(default, SIP)

Sometimes, because of network problems, a SIP phone may not register with Asterisk. When the caller selects the last 3 digits of a person’s name whose phone is not registered, asterisk just hangs up the phone (as haven’t defined any other rule).

Ideally, I would like to take the caller to that person’s voicemail.

exten => 8, 1, Directory(default, SIP)
exten => 8,2,Gosub(stdexten(xxx, SIP/xxx)

OR

exten => 8, 1, Directory(default, SIP)
exten => 8,2, Voicemail(xxx, u)

The problem is, I don’t know how to get the extension out of Directory() function and pass it on to the next step.

Is there a way to do this?

Or, is there a better approach?

Thank you in advance for your help.

Regards,
Peter

Anyone?

My only other option is to write our own “hardcoded” logic for each number. I would like to avoid that, if possible.

Appreciate your help.

Regards,
Peter

The second option for the Directory is the dial-context, so instead of SIP you can do something like this:

exten => 8, 1, Directory(default, new-context)

And then in the context ‘new-context’

[new-context]
exten => _XXX,1,Dial(SIP/${EXTEN},20) //Ring 20 seconds
exten => _XXX,n,Voicemail(${EXTEN},u)

If you already have a context setup that sends a person to voicemail you can just set the dial-context to that instead.

Awesome. I will try this and let you know.

Thank you for your help.

Peter

[quote=“bkofd”]The second option for the Directory is the dial-context, so instead of SIP you can do something like this:

exten => 8, 1, Directory(default, new-context)

And then in the context ‘new-context’

[new-context]
exten => _XXX,1,Dial(SIP/${EXTEN},20) //Ring 20 seconds
exten => _XXX,n,Voicemail(${EXTEN},u)

If you already have a context setup that sends a person to voicemail you can just set the dial-context to that instead.[/quote]

That did the trick. Appreciate your help.

Peter

[quote=“PeterTaps”]Awesome. I will try this and let you know.

Thank you for your help.

Peter

[quote=“bkofd”]The second option for the Directory is the dial-context, so instead of SIP you can do something like this:

exten => 8, 1, Directory(default, new-context)

And then in the context ‘new-context’

[new-context]
exten => _XXX,1,Dial(SIP/${EXTEN},20) //Ring 20 seconds
exten => _XXX,n,Voicemail(${EXTEN},u)

If you already have a context setup that sends a person to voicemail you can just set the dial-context to that instead.[/quote][/quote]