Question: How to play "warning" message on certain outbound destinations?

Hi,

I’d like to warn my FreePBX users when they’re dialling an expensive international fixed-line, or worse, international mobile. (This is from the UK).

I’ve put a long list of international codes as a route, with a route password - which is a great start.

However, ideally I’d like to play an explanatory message too - possibly a Misc Destination / Application / Announcement?

I’ve tried creating a new Route using “SIP/xxx” to a Misc Destination/Application but no joy. Is it possible to play a Misc Destination from a Route? Thoughts appreciated!

It would GREAT if there was a standard option to play a “route announcement” in addition to the “route password” field in FreePBX.

Thanks in advance,

Alex

1 Like

The idea would be that you’d make the destination of your route a CUSTOM trunk, then send it to a custom dialplan fragment (either a Dialplan Injection using the Dialplan Injection module, or some code in extensions-custom.conf) that would play the recording to the caller, then go to the part of the dialplan that actually connects the call. The only example I could find of anyone doing something remotely similar was in this PBX in a Flash forum post:

http://pbxinaflash.com/forum/showthread.php?t=862

While this isn’t exactly what you want to do, it may give you some ideas for how to do it. If you figure it out, please post how you did it - it might be something good to put into a How-To document.

another aproche would be to use trunk-preedial-hook and detect the trunk there and play the appropriate announcement based on the trunk

Hi,

Thanks for your suggestions … going into more depth on the custom trunk side certainly helped.

In the end I created a long list of international mobile codes, created a “route” to detect them and pass them through to a new custom trunk. A simple warning message plays saying that the call will cost around £1 a minute, so look for a cheaper alternative! (Next step may be to look autodial a discount international provider).

At the top of extensions_custom.conf I added :

[mobile-warn-custom]

exten => _X.,1,Answer
exten => _X.,2,Wait(1)
exten => _X.,n(begin),Noop(Playing announcement Expensive-Call-Warning)
exten => _X.,n,Playback(custom/International-Mobile-Warning,noanswer)
exten => _X.,2,Wait(1)
exten => _X.,n,Dial(mISDN/g:out/${EXTEN},300)

The trunk’s custom dial string is then:

Local/[email protected]

Then created a route using all these numbers … (9 for an external line etc). I may put a more readable list onto Wikipedia’s international mobile page for future reference.

The route

9|00124235.
9|00124245.
9|00124255.
9|0012687.
9|00147341.
9|0017672.
9|00201.
9|002126.
9|002162.
9|002169.
9|0021891.
9|002207.
9|002209.
9|002215.
9|002216.
9|002226.
9|002233.
9|002234.
9|002235.
9|002236.
9|002239.
9|002246.
9|002267.
9|002289.
9|002299.
9|002307.
9|002308.
9|002309.
9|0023223.
9|0023230.
9|0023233.
9|002327.
9|0023328.
9|0023480.
9|0023490.
9|0023990.
9|002402.
9|002424.
9|002425.
9|002426.
9|0024322.
9|0024378.
9|0024381.
9|0024384.
9|0024385.
9|0024386.
9|0024388.
9|0024389.
9|0024390.
9|0024394.
9|0024395.
9|0024396.
9|0024397.
9|0024398.
9|0024399.
9|002456.
9|002457.
9|002485.
9|002487.
9|002499.
9|0025008.
9|0025191.
9|002538.
9|002547.
9|0025574.
9|002567.
9|002577.
9|002588.
9|002609.
9|002613.
9|0026311.
9|0026323.
9|0026391.
9|002658.
9|002659.
9|0026658.
9|002666.
9|002677.
9|0026860.
9|002693.
9|00277.
9|00278.
9|002917.
9|0030693.
9|0030694.
9|0030697.
9|0030699.
9|00316.
9|003247.
9|003248.
9|003249.
9|00336.
9|00346.
9|0035058.
9|003519.
9|00352621.
9|00352628.
9|00352661.
9|00352668.
9|00352691.
9|00352698.
9|003538.
9|003546.
9|003548.
9|003556.
9|0035679.
9|0035699.
9|0035796.
9|0035797.
9|0035799.
9|003584.
9|0035850.
9|0035948.
9|0035987.
9|0035988.
9|0035989.
9|003620.
9|003630.
9|003670.
9|003706.
9|003725.
9|0037365.
9|0037368.
9|0037369.
9|0037376.
9|0037378.
9|0037379.
9|003749.
9|0037525.
9|0037529.
9|0037533.
9|0037544.
9|003774.
9|003776.
9|0037866.
9|0038039.
9|0038050.
9|0038063.
9|0038066.
9|0038067.
9|0038068.
9|0038097.
9|00381377.
9|003816.
9|003826.
9|003859.
9|0038761.
9|0038762.
9|0038763.
9|0038765.
9|0038970.
9|0038971.
9|0038975.
9|0038976.
9|0038977.
9|0038978.
9|0039328.
9|0039329.
9|0039333.
9|0039338.
9|0039339.
9|0039340.
9|0039347.
9|0039348.
9|0039349.
9|0039393.
9|00407.
9|004174.
9|004176.
9|004177.
9|004178.
9|004179.
9|0042060.
9|0042072.
9|0042073.
9|0042077.
9|004219.
9|004237.
9|0043650.
9|0043660.
9|0043664.
9|0043676.
9|0043680.
9|0043681.
9|0043688.
9|0043699.
9|004475.
9|004477.
9|004478.
9|004479.
9|004530.
9|004540.
9|00467.
9|00474.
9|00479.
9|004850.
9|004851.
9|004860.
9|004866.
9|004869.
9|004872.
9|004878.
9|004879.
9|004888.
9|004915.
9|004916.
9|004917.
9|0049700.
9|005016.
9|005024.
9|005025.
9|005037.
9|005043.
9|005048.
9|005049.
9|005058.
9|005063.
9|005074.
9|005075.
9|005076.
9|005077.
9|00519.
9|00521.
9|00535.
9|005415.
9|00557.
9|00558.
9|00559.
9|005698.
9|005699.
9|005731.
9|00584.
9|005917.
9|005926.
9|005938.
9|005939.
9|005959.
9|005978.
9|0059894.
9|0059896.
9|0059898.
9|0059899.
9|00601.
9|00614.
9|00628.
9|00639.
9|006420.
9|006421.
9|006424.
9|006425.
9|006427.
9|006428.
9|006429.
9|00658.
9|00659.
9|00661.
9|00669.
9|006707.
9|006738.
9|00674555.
9|0067568.
9|0067569.
9|006784.
9|006785.
9|006799.
9|0068577.
9|007300.
9|007333.
9|00770.
9|007777.
9|0079.
9|008170.
9|008180.
9|008190.
9|008210.
9|008211.
9|008216.
9|008217.
9|008218.
9|008219.
9|00849.
9|008523.
9|008526.
9|008528.
9|008529.
9|008536.
9|008559.
9|0085620.
9|008613.
9|008615.
9|0088016.
9|0088017.
9|00880181.
9|0088019.
9|008869.
9|00905.
9|009192.
9|009193.
9|009194.
9|009197.
9|009198.
9|009199.
9|009230.
9|009231.
9|009232.
9|009233.
9|009234.
9|009235.
9|009236.
9|009375.
9|00947.
9|00959.
9|009607.
9|009609.
9|009613.
9|0096170.
9|0096171.
9|009627.
9|009639.
9|009656.
9|009657.
9|009659.
9|0096650.
9|0096654.
9|0096655.
9|0096656.
9|009677.
9|00968968.
9|0097059.
9|0097150.
9|0097155.
9|009725.
9|009733.
9|009745.
9|009746.
9|0097517.
9|009769.
9|0097798.
9|00989.
9|009929.
9|009945.
9|009957.
9|009959.
9|009965.
9|009989.
9|2250.
9|2256.
9|2389.

Alex - I created a book page based on what you wrote above, giving you credit of course. Hope you don’t mind. This will hopefully help anyone else who is trying to do something similar (assuming they can find the How-To section in the first place, since there is no link to it on the main page).

Thanks for sharing your solution!

Hi - glad you found my solution of interest :slight_smile:

A couple of tweaks, I noticed 3 of the international destinations weren’t captured correctly.

9|2250.
9|2256.
9|2389.

should be …

9|002250.
9|002256.
9|002389.

Of course, the ‘9|xxxx.’ variants are only required if you use 9 for an outside line etc.

Sorry it took me a couple days to notice your previous post, but I have made the corrections.

First of all, thanks to Alex, for writing the code and to Wiseoldowl to help me find it.

I tried it and it works!

I just had an idea/humble-suggestion, I’m not sure how to implement as I’m no coder.

How about changing the last line, instead of sending it to the corresponding trunk, have it mimic a failing trunk.

This way, if you have several trunks, say, SIP providers, ZAP, isdn, etc, you don’t need to build macro one for each. Having it fail will send it to the next trunk in the trunk sequence, which will be the original trunk that was used.

I don’t know If I explained myself, I’m over caffeinated and my English is rusty.

Example of original outbound route
Trunk Sequence
0 SIP/VoipProvider
1 ________

Example of outbound modded to play msg
Trunk Sequence
0 Local/[email protected]
1 SIP/VoipProvider

on the second example the last line of [mobile-warn-custom] will send some sort of error as a failing trunk to force the next trunk on the sequence, then connect the call.

But… what to put there?
Comments, ideas, test lines, all appreciated
thanks

Alejandro Gidi.

Actually, I have found that in a context called from a Custom Trunk, if the call isn’t answered or sent anywhere it runs out and then falls thru to the next trunk. So try this:

[mobile-warn-custom]

exten => _X.,1,Noop(Playing announcement Expensive-Call-Warning)
exten => _X.,n,Playback(custom/International-Mobile-Warning,noanswer)

Make sure there’s nothing beyond that line other than perhaps the start of another context. You can add waits (as in the original) but I really don’t think they are needed, but if you want one or more make sure they are below the Noop line.

Then do it as you have suggested, calling the custom trunk first in the sequence - I am pretty sure it will play the recording and then go on to the next trunk. Let us know if it works.

oddly it does not, I tried placing a non existing sip trunk name, and I tried your theory,
it plays the recording and then just drops/closes the call

This is the CLI dump with your theory, it seems it needs to fill some variable as a failing trunk. Some how it does not fall thru other trunks, just stops.

CLI Dump:
– Executing [[email protected]:28] Dial(“SIP/202-08ab2c98”, “Local/[email protected]|300|”) in new stack
– Called [email protected]
– Executing [[email protected]:1] Answer(“Local/[email protected],2”, “”) in new stack
– Executing [[email protected]:2] Wait(“Local/[email protected],2”, “1”) in new stack
– Local/[email protected],1 answered SIP/202-08ab2c98
– Executing [[email protected]:3] NoOp(“Local/[email protected],2”, “Playing announcement Expensive-Call-Warning”) in new stack
– Executing [[email protected]:4] Playback(“Local/[email protected],2”, “SaldoPendienteMujer|noanswer”) in new stack
– <Local/[email protected],2> Playing ‘Outboundmsg’ (language ‘es’)
– Remote UNIX connection
– Remote UNIX connection disconnected
– Executing [[email protected]:5] Wait(“Local/[email protected],2”, “1”) in new stack
== Auto fallthrough, channel ‘Local/[email protected],2’ status is ‘UNKNOWN’
== Spawn extension (macro-dialout-trunk, s, 28) exited non-zero on ‘SIP/202-08ab2c98’ in macro ‘dialout-trunk’
== Spawn extension (macro-dialout-trunk, s, 28) exited non-zero on ‘SIP/202-08ab2c98’
– Executing [[email protected]:1] Macro(“SIP/202-08ab2c98”, “hangupcall|”) in new stack
– Executing [[email protected]:1] ResetCDR(“SIP/202-08ab2c98”, “w”) in new stack
– Executing [[email protected]:2] NoCDR(“SIP/202-08ab2c98”, “”) in new stack
– Executing [[email protected]:3] GotoIf(“SIP/202-08ab2c98”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,6)
– Executing [[email protected]ll:6] GotoIf(“SIP/202-08ab2c98”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [[email protected]:9] GotoIf(“SIP/202-08ab2c98”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,11)
– Executing [[email protected]:11] Hangup(“SIP/202-08ab2c98”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘SIP/202-08ab2c98’ in macro ‘hangupcall’
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘SIP/202-08ab2c98’
== End MixMonitor Recording SIP/202-08ab2c98

I’ll be more than glad to test other theories. :slight_smile:
thanks for the prompt reply.

Looks like you were trying to something similar to this:-

http://pbxinaflash.com/forum/showthread.php?t=2671

It worked for me!

Hope it helps

Matthew

I have got it working by using a dial plan injection which is great because it records everything right there in FreePbx rather than having to worry with the config files. On the custom trunk use a dial string like this:

Local/[email protected]

and put similar code to this in the box on the injection commands:

Answer
NoOp(Playing Progress Announcement)
Playback(pls-hold-while-try,noanswer)
Dial(SIP/5550003/${EXTEN},300,r)

The reason for doing this was that I am using a Portech SIP-GSM gateway and the because of delay in the mobile network mobile calls take a while to setup (about two rings) so I give an announcement followed by ring tone to get rid of the period of silence I was getting during the setup.The only trouble with this is if the called mobile returns a busy you get ring followed by busy. I have also tried replacing the r in the last line with m which gives music while waiting. I am debating which way to go at the moment.

As an aside I have also used an injection to strip +1 from the front of CID’s, will share that if anyone is interested.

Hi, I’ll give the injection module a try.

I’m interested in replacing your last line, with something that will make that custom trunk fail on purpose, with the correct error, so if falls down to other trunks.

So far I have been able to make it fail UNKNOWN and it hangs up .

The reason for this interest is, this way we don’t need to make a macro or injection for each trunk. Just place it as trunk1 on the outbound rule, have it fail and automatically will go to option trunk2.

I’m using this code, but I’m not coder, I just try to copy/paste parts:
[mobile-warn-custom]

exten => _X.,1,Answer
exten => _X.,n,Wait(1)
exten => _X.,n(begin),Noop(Playing announcement Expensive-Call-Warning)
exten => _X.,n,Playback(PleasebeBriefonThiscall,noanswer)
exten => _X.,n,Goto(macro-dialout-trunk,s-CONGESTION,1)
exten => _X.,n,Noop(end the macro)

This will give no real reason for the fail and hangs up.
Any suggestions on how to have it fail with a propper congestion error, so it falls to other trunks?

thanks!

You could try this: Instead of Goto(macro-dialout-trunk,s-CONGESTION,1) try Goto(app-blackhole,congestion,1) - however I think going to congestion is not what you really want to do because that effectively ends the call. If you have read the page How to give a particular extension different or restricted trunk access for outgoing calls, you may note that in the case of no call restriction a simple Noop is executed, and then the context runs out. You will also note that congestion is what is used when you want the call to end!

I’ve been using that technique for giving a particular extension restricted access on my system for at least three or four months now and it works quite well, so I feel pretty confident in saying that congestion is exactly what you DON’T want to use - even if that sounds counter-intuitive. Try a simple NoOp at the very end of the context (in other words, lose the GoTo) and see if that doesn’t work for you.

I have overcome the problem by setting up four single channel custom trunks called in order by an outbound route. Each of these trunks call their own separate injection, each injection then points the call to a different trunk that I already have set up.

I needed to use separate SIP trunks for each channel because that is the way the Portech gateway works. If you are using multiple channel SIP trunks I guess you only need one custom trunk, one injection and one SIP trunk, setting the maximum channels on both the custom and SIP trunks to the same number. With Zap trunks I guess you will need to deal with each one separately as I have done with the SIP trunks.

This is rather ungainly but it does work and required very little effort to set it up, mainly because the dial plan injection module is so practical and easy to use.

I would be interested to hear if you can come up with a more elegant solution.

I re-read this thread and saw lazytt’s comment ref pre-dial-hook. After a bit of searching I found the macro resides in extensions.conf and is called from macro-dialout-trunk which resides in extensions-additional.conf. I coded it like this:

[macro-dialout-trunk-predial-hook]
; this macro intentially left blank so it may be safely overwritten for any custom
; requirements that an installation may have.
;
; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
; if set to “BYPASS” then this trunk will be skipped
;
exten => s,1,NoOp(Trunk ${OUT_${DIAL_TRUNK}} selected)
exten => s,n,Gotoif($["${OUT_${DIAL_TRUNK}:0:7}" != “SIP/700”]?skip)
exten => s,n,NoOp(Playing Progress Announcement)
exten => s,n,Playback(pls-hold-while-try,noanswer)
exten => s,n(skip),MacroExit()

; This macro is for dev purposes and just dumps channel/app variables. Useful when designing new contexts.

The SIP trunks I want to play the message are 7000, 7001, 7002 and 7003, hence the Gotoif to stop the message being played on other trunks.

This way I was able to insert the message without using the custom trunk. I just setup a normal outbound route with the four trunks I wanted to use.

If you only wanted this to happen with certain numbers I think you could use pattern matches instead of the Gotoif. Have not got deep enough into dial plans yet to work out exactly how.

Hi I would like to do something similar.
I initiate a call over click-to-dial aplication…asterisk calls my extension and when i pickup then the real call is made.
Now I would like to make an anouncement when the phone is picked up - something like "You are calling this number, if u are sure to call press 1, otherwise hangup.

I understand that i have to copy the entire [macro-dialout-trunk] section to extensions_custom.conf to override the default behaviour and inject that anouncement.

  1. I don’t know where exactly to inject
  2. I would like to do this only when calls come form click-to-dial aplication (specific user in manager.conf) and not on every call made (so it can’t be based on an outbound route).

Any help would be great.

Thank you.

Thanks for hard work putting in.
My question is Is there a simpler solution?
for example just add [outrt-7-custom] and play warning for this route which is set for all/any other numbers dialled?
something like this
[outrt-7-custom]
exten => _X.,1,Answer
exten => _X.,2,Wait(1)
exten => _X.,n(begin),Noop(Playing Progress Announcement)
exten => _X.,n,Playback(pls-hold-while-try,noanswer)

Hello, how would I make the message play on all outbound calls. Thanks