Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
FreeSWITCH 1.2

You're reading from   FreeSWITCH 1.2 Whether you're an IT pro or an enthusiast, setting up your own fully-featured telephony system is an exciting challenge, made all the more realistic for beginners by this brilliant book on FreeSWITCH. A 100% practical tutorial.

Arrow left icon
Product type Paperback
Published in May 2013
Publisher Packt
ISBN-13 9781782161004
Length 428 pages
Edition 2nd Edition
Concepts
Arrow right icon
Toc

Table of Contents (24) Chapters Close

FreeSWITCH 1.2
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Architecture of FreeSWITCH 2. Building and Installation FREE CHAPTER 3. Test Driving the Example Configuration 4. SIP and the User Directory 5. Understanding the XML Dialplan 6. Using XML IVRs and Phrase Macros 7. Dialplan Scripting with Lua 8. Advanced Dialplan Concepts 9. Moving Beyond the Static XML Configuration 10. Controlling FreeSWITCH Externally 11. Web-based Call Control with mod_httapi 12. Handling NAT 13. VoIP Security 14. Advanced Features and Further Reading The FreeSWITCH Online Community Migrating from Asterisk to FreeSWITCH The History of FreeSWITCH Index

Voicemail


We now shift our attention to a feature that is available in both systems: voicemail.

Asterisk

The Asterisk dialplan application, Dial, offers the ability to add the number of seconds the phone can ring. It will wait for that amount of seconds (for example, 10) for the called party to answer and then move to the next priority. In this example we have the VoiceMail application. Please replace the /etc/asterisk/extensions.conf with this content:

[default] 
exten => _200[1-2],1,Dial(SIP/${EXTEN}, 10)
exten => _200[1-2],n,VoiceMail(${EXTEN},u)

Asterisk needs some additional configuration for the voicemail boxes. Please replace the file /etc/asterisk/voicemail.conf with:

 [general]
format = wav
attach = yes
[default]
2000 => 1234,Mr. X
2001 => 1234,Mr. Y

Now you can make a call and after approximately 10 seconds the Dial application stops calling. Asterisk increases the priority by 1 and starts the VoiceMail application for the voicemail box ${EXTEN}, and the calling party can leave a message.

FreeSWITCH

Voicemail configuration in FreeSWITCH is very different. Please replace the file /usr/local/freeswitch/conf/dialplan/default/01_New.xml with this content:

<?xml version="1.0" encoding="utf-8"?>
<include>
  <context name="default">
    <extension name="Local_Extension">
      <condition field="destination_number"
       expression="^(200[1-2])$">
        <action application="export" 
          data="dialed_extension=$1"/>
        <action application="set" data="call_timeout=10"/>
        <action application="set" 
          data="hangup_after_bridge=true"/>
        <action application="set" 
          data="continue_on_fail=true"/>
        <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}"/>
      </condition>
    </extension>
  </context>
</include>

The FreeSWITCH dialplan is a bit more complex but also gives more control. With call_timeout=10 you can set the maximum time in seconds the bridge application tries to call the other party. The setting hangup_after_bridge=true tells FreeSWITCH to hang up after a bridged call has occurred. (This is also important for when the caller goes to voicemail and hangs up.) The setting continue_on_fail=true handles the scenario when the called party is busy. After the bridge application we have the answer, which means that FreeSWITCH kind of "picks up the phone" itself. After a one second sleep (which just feels a bit more human than without it) it bridges the call to a loopback destination for the voicemail application. You can also use the voicemail application without the loopback channel; however, by using this specific syntax we allow for attended transfers into a user's voicemail box.

Accessing voicemail

Now that we've configured the system to record voicemail messages for our users, let's discuss how to access those messages. In each case, be sure to call and leave a voicemail message for a user and then follow the instructions for retrieving.

We'll create dialplans that allow us to check voicemail boxes by dialing 4000.

Asterisk

Please replace the /etc/asterisk/extensions.conf file with this content:

[default] 
exten => _200[1-2],1,Dial(SIP/${EXTEN}, 10)
exten => _200[1-2],n,VoiceMail(${EXTEN},u)
exten => 4000,1,VoiceMailMain(${CALLERID(num)})

The Asterisk application VoiceMailMain offers a gateway to a caller's personal voicemail box. The function ${CALLERID(num)} returns the number of the caller. Don't mix it up with ${EXTEN}, which is the number you are dialing and would be 4000 in this example.

FreeSWITCH

First we need to define a password for accessing the voicemail box by the owner. For simplicity we use 1234 as a password again.

Open /usr/local/freeswitch/conf/directory/default/2000.xml and locate this line:

<param name="password" value="1234"/>

Add a new param line:

<param name="password" value="1234"/>

Save the file. Repeat for /usr/local/freeswitch/conf/directory/default/2000.xml.

At this point you can dial 4000 to retrieve a message because the example FreeSWITCH dialplan already defines 4000 as the message retrieval extension. You can alternatively dial *98 to access voicemail.

Notice that the system asks you to key in both your "ID number" (that is, 2000 or 2001) as well as your password. Some people prefer to have the system assume that if you dial voicemail from a particular extension then it should attempt to log in to that extension's voicemail box. This is easily achieved. Open the file /usr/local/freeswitch/conf/dialplan/default.xml and locate this extension:

    <extension name="vmain">
      <condition field="destination_number" expression="^vmain$|^4000$|^\*98$">
        <action application="answer"/>
        <action application="sleep" data="1000"/>
        <action application="voicemail" data="check default ${domain_name}"/>
      </condition>
    </extension>

Notice the highlighted line with the voicemail application. Let's modify the arguments to the voicemail application so that it assumes the caller ID number is the voicemail box to which the caller wants access. Change the argument to this:

data="check default ${domain_name} ${caller_id_number}"

Notice that we added ${caller_id_number} to the arguments. This tells the voicemail application to assume that the caller ID number (that is, 2000 or 2001) is the voicemail box to which the caller wants access.

Save the file and then issue the reloadxml command (or press F6) from fs_cli. Dial 4000 and now the system only asks for the password.

Note

FreeSWITCH global voicemail settings are found in /usr/local/freeswitch/conf/autoload_configs/voicemail.conf.xml.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image