<extension name="froudContol" continue="true">
<condition>
<action application="set" data="nibble_account=${accountcode}"/>
<action application="nibblebill" data="flush"/>
</condition>
</extension>
I use following dialplan extension. All work fine<extension name="setNibbleBillRate" continue="true">
<condition field="${destination_number}" expression="^\+7(495|499)\d+$" break="on-true">
<action application="set" data="nibble_rate=1"/>
</condition>
<condition field="${destination_number}" expression="^\+7800\d+$" break="on-true">
<action application="set" data="nibble_rate=0"/>
</condition>
<condition field="${destination_number}" expression="^\+7\d+$" break="on-true">
<action application="set" data="nibble_rate=3"/>
</condition>
<condition field="${destination_number}" expression="^\+\d+$" break="on-true">
<action application="set" data="nibble_rate=20"/>
</condition>
<condition field="${destination_number}" expression="^[a-zA-Z0-9]+$" break="on-true">
<action application="set" data="nibble_rate=0"/>
<anti-action application="set" data="nibble_rate=200000000"/>
</condition>
</extension><extension name="froudContol" continue="true">
<condition>
<action application="nibblebill" data="flush"/></condition>
</extension>вс, 10 апр. 2016 г. в 14:22, Tanguy <phenix@vfemail.net>:Hello_________________________________________________________________________
I would like to use nibblebilling for fraud prevention on international and premium numbers ( national or emergency calls should never be blocked and should still working even if the billing database is unavailable )
Unfortunately that never hangup my calls using standard dial plan
nibblebill.conf.xml
<configuration name="nibblebill.conf" description="Nibble Billing">
<settings>
<!-- See http://wiki.freeswitch.org/wiki/Mod_nibblebill for help with these options -->
<!-- Information for connecting to your database -->
<param name="db_dsn" value="pgsql://hostaddr=127.0.0.1 dbname=xxxx user=xxxx password=xxxx"/>
<!-- The database table where your CASH column is located -->
<param name="db_table" value="accounts"/>
<!-- The column name where we store the value of the account -->
<param name="db_column_cash" value="cash"/>
<!-- The column name for the unique ID identifying the account -->
<param name="db_column_account" value="id"/>
<!-- Default heartbeat interval. Set to 'off' for no heartbeat (i.e. bill only at end of call) -->
<param name="global_heartbeat" value="20"/>
<!-- By default, warn a caller when their balance is at $5.00. You can set this to a negative number. -->
<param name="lowbal_amt" value="-100"/> <!-- i don't need this -->
<param name="lowbal_action" value="play ding"/>
<!-- By default, terminate a caller when their balance hits $0.00. You can set this to a negative number. -->
<param name="nobal_amt" value="0"/>
<param name="nobal_action" value="hangup"/>
<!-- If a call goes beyond a certain dollar amount, flag or terminate it -->
<param name="percall_max_amt" value="10"/>
<param name="percall_action" value="hangup"/>
</settings>
</configuration>
outbound route
<extension name="international" >
<condition field="destination_number" expression="^00(\d{6,20})$" >
<action application="nibblebill" data="flush"/>
<action application="set" data="nibble_account=${accountcode}"/>
<action application="set" data="nibble_rate=0.1"/>
<action application="bridge" data="sofia/gateway/gw_idt/$1" />
</condition>
</extension>
My balance
My balance is already negative
select * from accounts ;
id | cash
----------------------------------+-----------
company.voip.mydomain.com | -0.789471
A sample call
My balance already negative, the call will be billed but never blocked
Dialplan: sofia/internal/5003@company.voip.domain.com Action nibblebill(flush)
Dialplan: sofia/internal/5003@company.voip.domain.com Action set(nibble_account=${accountcode})
Dialplan: sofia/internal/5003@company.voip.domain.com Action set(nibble_rate=0.1)
EXECUTE sofia/internal/5003@company.voip.domain.com nibblebill(flush)
EXECUTE sofia/internal/5003@company.voip.domain.com set(nibble_account=company.voip.domain.com)
2016-04-10 12:10:04.049418 [DEBUG] mod_dptools.c:1477 sofia/internal/5003@company.voip.domain.com SET [nibble_account]=[company.voip.domain.com]
EXECUTE sofia/internal/5003@company.voip.domain.com set(nibble_rate=0.1)
2016-04-10 12:10:04.049418 [DEBUG] mod_dptools.c:1477 sofia/internal/5003@company.voip.domain.com SET [nibble_rate]=[0.1]
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:488 Attempting to bill at $0.1 per minute to account company.voip.domain.com
2016-04-10 12:10:52.132458 [INFO] mod_nibblebill.c:540 Beginning new billing on 644488fc-ff04-11e5-9a27-fd2791153af9
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:546 42 seconds passed since last bill time of 2016-04-10 12:10:09
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:563 Billing $0.071033 to company.voip.domain.com (Call: / 0.000000 so far)
2016-04-10 12:10:52.132458 [DEBUG] mod_nibblebill.c:393 Doing update query
2016-04-10 12:10:52.172440 [DEBUG] mod_nibblebill.c:420 Doing lookup query
[SELECT cash AS nibble_balance FROM accounts WHERE id='company.voip.domain.com']
2016-04-10 12:10:52.172440 [DEBUG] mod_nibblebill.c:428 Retrieved current balance for account company.voip.domain.com (balance = -0.860504)
Using b-leg only
Alternatively i tried an alternative dialplan ( Even if i don't relay understand what is the meaning of b-leg billing )
<action application="bridge" data="{enable_heartbeat_events=5,nibble_rate=0.1,nibble_account=${accountcode},originate_timeout=90}sofia/gateway/gw_idt/33$1" />
The result is better because the pending call is hanged up when the balance reach 0.
2016-04-10 12:39:59.012462 [CRIT] mod_nibblebill.c:607 Balance of -0.003237 fell below allowed amount of 0.000000! (Account company.voip.domain.com)
But if i make a new call ( when my balance is negative ) , the caller party is immediately hanged but this did not cancel immediately the bridge: The called party ring and can stay bridged for 61 seconds after answer.
Professional FreeSWITCH Consulting Services:
consulting@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@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org