Freeswitch bgapi originate command with ignore_early_media=true - freeswitch

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.

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

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