Creating custom Dialplan for playing an automated voice

Hi all,
I want to setup configurations as below and I have tried almost everything but for some unknown reasons its not working and its driving me crazy.
it would be great if I can get help.
I have a main extension (lets say 1000) and some side extensions (lets say 1001 and 1002).
I want to have this configuration that as soon as main extension (1000) calls the other extensions (1001 or 1002) a recorded message plays and then once it is finished, the call get disconnects.
I have tried multiple custom Dialplans but its not working and once I call the side extensions from the main extensions, its like a normal call and voice of each side can be heard on the other side instead of playing the recorded sound on B side.
here is what i have done :
editing the /etc/asterisk/extensions.conf as below:
[default]

; Define the primary extension (e.g., 1000)
exten => 1000,1,NoOp(Primary Extension)
same => n,Answer()
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

; Define side extensions (e.g., 1001, 1002, etc.)
exten => 1001,1,NoOp(Side Extension 1001)
same => n,Dial(SIP/1001)

exten => 1002,1,NoOp(Side Extension 1002)
same => n,Dial(SIP/1002)

; Add more side extensions as needed

; Rule for when primary extension calls side extensions
exten => _1XXX,1,NoOp(Primary to Side Extension Call)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

editing /etc/asterisk/sip.conf as below :

[sip]

; Primary extension (e.g., 1000)
[1000]
type=friend
context=default
host=dynamic
secret=yourpassword
; Add other necessary settings

; Side extensions (e.g., 1001, 1002)
[1001]
type=friend
context=default
host=dynamic
secret=yourpassword
; Add other necessary settings

[1002]
type=friend
context=default
host=dynamic
secret=yourpassword
; Add other necessary settings

asterisk -rx “dialplan reload”
asterisk -rx “sip reload”

I am on asterisk v 18.19.0

I’m not 100% sure, but I think your problem may be this line :
; Rule for when primary extension calls side extensions
exten => _1XXX,1,NoOp(Primary to Side Extension Call)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

this should be at the top of your default context, I think your calls from 1000 to 1001 and 1002 are matching the rules for “Define side extensions (e.g., 1001, 1002, etc.)” which should just dial these extensions; Or you could separate your inbound and outbound contexts.

again, I may be mistaken, but you can give it a shot

You should be using PJSIP vs SIP. SIP is old, it’s no longer supported in newer versions, and unless you have a very specific reason; PJSIP should be used. However, that’s not why this isn’t working; it’s just the first glaring thing I see.

So how are you wanting this to work? Does a person have to get to extension 1000 before they can get to 1001 or 1002? Can they dial 1001 and 1002 from the same menu they’d enter 1000?

Matching is done in order it’s in dialplan; so your pattern matching will only match when the entered extension isn’t 1000,1001, or 1002. I do believe it will also check the rest of the dialplan for exact matches before pattern matching; this is something that’s better documented than the practical knowledge I’m pulling off the top of my head.

Beyond that, extensions 1001 and 1002 are set to dial. You only dial an endpoint if you want to actually call that endpoint. If you just want to play a message and hangup, then it should look like this:

; Define side extensions (e.g., 1001, 1002, etc.)
exten => 1001,1,NoOp(Side Extension 1001)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

exten => 1002,1,NoOp(Side Extension 1002)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

And since it sounds like you want there to be a sub-menu, here’s how I’d split it out:

[default]

exten => 1000,1,NoOp(Primary Extension)
same => n,Answer()
same => n,GoTo(1000ivr,s,1) ; jump to 's' extension in 1000ivr context

[1000ivr]

exten => s,1,Answer()
same => n,Background(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

; Define side extensions (e.g., 1001, 1002, etc.)

exten => 1001,1,NoOp(Side Extension 1001)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

exten => 1002,1,NoOp(Side Extension 1002)
same => n,Playback(welcome-message) ; Play the recorded message (without extension)
same => n,Hangup()

So what happens is when someone from the main menu enters 1000; the dialplan now executes a Goto in to a specific extension in a new context. I use the ‘s’ extension for this, which probably isn’t proper, as it’s what we had to do back in the days of analog lines when incoming calls didn’t have an extension specificed; but it’s also how I’ve always done IVRs.

So what does changing contexts do? It changes the rules. Whatever extensions existed before, they don’t anymore. We’re basically in an entirely new room. The ‘s’ extension where we start, answers the calls and plays the recorded message. I changed this to Background() vs Playback(). Playback will not allow extension input during it’s operation. So the person entering 1000 will hear the message, try to input numbers, then get hung-up on. Background() solves this listening for digits during playback. It’s usually a good idea to leave some time if you’re building out an actual IVR before you hangup on the person.

So now when someone hits 1001 or 1002, it plays the message and hangs-up.

The order won’t make any difference. The most explicit match will be used if all appear in the same context.

I’m afraid I don’t really understand what the OP is trying to do, and what they mean by side extension. They are further confusing the issue by calling SIP endpoints “extensions”.

The OP needs to explain what they are trying to achieve, not how, and to make it clear who is expected to hear the recordings.

Hi Man,
Thanks for your time.
So basically in this scenario only thing which is happening is this main extension (1000) will call other extensions (1001, 1002, etc.)
Imagine that I am the one with main extension (1000) and you are the one using side one (1001)
I want to make a call to your extension and once you answer, I want an announcement to be played for you (For instance i want to let you know that your account balance is going to be finished soon or something like that) and after finishing the announcement, it will get disconnected.
I have tried your config but it is still not working. i mean the same thing as before is happening. Once i am calling from 1000 to 1001 instead of a hearing the announcement on 1001 side, we can here each other.
and about your other question i must say that I have to use only SIP and not the PJSIP

Side extension is not a term that I recognize. Also you are not describing your goal, only the way you think you can achieve it. If we understood the purpose of your unusual requirement, we could give better advice.

In your original dialplan, the _1XXX extension will never be used as 1001, and 1002 are more specific, so will match, in preference.

I suspect you want the U option on Dial, set to return a status to abort the call, or to use Originate.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.