Play an ivr based on hangup cause - freeswitch

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

Related

freeswitch dialplan condition not working

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.

Freeswitch - 'find_user_xml' inside dialplan returns boolean instead of XML

fs_cli can execute api function find_user_xml and I can get user data in XML. However, if I run it inside dialplan, Freeswitch logs true instead of real result.
Here is my dialplan extension:
<extension name="Test">
<condition field="destination_number" expression="^(\d{1,20})$">
<action application="set" data="somevar=${find_user_xml(id 1000 xxx.xxx.xxx.xxx)}"/>
<action application="log" data="INFO ${somevar}"/>
</condition>
</extension>
And I get this result instead of actual XML representation:
2019-09-02 07:01:58.120071 [INFO] mod_dptools.c:1792 true
If user does not exist, Freeswitch will return false. Command xml_locate also returns data in XML format and it works just fine.
Does anybody know how can I get XML result from 'find_user_xml' command instead of boolean value?
I found a workaround for this issue - execute find_user_xml like system command. It is not best solution but still returns desired result.
<extension name="Test">
<condition field="destination_number" expression="^(\d{1,20})$">
<action application="set" data="somevar=${system fs_cli -x 'find_user_xml id 1000 xxx.xxx.xxx.xxx'}" />
<action application="log" data="INFO ${somevar}" />
</condition>
</extension>

How can I bridge a call and limit its duration with FreeSWITH?

I try to configure FreeSwitch.
I wish to bridge a call and limits duration, for sample, max 30 seconds.
How can i do it?
This configuration just allow call without limits.
<extension name="Test4">
<condition field="destination_number" expression="^00(\d+)$">
<action application="bridge" data="sofia/gate1/011$1#x.x.x.x"/>
</condition>
</extension>
Or can it be done another way?
Maybe you have already figure it out, but here is answer just for reference.
Before bridge, set app:
<action application="sched_hangup" data="+60"/>
<action application="bridge" data="sofia/gate1/011$1#x.x.x.x"/>
But this will hangup after 60 seconds also including time for setting up call and ringing. If you want to hangup in 60 second after call is established than you need to execute directive on answer:
<action application="set" data="execute_on_answer=sched_hangup +60" />
<action application="bridge" data="sofia/gate1/011$1#x.x.x.x"/>
There are also few more details that you can read about it on FS wiki:
http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_hangup

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!

freeswitch configuration for ipkall

i have setup my freeswitch with plivo but now i m unable to configure ipkall number for my sip user 1005#ipadress since the configuration of freeswitch wiki for ipkall is not clear.
Please can anybody give me steps to configure?
Thanks in advance.
in dialplan/public.xml (or an included file):
<include>
<extension name="IPKALL">
<condition field="destination_number" expression="^5150$">
<action application="set" data="domain_name=freeswitch.org"/>
<action application="transfer" data="1001 XML default"/>
</condition>
</extension>
</include>

Resources