Call an extension that goes to a custom context

Hi guys,

Another question :smiley:

Within the extension_custom.conf file, I have placed the following context:

[call-file-test]
exten => 10,1,Answer()
exten => 10,n,Wait(1)
exten => 10,n,Playback(hello-world)
exten => 10,n,Wait(1)
exten => 10,n,Hangup()

I have then created a test.call file:
hannel: PJSIP/1000
MaxRetries: 2
RetryTime: 10
WaitTime: 3
Context: call-file-test
Extension: 10

And in the PBX gui, I have created a custom extension 10

In the cli I run:
mv /test.call /var/asterisk/spool/outgoing/

This initiates a call on extension 2000 (physically connected device) and plays the “hello-world” recording.

Is there a way for me to
A) dial this number from a phone so that it rings a group of people and plays the hello-world recording.
B) stops the group of people from hanging up until the message is played then hangs up (or, continues to ring and play until the whole message is played)

I bought the paging pro module following an earlier ticket solution, but it does not quite give me everything I need.

I know of no way to block a SIP device from terminating an active session before the other side finishes. If such a thing is even possible it would have to be a phone feature, and the call would have to have some way of triggering the feature with a custom header. Sounds like you want an overhead paging system, perhaps used in conjunction with paging to the phones.

OK great, so can you help with sending an alert out without allowing hangup?

Reread my post. AFAIK your requirement is not possible, your first job would be to disprove that claim.

Sorry, not sure if I am misunderstood…so take out the requirement to not allow hang up…
The rest is not possible in your opinion? (push out an announcement using custom contexts?)

Started on something like the following:

Add 12345 as a custom extension in the gui.

Add the following in extension_custom.conf
exten => 12345,1,Goto(pa-system,s,1)
[pa-system] exten => s,1,Answer
exten => 1,n,System(cp test.call /var/spool/asterisk/outgoing/)
exten => 0,1, Hangup()

Then, when I dial 12345 from any phone, I expected it to copy my call file (below) into outgoing to be processed
Channel: PJSIP/1000
MaxRetries: 2
RetryTime: 10
WaitTime: 3
Context: call-file-test
Extension: 10

Which processes:
[call-file-test]
exten => 10,n,Answer
exten => 10,n,Wait(1)
exten => 10,n,Playback(hello-world)
exten => 10,n,Wait(1)
exten => 10,n,Hangup()

Instead, nothing happens :frowning:

cp’ing call files into outgoing will sooner rather than later bite you in the butt

Why? I am curious because we setup a set of static calls files and set a cron job that copies from the folder to /outgoing, at specified times. These are reminder calls (calls user to remind them of a function), but they seem to be working. Do you think this approach is flawed?

Okay, can you think of a solution where I can generate the .call files when an extension is dialled so that it pushes a message out to a number of people?
Maybe copy to one folder, then move the copied file?

You can cp files that are dated in the future, if not asterisk will likely grab only some of the file that are dated (mtime or atime) before the instant of time they start appearing in ‘outgoing’ (the words used by the developers. Asterisk aggressively consumes them)

1 Like

Easy way, in your staging folder , create one file for each extension ‘touch’ them each with a random time between one second in the future and a reasonable period in that future, this eases the load on the system. Then cp them all into outgoing.

If you’re writing dialplan, there is no need to use call files unless you are attempting to schedule calls for the future. With dialplan you can just use the Originate dialplan application.

lorne14-pro*CLI> core show application Originate

  -= Info about application 'Originate' =-

[Synopsis]
Originate a call.

[Description]
This application originates an outbound call and connects it to a specified
extension or application.  This application will block until the outgoing call
fails or gets answered.  At that point, this application will exit with the
status variable set and dialplan processing will continue.
This application sets the following channel variable before exiting:
${ORIGINATE_STATUS}: This indicates the result of the call origination.
    FAILED
    SUCCESS
    BUSY
    CONGESTION
    HANGUP
    RINGING
    UNKNOWN: In practice, you should never see this value.  Please report it to
    the issue tracker if you ever see it.

[Syntax]
Originate(tech_data,type,arg1[,arg2[,arg3[,timeout]]])
1 Like

Thanks, but as per my original support request, I want to be able to send a broadcast message to a number of people.

Extension 1000 dials 999

When this is dialled it then sends a recorded message to 1001, 1002, 1003 (up to 20 extensions) then hangs up.

Please can you explain how I could do this in a dial plan when 999 is dialled? :slight_smile:

Thanks for all your help

Should read “Then ‘mv’ them…”. Using ‘cp’ copies the contents of the new file into the outgoing directory, and you can get ‘false starts’ where the file is not complete when the call file is consumed. The recommended procedure is to build the file in a directory on the same file system and ‘mv’ it into the outgoing directory. This doesn’t actually copy the text of the file, it merely changes the directory entry so that ‘extant’ file appears fully formed in the outgoing directory and you are ensured to get all of the contents of the file.

This still sounds like a paging application.

No, it doesn’t work like that because we have previously ‘touched’ them some time safely in the near future, no false starts not interim renaming, just as i said ‘cp’ them and they will still be there the next time you need them (retouched of course) Spacing them out also as twenty cals hitting the system at the same time is probably quite a shock to a small system, if the message is 20 seconds long and you are happy with 5 calls then space them out at "touch callfile.n -d “+ 4*index”

The call files (with retries) will have a much higher delivery success rate than any other solution :wink:

Something like:-

j=1;for i in 1111 2222 3333 4444 5555 6666;do echo -n " contents of callfile \nwhere $i is replaced\nas necessary\n$j\n\n"> callfile.$i;touch callfile.$i -d "+$j sec ";j=$((j + 4));done;chown asterisk:asterisk callfile*;cp callfile* /var/spool/asterisk/outgoing

If i get you right. you want to create a custom extension and sent it to extension_custom.conf.
Create your custom extension go to (advance>Custom Context) add “Local/[email protected]

Sorry got it wrong. Here’s how to do it
Create your custom extension go to (advance> Edit Extension>Dial) add “Local/[email protected]

You do not copy the files because copy doesn’t write the entire file at once just like if you were to write directly to the file in the directory. which is a no-no.

The only way you can copy files into the outgoing spool without it being triggered immediately is to change the permissions of the file so Asterisk can’t execute it until the permissions are changed.

Even over at voip-info.org the how-tos all point out that you should be doing a mv not a cp when working with these things. Asterisk auto-dial out - VoIP-Info

Even if it takes the kernel 30 minutes to copy a file but that file was dated 31 minutes in the future when the copy was started, asterisk wont do anything until that 31 minutes have passed. its just how Asterisk works.

Which is another way of stating wgat i did already in this thread

You can cp files that are dated in the future, if not asterisk will likely grab only some of the file that are dated (mtime or atime) before the instant of time they start appearing in ‘outgoing’ (the words used by the developers. Asterisk aggressively consumes them)