[Freeswitch-users] [Condition AND Problem]
Aqs Younas
aqsyounas at gmail.com
Tue Sep 22 00:33:55 MSD 2015
Hi, Bilal
Actually freeswitch does dialplan execution in 2 stages. During first stage
in a context it evaluates all conditions and in second stage it execute
actions according to conditions evaluated during first step. So, in you
case first conditions set(True) and second conditions set(Fail because
action in first condition is yet to performed) are check simultaneously
during first phase.
So, if you are querying some database. You need to do this in following
ways.
<context name="default">
<extension name="ASDF" continue="true">
<condition>
<action application="set"
data="effective_caller_id_number=2"/>
<action application="log" data="CRIT This is Caller_ID_NUM
${effective_caller_id_number}"/>
<action application="transfer" data="
${effective_caller_id_number} XML block" />
</condition>
</extension>
</context>
<context name="block">
<extension name="testing" continue="true">
<condition field="${effective_caller_id_number}"
expression="2">
<action application="log" data="CRIT This is Caller_ID_NUM
${effective_caller_id_number}"/>
<action application="hangup"/>
<anti-action application="set"
data="hangup_after_bridge=true"/>
<anti-action application="set"
data="continue_on_fail=true"/>
<anti-action application="set" data="bypass_media=true"/>
<anti-action application="log" data="CRIT Caller_ID_NUM
${effective_caller_id_number}"/>
<anti-action application="bridge" data="sofia/external/$
1 at 10.100.0.60"/>
</condition>
</extension>
</context>
Hope this helps. Feel free to contact me if you face any problem :)
https://wiki.freeswitch.org/wiki/Mod_blacklist
On 21 September 2015 at 17:59, Bilal Abbasi <bilaln018 at gmail.com> wrote:
> Thanks Ayre,
> Actually i am making a system to block few caller_id_numbers(its long
> story, even its not like what i said..:-P), i will pick that number form
> the database(to make that simple i have assigned 2), now as you said making
> variable inline, yes its working on the condition level, and every thing
> works GREAT, but when i print the logs it shows the old value of caller
> id(it seems its not set value executing the log,
> I am not picking up the way FS behaves.
>
> Regards
> Bilal Abbasi
>
> On Mon, Sep 21, 2015 at 5:22 PM, Steven Ayre <steveayre at gmail.com> wrote:
>
>> Ok, so that part should pass then.
>>
>> Out of curiousity why do you want to set effective_caller_id_number and
>> then test if it's the value you just set - with inline that should always
>> be true, so it doesn't give any advantage over just a single condition on
>> destination_number.
>>
>> Without inline="true" when setting effective_caller_id_number=2 it'll
>> never work, unless effective_caller_id_number was already 2. FreeSWITCH
>> evaluates the conditions (hunting stage) to generate a list of actions to
>> execute, then executes that list (execution stage), meaning the 3rd
>> condition is evaluated before the "set" is executed despite the order they
>> appear in the dialplan, unless you use inline=true which executes the set
>> during the hunting stage as soon as it's found. Using that should work for
>> you.
>>
>>
>> On 21 September 2015 at 13:04, Bilal Abbasi <bilaln018 at gmail.com> wrote:
>>
>>> Destination number is 03131234567 and yes i know that this is not match
>>> exactly, and its not showing the condition result rather it shows the
>>> anti-action(result of condition false).
>>>
>>> Regards
>>>
>>>
>>> On Mon, Sep 21, 2015 at 4:32 PM, Steven Ayre <steveayre at gmail.com>
>>> wrote:
>>>
>>>> What's the destination_number?
>>>>
>>>> Also you probably want to test for ^2$ not 2 (exact match of "2" rather
>>>> than contains "2")
>>>>
>>>> If you look at FreeSWITCH's debug logging you'll see messages of when
>>>> it evaluates conditions - what it's testing, what it's testing for and the
>>>> PASS/FAIL result.
>>>>
>>>> On 21 September 2015 at 11:41, Bilal Abbasi <bilaln018 at gmail.com>
>>>> wrote:
>>>>
>>>>> Thanks for the comment, but this does not solved the issue..:-(
>>>>> Regards
>>>>>
>>>>>
>>>>> On Mon, Sep 21, 2015 at 3:06 PM, Sergey Safarov <s.safarov at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Try
>>>>>> <action application="set" data="effective_caller_id_number=2"
>>>>>> inline="true"/>
>>>>>>
>>>>>>
>>>>>> On Mon, Sep 21, 2015 at 12:49 PM, Bilal Abbasi <bilaln018 at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi All,
>>>>>>> I have the following as my dial plan,
>>>>>>>
>>>>>>> <extension name="ASDF" continue="true">
>>>>>>> <condition>
>>>>>>> <action application="set"
>>>>>>> data="effective_caller_id_number=2"/>
>>>>>>> <action application="log" data="CRIT This is
>>>>>>> Caller_ID_NUM ${effective_caller_id_number}"/>
>>>>>>> </condition>
>>>>>>>
>>>>>>> <condition field="destination_number"
>>>>>>> expression="(^\d{11}$|^\d{10}$)"/>
>>>>>>> <condition field="${effective_caller_id_number}"
>>>>>>> expression="2">
>>>>>>> <action application="log" data="CRIT This is
>>>>>>> Caller_ID_NUM ${effective_caller_id_number}"/>
>>>>>>> <action application="hangup"/>
>>>>>>> <anti-action application="set"
>>>>>>> data="hangup_after_bridge=true"/>
>>>>>>> <anti-action application="set"
>>>>>>> data="continue_on_fail=true"/>
>>>>>>> <anti-action application="set"
>>>>>>> data="bypass_media=true"/>
>>>>>>> <anti-action application="log" data="CRIT
>>>>>>> Caller_ID_NUM ${effective_caller_id_number}"/>
>>>>>>> <anti-action application="bridge"
>>>>>>> data="sofia/external/$1 at 10.100.0.60"/>
>>>>>>> </condition>
>>>>>>> </extension>
>>>>>>>
>>>>>>> I have changed the effective called id to 2, now what I expect is
>>>>>>> that action should be executed, but dial plan goes to the anti-action
>>>>>>> Don't know what I am missing out.
>>>>>>>
>>>>>>> Help is appropriated,
>>>>>>>
>>>>>>> Regards
>>>>>>> Bilal Abbasi
>>>>>>>
>>>>>>>
>>>>>>> _________________________________________________________________________
>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>> consulting at freeswitch.org
>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>
>>>>>>> Official FreeSWITCH Sites
>>>>>>> http://www.freeswitch.org
>>>>>>> http://confluence.freeswitch.org
>>>>>>> http://www.cluecon.com
>>>>>>>
>>>>>>> FreeSWITCH-users mailing list
>>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>>> UNSUBSCRIBE:
>>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>>> http://www.freeswitch.org
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _________________________________________________________________________
>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>> consulting at freeswitch.org
>>>>>> http://www.freeswitchsolutions.com
>>>>>>
>>>>>> Official FreeSWITCH Sites
>>>>>> http://www.freeswitch.org
>>>>>> http://confluence.freeswitch.org
>>>>>> http://www.cluecon.com
>>>>>>
>>>>>> FreeSWITCH-users mailing list
>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>> UNSUBSCRIBE:
>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>> http://www.freeswitch.org
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _________________________________________________________________________
>>>>> Professional FreeSWITCH Consulting Services:
>>>>> consulting at freeswitch.org
>>>>> http://www.freeswitchsolutions.com
>>>>>
>>>>> Official FreeSWITCH Sites
>>>>> http://www.freeswitch.org
>>>>> http://confluence.freeswitch.org
>>>>> http://www.cluecon.com
>>>>>
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:
>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>
>>>>
>>>>
>>>> _________________________________________________________________________
>>>> Professional FreeSWITCH Consulting Services:
>>>> consulting at freeswitch.org
>>>> http://www.freeswitchsolutions.com
>>>>
>>>> Official FreeSWITCH Sites
>>>> http://www.freeswitch.org
>>>> http://confluence.freeswitch.org
>>>> http://www.cluecon.com
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150922/4be412f3/attachment-0001.html
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list