freeswitch dialplan condition not working - freeswitch

I am trying to understand db module.
Here is my dialplan for testing.
Here issue is that my condition is not working. Without condition its working fine.
Anyone please guide that how can i get this working ?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="dialplan" description="Test Dialplan">
<context name="default">
<extension name="919824012345">
<condition field="destination_number" expression="919824012345">
<action application="set" data="effective_destination_number=919824012345"/>
<action application="set" data="bridge_pre_execute_bleg_app=sched_hangup"/>
<action application="set" data="bridge_pre_execute_bleg_data=+6000 normal_clearing"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="continue_on_fail=TRUE"/>
<action application="set" data="call_processed=internal"/>
<action application="set" data="call_direction=outbound"/>
<action application="set" data="accountname=default"/>
<action application="set" data="origination_rates=ID:2|CODE:^91.*|DESTINATION:|CONNECTIONCOST:0.00000|INCLUDEDSECONDS:0|CT:|COST:0.20000|INC:60|INITIALBLOCK:1|RATEGROUP:1|MARKUP:0|CI:0|ACCID:24"/>
<action application="set" data="original_caller_id_name=919426223273"/>
<action application="set" data="original_caller_id_number=919824012345"/>
<action application="limit" data="db 24 user_24 1 !SWITCH_CONGESTION"/>
<condition field="${db(exists/realm/account_24)}" expression="^true$"/>
<condition field="${db(select/realm/account_24)}" expression="4"/>
<action application="set" data="var=${db(select/realm/account_24)}"/>
<action application="db" data="insert/realm/account_24/$${var}+1"/>
<anti-action application="hangup" data="${originate_disposition}"/>
</condition>
<anti-action application="db" data="insert/realm/account_24/1"/>
<action application="set" data="execute_on_anwer=transfer OUTBOUNDSERVICE XML default"/>
</condition>
<action application="bridge" data="[leg_timeout=30,absolute_codec_string=^^:PCMA:G729:PCMA]sofia/gateway/mygateway/919824012345"/>
</condition>
</extension>
</context>
</section>
</document>
I would like to achieve below
if exists account_24 then select the value of account_24 key.
If its value 4 or smaller then continue the call and add one more count.
If its value 4 then hangup call.
Once the call will be completed decrease its count up to 0.
In simple language, Count management to know how many calls are running for the customer. It should not more than assign to the customer.
Please, Let me know if required any more helps.

Related

Freeswitch: transfer b-leg to survey extension after a-leg hangs up

Due to Freeswitch documentation hangup_after_bridge=false means to continue with dialplan when B-leg terminates the call (ext. 180 in this case), but this dialplan fails to transfer A-leg to ext. 913
<extension name="180" continue="false" uuid="d0667b02-b3b8-40e4-a034-edf1ad4850fa">
<condition field="destination_number" expression="^(180)$">
<action application="export" data="call_direction=inbound" inline="true"></action>
<action application="set" data="domain_uuid=368fc039-4fc4-43f1-ac24-2d673dedd18f" inline="true"></action>
<action application="set" data="domain_name=sirhan.sip.sirhan.com" inline="true"></action>
<action application="set" data="hangup_after_bridge=false"></action>
<action application="set" data="continue_on_fail=true"></action>
<action application="transfer" data="180 XML silah.sip.silah.com.sa"></action>
<action application="transfer" data="913 XML silah.sip.silah.com.sa"></action>
</condition>
</extension>

freeswitch recordings during IVR

in last version of freeswitch i got a problem - on stereo records during ivr some noice presnt in b-channel. dialplan:
<extension name="91:1">
<condition field="destination_number" expression="^1203$" require-nested="false">
<action application="export" data="dialed_extension=1203"/>
<action application="set" data="hangup_after_bridge=false"/>
<action application="set" data="session_in_hangup_hook=true"/>
<action application="set" data="RECORD_STEREO=true"/>
<action application="set" data="record_name=$${recordings_dir_tmp}/${strftime(%Y-%m-%d)}/${caller_id_number}.${dialed_extension}.${call_uuid}.wav" />
<action application="record_session" data="${record_name}"/>
<action application="set" data="execute_on_answer=python detect_gp ${record_name}"/>
<action application="set" data="ivr_menu_terminator=*"/>
<action application="ivr" data="91:1"/>
<action application="playback" data="/etc/freeswitch/moh/moh" />
<action application="hangup"/>
</condition>
</extension>
wav file left channel
how i can resolve this problem?
Receiving out of band DTMF (RFC2833 telephone event 101) can interfere with recording. You will get silent spots instead of tones. That might explain why your recording sounds like the audio cuts out or packet loss.

Play an ivr based on hangup cause

Is there anyway to play an ivr based on Hangupcause ?
Right now i have tried below dialplan but seems like its not working.
So please suggest if there is any other way i can achieve it.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="dialplan" description="Custom_dialplan">
<context name="default">
<extension name="123456">
<condition field="destination_number" expression="123456">
<action application="set" data="effective_destination_number=123456"/>
<action application="set" data="transfer_on_fail=RECOVERY_ON_TIMER_EXPIRE auto_cause xml error"/>
<action application="bridge" data="sofia/gateway/Dummy_Gateway/123456"/>
<action application="log" data="AFTER BRIDGE"/>
</condition>
</extension>
</context>
<context name=error">
<action application="log" data="AFTER BRIDGE2"/>
<extension name="RECOVERY_ON_TIMER_EXPIRE" continue="true">
<action application="log" data="AFTER BRIDGE3"/>
<condition field="${originate_disposition}" expression="RECOVERY_ON_TIMER_EXPIRE" continue="false" break="on-true">
<action application="log" data="AFTER BRIDGE4"/>
<action application="playback" data="/usr/local/freeswitch/sounds/en/us/callie/notinservice.wav"/>
</condition>
</extension>
</context>
</section>
</document>
Definitely, you have done few mistakes in your dialplan while it is significant:
Before use transfer_on_fail you should set up another obligatory options follows:
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="failure_causes=RECOVERY_ON_TIMER_EXPIRE"/>
To remove that logging option BRIDGE due to it's useless and it will never be handled.
I would like to draw your attention the dialplan has strict structure, so you can't insert options/actions wherever you want. First of all, you should remove all logging from the context ERROR
-- The sequence is going to be: context -> extension --> condition --> action (s). Thus you have setup the condition follows with the action playing announcement.
--!-- You have taken call handling in your hands, so please manage the process. After your platform had played to leg A you have to instruct FreeSWITCH terminating the call (it must follow "playback"):
<action application="hangup" data="NORMAL_CLEARING"/>
However, I assume your dialplan won't work ever because RECOVERY_ON_TIMER_EXPIRE is the status of Freeswitch State Machine which appear when SIP 408. You should use Q.850 hangup cause in dialplan instead, so try replacing it with NO_USER_RESPONSE.
You may find Q.850 hangup cause table here

Why onference_auto_outcall_flags doesn't work

I have the following configuration in my dialplan:
<extension name="conference_set_auto_outcall">
<condition field="destination_number" expression="^ds_(.*);(.*);(.*);(.*)$">
<action application="answer"/>
<action application="set" data="conference_auto_outcall_flags=mute"/>
<action application="set" data="conference_auto_outcall_caller_id_name=$${effective_caller_id_name}"/>
<action application="set" data="conference_auto_outcall_caller_id_number=$${effective_caller_id_number}"/>
<action application="set" data="conference_auto_outcall_profile=default"/>
<action application="set" data="conference_auto_outcall_prefix={sip_auto_answer=true,execute_on_answer_1='start_dtmf_generate',execute_on_answer_2='send_dtmf $4'}"/>
<action application="conference_set_auto_outcall" data="{ignore_early_media=true}sofia/gateway/$2/$3"/>
<action application="conference" data="$1+flags{moderator|mute}"/>
</condition>
</extension>
I need to set flags to the members that are joined to the conference by the auto call. Unfortunately none of the flags I set in conference_auto_outcall_flags is propagated to the members. I can hear the called member and
show channels
in fs_cli shows the following information among other staff:
1946#default+flags{}
e.g. flags aren't assigned.
FreeSwitch version 1.6.6
What can be wrong?
FreeSWITCH wiki seems to be outdated. In 1.6.6 source codes the parameter is called
conference_utils_auto_outcall_flags
so the flags need to be specified as
<action application="set" data="conference_utils_auto_outcall_flags=mute"/>

Call faliure: invalid number format (Zoiper Communicator)

Hi I'm working with freeswitch, in my dialplan I have this extension:
<extension name="uk_maxadie_8">
<condition field="destination_number" expression="^447589800001$">
<action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
<action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
<action application="set" data="accountcode=aphroditel"/>
<action application="bridge" data="sofia/external/radio#didx.net"/>
</condition>
</extension>
And then from my softphone(Zoiper) I call to the "destination_number" 447589800001 but I get this error message: Call faliure: invalid(incomplete) number format.
I have another extensions where the destination_number are also 12 units long, so i don't know what i did wrong. Any idea?
Thanks!

Resources