官术网_书友最值得收藏!

  • FreeSWITCH Cookbook
  • Anthony Minessale Darren Schreiber Michael S Collins Raymond Chandler
  • 472字
  • 2021-08-20 15:44:34

Incoming DID calls

Phone calls coming in from the Public Switched Telephone Network (PSTN) are often called DID calls. DID stands for Direct Inward Dialing. DID numbers are delivered by your telephone service provider. They can be delivered over VoIP connections (such as a SIP trunk) or via traditional telephone circuits like PRI lines. These phone numbers are sometimes called "DID numbers" or "external phone numbers".

Getting ready

Routing a call requires two pieces of information—the phone number being routed and a destination for that phone number. In our example, we will use a DID number of 8005551212. Our destination will be user 1000. Replace these sample numbers with the appropriate values for your setup.

How to do it...

Follow these steps:

  1. Create a new file in conf/dialplan/public/ named 01_DID.xml. Add this text:
    <include>
      <extension name="public_did">
        <condition field="destination_number"expression="^(8005551212)$">
          <action application="set" data="domain_name=$${domain}"/>
          <action application="transfer" data="1000 XML default"/>
        </condition>
      </extension>
    </include>
  2. Save the file and then execute reloadxml from the fs_cli.

How it works...

All calls that come in to the FreeSWITCH server from outside (as well as internal calls that are not authenticated) are initially handled in the public dialplan context (dialplan contexts were discussed in more detail in this chapter's introduction). Once the call hits the public context, we try to match the destination_number field. The destination_number is generally the DID number (see the There's more section below for some caveats). Once we match the incoming number, we then set the domain_name channel variable to the default domain value and then transfer the call to user 1000 (FreeSWITCH is domain-based in a way similar to e-mail.

Most systems have only a single domain, although FreeSWITCH supports multiple domains. See the FreeSWITCH wiki for explicit information on multiple domain configuration). The actual transfer happens with this dialplan entry:

<action application="transfer" data="1000 XML default"/>

In plain language, this tells FreeSWITCH to transfer the call to extension 1000 in the XML dialplan and the default context. The default context contains the Local_Extension, which handles calls to users' telephones.

There's more...

Keep in mind the match in destination_number must match what the provider sends to FreeSWITCH, not necessarily what the calling party actually dialed. In North America, there are providers that send DID information in various formats such as:

  • 8005551212
  • 18005551212
  • +18005551212

The expression must match what the provider sends. One way to accomplish this is to have a few optional characters in the pattern. This pattern matches all three formats listed above:

<condition field="destination_number" expression="^\+?1?(8005551212)$">

The value \+? means optionally match a literal + character and the value 1? means "optionally match a literal digit 1". Now our pattern will match all three formats that are commonly used in North America (technically, our pattern will also match +8005551212, but we are not concerned about that. However, the pedantic admin might be, so he or she can use the pattern ^(\+1)?1?(8005551212)$ instead).

See also

  • The Configuring a SIP gateway section in Chapter 2, Connecting Telephones and Service Providers
主站蜘蛛池模板: 凭祥市| 曲周县| 苏尼特左旗| 木兰县| 湖南省| 罗定市| 枞阳县| 德格县| 亳州市| 扬中市| 石林| 额尔古纳市| 黄浦区| 石渠县| 阿勒泰市| 加查县| 道孚县| 晴隆县| 化州市| 邯郸县| 华亭县| 宜丰县| 盐城市| 西宁市| 台南市| 张家界市| 北辰区| 牡丹江市| 云和县| 雅安市| 葫芦岛市| 余江县| 石狮市| 吴川市| 公主岭市| 湘阴县| 西和县| 本溪| 阿合奇县| 浠水县| 安达市|