Dialplan action based on callerid number?

mdoupe

New Member
Mar 21, 2023
28
0
1
44
Hi all,

Hopefully an easy question. :)

I am trying to make an operator dialplan that sends to different operators based on the extension that is dialing 0. I've made a simple test dialplan to send two extensions to each other when they dial 0. the first one (3333 > 3334) works, but the second does not try to match. I assume it is because I'm not quite understanding how dialplan flow works. :)

Code:
    <extension name="operator-new" continue="false" uuid="53fa7641-b806-4a8d-bede-a5d8e0c7f05f">
        <condition field="destination_number" expression="^0$"/>
        <condition field="caller_id_number" expression="^3333$">
            <action application="transfer" data="3334 XML fusionpbx.example.com"/>
        </condition>
        <condition field="caller_id_number" expression="^3334$">
            <action application="transfer" data="3333 XML fusionpbx.example.com"/>
        </condition>
    </extension>

Any help would be appreciated!
 
I think I've figured it out. I added "break="on-true"" to all of the caller_id_number conditions so if one is false it doesn't stop processing the rule.
 
Aside from adding the tag, the final version is pretty much the same:

Code:
    <extension name="operator-new" continue="false" uuid="53fa7641-b806-4a8d-bede-a5d8e0c7f05f">
        <condition field="destination_number" expression="^0$"/>
        <condition field="caller_id_number" expression="^50..$" break="on-true">
            <action application="transfer" data="5000 XML fusionpbx.example.com"/>
        </condition>
        <condition field="caller_id_number" expression="^60..$" break="on-true">
            <action application="transfer" data="6000 XML fusionpbx.example.com"/>
        </condition>
    </extension>

so dialing 0 from any 5000 range extension sends you to ext 5000, and dialing 0 from any 6000 range extension sends you to ext 6000.

As a bonus, I had to figure out how to do the same thing, but pulling different amounts of digits from the dialed number for different ranges. I don't know if this is the best way to do it, but here's what I ended up with:

Code:
<extension name="thisstuff" continue="false" uuid="875551b2-6317-4a0f-9f07-749f9472cebb">
    <condition field="destination_number" expression="^#..$"/>
    <!-- site 1 -->
    <condition regex="all" break="on-true">
        <regex field="caller_id_number" expression="^50..$"/>
        <regex field="destination_number" expression="^#0(.)$"/>
        <action application="transfer" data="100${1} XML fusionpbx.example.com"/>
    </condition>
    <!-- site 2 -->
    <condition regex="all" break="on-true">
        <regex field="caller_id_number" expression="^60..$"/>
        <regex field="destination_number" expression="^#(..)$"/>
        <action application="transfer" data="20${1} XML fusionpbx.example.com"/>
    </condition>
</extension>

so dialing #01 from ext 5000 would send you to 1001, and dialing #01 from ext 6000 would send you to 2001.
 
FusionPBX has this as a built-in feature starting in version 5.2 or 5.3. It can be found in the Menu -> Dialplan -> Destinations