Nice solution Eric, thanks. Very elegant.<br><br><div><span class="gmail_quote">On 6/27/07, <b class="gmail_sendername">Eric ManxPower Wieling</b> &lt;<a href="mailto:eric@fnords.org">eric@fnords.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Matthew Brothers wrote:<br>&gt;&gt; Hi,<br>&gt;&gt;<br>&gt;&gt; I have been looking for an example of accomplishing this, but<br>&gt;&gt; I&#39;ve been unable to locate something similar to what I&#39;m trying<br>&gt;&gt; to do.
<br>&gt;&gt;<br>&gt;&gt; Here&#39;s the scenario:<br>&gt;&gt;<br>&gt;&gt; Users caller ID is set to their internal extension (200-250).<br>&gt;&gt; This is set in sip.conf for each user. Each user has a local DID<br>&gt;&gt; as well (hosted through Vitelity, for example (555)111-2222). The
<br>&gt;&gt;&nbsp;&nbsp;problem is that this extension was being passed to the outside<br>&gt;&gt; world. I currently have a SetCallerID command changing the<br>&gt;&gt; CallerID to our main office number, but some users want their DID
<br>&gt;&gt;&nbsp;&nbsp;sent, not the general number.<br>&gt;&gt;<br>&gt;&gt; The problem is that if their caller ID is set to their DID, when<br>&gt;&gt; users hit redial on their phones internally they dial out and<br>&gt;&gt; back in. I corrected this by putting each DID in 
extensions.conf<br>&gt;&gt; under their three digit extension, but that seems a bit like a<br>&gt;&gt; kludge obviously.<br>&gt;&gt;<br>&gt;&gt; I&#39;m looking for a method of sending the internal three digit<br>&gt;&gt; extension only when a user is dialing another user internally,
<br>&gt;&gt; otherwise it will send their DID. Is their a method to do this in<br>&gt;&gt;&nbsp;&nbsp;the dial plan? Anyone have an example of how to accomplish this?<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Thanks in advance.<br>&gt;<br>
&gt;<br>&gt; Mike,<br>&gt;<br>&gt; I have a similar setup (I even use Vitel) and the easiest and<br>&gt; cleanest method that I have found to accomplish this is with the<br>&gt; AstDB. You can simply create a cross-reference of DIDs and Internal
<br>&gt; extensions similar to extdid/200 =&gt; 5551112222 ... extdid/250 =&gt;<br>&gt; 5551112272 in the AstDB. Then you can change your outgoing dialplan<br>&gt; to change the caller id based upon this cross reference. Example:
<br>&gt;<br>&gt;<br>&gt; exten =&gt; NXXNXXXXXX,n,Set(outgoingCID=&lt;MAINNUMBER&gt;)<br>&gt;<br>&gt; exten =&gt; NXXNXXXXXX,n,<br>&gt; GotoIf($[ ${DB_EXISTS(extdid/${CALLERID(num)})} = 0 ]?makecall)<br>&gt;<br>&gt; exten =&gt; NXXNXXXXXX,n,
<br>&gt; Set(outgoingCID=${DB(extdid/${CALLERID(num)})})<br>&gt;<br>&gt; exten =&gt; NXXNXXXXXX,n(makecall),Set(CALLERID(num)=${outgoingCID})<br>&gt;<br>&gt; ...<br>&gt;<br>&gt; You could even simplify your incoming context by cross-referencing
<br>&gt; in the other direction. That is didext/5551112222 =&gt; 200 ...<br>&gt; didext/5551112272 =&gt; 250.<br>&gt;<br>&gt; exten =&gt; NXXNXXXXXX,n,<br>&gt; Goto(internal-extensions,${DB(didext/${EXTEN})},1)<br>&gt;<br>
&gt; OR you could do something similar with LOCAL channels or with a Dial<br>&gt; command.<br><br>Here is my solution.&nbsp;&nbsp;I&#39;ve stripped out most of the unimportant stuff.<br><br>Because our carrier charges for PICs on a per-DID basis, we set the
<br>Caller*ID number for long distance calls to be the main number,<br>regardless of what the person&#39;s DID is.&nbsp;&nbsp; It also allows use of more<br>than one main number, depending on the device making the call.<br><br>The macro-dial-result is not important for this.&nbsp;&nbsp;It is a macro we use
<br>to figure out what happened to the call based on HANGUPCAUSE and what,<br>if any tone or message to send the caller, as well as decide if the call<br>failed and should be sent out a different route.<br><br>In sip.conf
 set up the device like this:<br><br>[0004f201e570-a]<br>callerid=Room, Computer &lt;3726&gt;<br>setvar=DID=9852463726<br>setvar=BTN=9858982022<br>accountcode=3726<br>type=friend<br>host=dynamic<br>secret=Shhhh<br>context=toll-access
<br><br>My extensions.conf looks like this:<br><br>[toll-access]<br>;<br>; 9-1-nxx-nxx-xxxx<br>exten =&gt; _91NXXNXXXXXX,1,Set(USE_BTN=yes)<br>exten =&gt; _91NXXNXXXXXX,n,Gosub(outgoing-call-fixup,${EXTEN},1)<br>exten =&gt; _91NXXNXXXXXX,n,Dial(${PSTN}/${EXTEN:1},,g)
<br>exten =&gt; _91NXXNXXXXXX,n,Macro(dial-result,SIP/${EXTEN}@pinhook)<br>;<br>; 9-1-985-nxx-xxxx<br>exten =&gt; _91985NXXXXXX,1,Gosub(outgoing-call-fixup,${EXTEN},1)<br>exten =&gt; _91985NXXXXXX,n,Dial(${PSTN}/${EXTEN:1},,g)
<br>exten =&gt; _91985NXXXXXX,n,Macro(dial-result,SIP/${EXTEN}@pinhook)<br><br>[outgoing-call-fixup]<br>;<br>exten =&gt; _X.,1,GotoIf($[${LEN(${CALLERID(num)})} != 10]?check-btn)<br>exten =&gt; _X.,n,Return<br>exten =&gt; _X.,n(check-btn),GotoIf($[&quot;${USE_BTN}&quot; = &quot;yes&quot;]?set-btn)
<br>exten =&gt; _X.,n,Set(CALLERID(num)=${DID})<br>exten =&gt; _X.,n,Return<br>exten =&gt; _X.,n(set-btn),Set(CALLERID(num)=${BTN})<br>exten =&gt; _X.,n,Return<br><br>_______________________________________________<br>--Bandwidth and Colocation Provided by 
<a href="http://www.api-digital.com--">http://www.api-digital.com--</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br>&nbsp;&nbsp; <a href="http://lists.digium.com/mailman/listinfo/asterisk-users">
http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br>