Contact Mapping

From FreeSWITCH Wiki
Jump to: navigation, search

Contact Mapping

There are many times when you would like to have a username which is very different from the contact information for reaching that user. For instance maybe you want each device to register with mac-address_line-number (000e081c4f6a_1) and they will have a standard npa-nxx number which routes to them (509.123.4567).

There are a couple things that you will need, first the directory:

Your friend here is going to be sip-force-user which is a variable. Set this to the number you want the user to be mapped to, here is an example:

<include>
  <user id="000e081c4f6a_1" mailbox="5091234567">
    <params>
      <param name="password" value="1234"/>
    </params>
    <variables>
      <variable name="user_context" value="default"/>
      <variable name="sip-force-user" value="5091234567"/>
    </variables>
  </user>
</include>

Next you will need to want to catch a number and send the call to this user:

You have to use sofia or sofia_contact here. user will not work because of the sip-force-user, not exactly sure why but ya. Here is an example:

<extension name="Call_User">
   <condition field="destination_number" expression="^(\d+)$">
     <action application="set" data="call_timeout=20"/>
     <action application="set" data="hangup_after_bridge=true"/>
     <action application="set" data="continue_on_fail=true"/>
     <action application="bridge" data="${sofia_contact($1@$${domain})}"/>
     <action application="answer"/>
     <action application="set" data="vm_exten=$1" />
     <action application="sleep" data="1000"/>
     <action application="voicemail" data="default ${domain_name} $1"/>
   </condition>
</extension>

A word of caution. Depending on how you route calls here, this will match all numbers and try to send them to sip-force-users listed in your directory.

There is an alternative method to contact mapping described here: XML_User_Directory_Guide#Alphanumeric_to_numeric_user_mapping