How does freeswitch play voice prompts when a call fails?

Source: Internet
Author: User
Tags freeswitch

Many netizens asked this question. Generally, when we call, we will hear that "your phone number is in the process of making a call. Please try again later .... ", or" no answer by phone... we can also do this in freeswitch.

In fact, it is very simple. The default configuration will be transferred to voicemail (voice mailbox) when the call fails. We only need to modify it here to let him play a voice prompt, then go to the voice mailbox (or directly disconnect ).

Find the last few lines in the <extension name = "local_extension"> section.

 
<Action application = "bridge" Data = "User/$ {dialed_extension }@$ {domain_name}"/> <action application = "Answer"/> <action application = "sleep" data = "1000"/> <action application = "bridge" Data = "loopback/APP = VOICEMAIL: default $ {domain_name }$ {dialed_extension} "/>

The first bridge indicates that the called number is called. If the call fails, dialplan continues.

    • Response
    • Sleep
    • Enter voicemail

OK. We only need to change the last bridge line

 
<Action application = "playback" Data = "${inate_disposition).wav"/>

Try again. If the call is busy, the originate_disposition variable is user_busy. If the user is not registered, it is user_not_registered, you only need to ensure that there is a sound file in the relevant directory (if the log shows that the sound file cannot be found, try recording it yourself ).

Of course, there may be many reasons for the call failure. You cannot record all the audio files, right? There are two ways:

1) Use a Lua (or other language) script

 
<Action appliction = "Lua" Data = "/tmp/xxx. Lua"/>

In the Lua script, you can get the originate_disposition variable, so that you can use logic like if then else to play a variety of audio files.

2) Of course, if you do not want to edit the script, the dialplan function of freeswitch is very powerful. You only need to switch the call to the dialplan for playing different audio files:

 
<Action application = "transfer" Data = "Play-cause-$ {originate_disposition}"/>

Then create the following dialplan extension:

 

 
<Condition field = "destination_number" expression = "^ play-cause-USER_BUSY $"> <action application = "playback" "/tmp/sounds/user-busy.wav"/> </condition>

 

 

 
<Condition field = "destination_number" expression = "^ play-cause-USER_NOT_REGISTERED $"> <action application = "playback" "/tmp/sounds/user-not-registered.wav"/> </condition>

 

 

 
<Condition field = "destination_number" expression = "^ play-cause0 (. *) $"> <! -- For all other reasons, play this file --> <action application = "log" Data = "Warning hangup cause: $1 "/> <action application =" playback ""/tmp/sounds/unknown-error.wav "/> </condition>

 

Summary:

Of course, there is another premise for playing the above audio files, that is, there must be the following two lines before the first bridge:

 
<Action application = "set" Data = "hangup_after_bridge = true"/> <action application = "set" Data = "continue_on_fail = true"/>

The role of the first line is that if the first bridge is successful, we do not need to play the sound again after the call is called and hung up, so we can directly log on to the server. Of course, this line does not exist. If you find that the value is "normal_clearing" in originate_disposition, you can determine whether to play the relevant voice.

The role of the second line is to continue if the call fails (empty number, reject, etc.); otherwise (if the value is false) the next line will be suspended. The value of this variable can also include the following types, indicating that only the voice is played in these cases, and other variables are directly mounted.

 
<Action application = "set" Data = "continue_on_fail = normal_temporary_failure, user_busy, no_answer, timeout, no_route_destination"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.