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

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

Related

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>

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"/>

Freeswitch bgapi originate command with ignore_early_media=true

I'm trying the following scenario on freeswitch:
Create a call (a-leg)
Create another call (b-leg)
Bridge then together
The b-leg phone is a dial plan in other freeswitch is the following:
<extension name="EarlyMedia">
<condition field="destination_number" expression="^[+]?[1]?<MY_NUMBER>">
<action application="pre_answer"/>
<action application="playback" data="/home/ubuntu/EARLY_MEDIA.wav"/>
<action application="sleep" data="1000"/>
<action application="answer"/>
<action application="playback" data="/home/ubuntu/CALL_MEDIA.wav"/>
<action application="sleep" data="1000"/>
</condition>
</extension>
The sequence of commands that i sent to freeswitch is the following:
a-leg
bgapi originate {ignore_early_media=true,bridge_early_media=false,origination_caller_id_number=sofia/external/<MY_FROM_NUMBER>#<MY_IP>,origination_channel_name=<MY_CHANNEL>,ringback=\'%(2000,4000,440,480)\'}sofia/external/<A-LEG NUMBER>#<MY_IP> &park()
b-leg
bgapi originate {ignore_early_media=true,bridge_early_media=false,origination_caller_id_number=sofia/external/<MY_FROM_NUMBER>#<MY_IP>,origination_channel_name=<MY_CHANNEL>,ringback=\'%(2000,4000,440,480)\'}sofia/external/<B-LEG NUMBER>#<MY_IP> &park()
uuid_bridge
bgapi uuid_bridge <A-LEG UUID> <B-LEG UUID>
The problem is that even with ignore_early_media=true,bridge_early_media=false i hear the early media on A-LEG
ignore_early_media does not mean you do not 'hear' the early media. It just means Freeswitch will not treat it as an answer.
From the docs ignore_early_media:
Controls if the call returns on early media or not. Default is false
Even with ringback=\'%(2000,4000,440,480)\ set, I have found that Freeswitch will still send a 183 SIP response. If it is your Freeswitch sending the 183 you do not want, remove ringback=\'%(2000,4000,440,480)\ and see if that works. Also, you can use ring_ready to send a 180 which should not have SDP/early media.

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