Play an audio message when I pick up the phone's handset [SOLVED]

I would like to be able to play a message every time an extension raises the phone’s handset

Can you be more specific?
Do you want it to play the message when someone is answering a call?
When they are making an outbound call?
What message are you going to play?

The questions will help others get you the best answer.

Yes, I’m sorry … my English is not good …

I try to be simple

I should give a message every time an extension prepares to make a phone call I hope it’s clearer Thank you

Only the phone itself can do that, Asterisk is not involved until the phone completes its self defined ‘dial’ .

2 Likes

… unless your channel driver supports it. Chan_SIP and PJ_SIP definitely can’t do this, but other (stupider) channel drivers (like DAHDI and Chan-SCCP-B) can actually interact with the phone once it goes off-hook. Of course, both of these drivers rely on the phone to be as dumb as a bag of hammers, so it’s going to depend.

If you were willing to wait until after the call is dialed, then you could probably implement something that would work across the spectrum, but for most people - @dicko absolutely has the right answer.

BIG NOTE: I would not recommend abandoning working SIP phones to adopt any 20-year-old technology so that you can get something like this working.

1 Like

And if I’m content to give a message just before the call starts …
That is, the person dials the number and before the call starts from the message?
So maybe it is possible?

Look at the various “predial hooks” depending on the destination

grep -r predial /etc/asterisk/*|grep “[”

will enumerate the possibilities , if you want to do that only for external calls use macro-dialout-trunk-predial-hook
maybe it looks like:-

[macro-dialout-trunk-predial-hook]
exten => s,1,Playback(custom/yourfile)
exten => s,n,MacroExit()

but probably, and second guessing you, you might need to add a "conditional’ to do what you want.

1 Like

The only way that jumps out at me is to configure the phone as a ‘hotline’ - eg, it immediately dials ‘1234’. Then you set up 1234 to play the announcement, and then jump to DISA, so they user can then dial out. However, you won’t be able to use any phone functionality such as ‘redial’, because the dialing won’t be handled by the phone.

2 Likes

Nice @xrobau, if the announcement is informative, use my solution, if conditional use Rob’s if the phone supports “ringdown/hotline” but that’s again a “phone thing”, you can’t make that happen with Asterisk.

What do you say is possible to add a line in the configuration in the outbound route …
And play an audio track …?

[outrt-3] ; Ufficio
include => outrt-3-custom
exten => _.*,1,Macro(user-callerid,LIMIT,EXTERNAL,)

exten => _.*,n,Playback(custom/msg-cv-ergosol-2015)

so, however, it does not work …

your example interests me a lot

here is my route out “I do not know how to implement can you give me a suggestion?”:

[outrt-3]; Office
include => outrt-3-custom
exten => _. *, 1, Macro (user-callerid, LIMIT, EXTERNAL,)

exten => _. * / 018258 …, 1, Macro (user-callerid, LIMIT, EXTERNAL,)
exten => _. * / 018258 …, n, Gosub (sub-record-check, s, 1 (out, $ {EXTEN}, yes))
exten => _. * / 018258 …, n, Set (MOHCLASS = $ {IF ($ ["$ {MOHCLASS}" = “”]? default: $ {MOHCLASS})})
exten => _. * / 018258 …, n, Set (_NODEST =)
exten => _. * / 018258 …, n, Macro (dialout-trunk, 4, $ {EXTEN} , off)
exten => _. * / 018258 …, n, Macro (outisbusy,)

exten => _. * / _ 1X, 1, Macro (user-callerid, LIMIT, EXTERNAL,)
exten => _. * / _ 1X, n, Gosub (sub-record-check, s, 1 (out, $ {EXTEN}, yes))
exten => _. * / _ 1X, n, Set (MOHCLASS = $ {IF ($ ["$ {MOHCLASS}" = “”]? default: $ {MOHCLASS})})
exten => _. * / _ 1X, n, Set (_NODEST =)
exten => _. * / _ 1X, n, Macro (dialout-trunk, 4, $ {EXTEN} , off)
exten => _. * / _ 1X, n, Macro (outisbusy,)

exten => _00. *, 1, Macro (user-callerid, LIMIT, EXTERNAL,)

exten => _00. * / _ 1X, 1, Macro (user-callerid, LIMIT, EXTERNAL,)
exten => _00. * / _ 1X, n, Gosub (sub-record-check, s, 1 (out, $ {EXTEN}, yes))
exten => _00. * / _ 1X, n, Set (MOHCLASS = $ {IF ($ ["$ {MOHCLASS}" = “”]? default: $ {MOHCLASS})})
exten => _00. * / _ 1X, n, Set (_NODEST =)
exten => _00. * / _ 1X, n, Macro (dialout-trunk, 4, ** 347596 * $ {EXTEN} , off)
exten => _00. * / _ 1X, n, Macro (outisbusy,)

Read the first few lines of that file.

Thanks to everyone in particular to Dicko

With its indications it was sufficient to edit the file /etc/asterisk/extensions.conf

Then find the macro [macro-dialout-trunk-predial-hook]

Insert a Playback and now when I take the line it warns me with the message I want, I would say perfect

here is an example

[Macro-dialout-trunk-predial-hook]
exten => s, 1, Playback (custom /we-apologize-for-wait)
exten => s, 1, MacroExit ()

obviously restarted …: rasterisk -x “core reload”

Hello to all

That file is overwritten by FreePBX and should not be modified by the user.

Your macro should be placed in /etc/asterisk/extensions_custom.conf – see warning in extensions.conf at the beginning.

You will never get to macroexit, (s,n or s,2) but it works because the context falls though, the macroexit is just good form it is also good form to put that context n extensions_custom.conf , although freepbx doesn’t ever actually write to extensions.conf, it might one day.

Doesn’t it get written when you upgrade?

Yes possibly just not on day to day reloads, so the op might well not ever notice it, until its gone.That need for usinf that location is fully documented in that context in extensions.conf

extensions.conf is a symlink to a corresponding file in the core module directory. It should get written on every core install/upgrade.

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