Misc. Dialplan Tools sched hangup

From FreeSWITCH Wiki
Jump to: navigation, search
What is the equivalent in FreeSWITCH for Asterisk S(n) Dial command setting?

S(n): Hangup the call n seconds AFTER called party picks up.

How to set a maximum call duration?

The sched_hangup application allows you to schedule a hangup action for a call, basically to limit call duration.

Recipe 1

Before you call bridge add another action that executes the sched_hangup application.

<action application="sched_hangup" data="+<seconds>[ <cause>]"/>

So to make the call last 1 minute and end with cause SWITCH_CAUSE_ALLOTTED_TIMEOUT (which happens to be the default so you can omit it unless you need another cause.)

<action application="sched_hangup" data="+60 allotted_timeout"/>

Also if you omit the '+' character the value will be considered the absolute epoch time you wish the call to end.

Once a call is already up you can do it from the sched_hangup API command from XML-RPC or the command CLI.

Do a show channels to get the uuid of the call then enter.

sched_hangup +60 <uuid> alotted_timeout

All the params besides uuid have the same meaning as the dialplan app.

Recipe 2

If you follow recipe 1 and your dialplan looks like:

<action application="sched_hangup" data="+60 alloted_timeout"/>
<action application="bridge" data="sofia/external/1234567@"/>

you will execute hangup exactly 60 seconds after calling sched_hangup. This means 60 seconds including call setup time. For example, if remote side answers the call 15 seconds after phone starts ringing there will be 45 seconds left for the actual conversation.

  • If you want to ensure 60 seconds of talk time, schedule hangup at the moment of answering:
<action application="set" data="execute_on_answer=sched_hangup +60 alloted_timeout" />
<action application="bridge" data="sofia/external/1234567@" />
  • If your a-leg call has already been answered, e.g. with an IVR and you want to limit on the B-leg, then use: note: api_on_answer, not execute_on_answer
<action application="export" data="nolocal:api_on_answer=sched_hangup +60 ${uuid} alloted_timeout" />
<action application="bridge" data="sofia/external/1234567@" />

See also