Simple Day Nite Mode

From FreeSWITCH Wiki
Jump to: navigation, search

Contents

Introduction

This is a very simple example of using the dialplan to manipulate global variables.

Discussion

This dialplan example will manipulate the global variable "sys_mode" which normally contains "DAY" or "NITE" depending on the system mode. Dial x9200 to set day mode and dial x9201 to set nite mode. NOTE: At the time of this writing I did not have "day mode" or "night mode" prompts recorded, so I just filled in with "call forwarding set" for setting NITE mode and "Call forwarding cancelled" for indicating that DAY mode has been set.

To act on DAY mode vs. NITE mode simply check the value of ${sys_mode} and act accordingly.

Dialplan

Simple extension to display what the current mode is:

  <extension name="Day/Nite mode check" continue="true">
    <condition>
      <action application="log" data="INFO Current system mode is: ${sys_mode}"/>
    </condition>
  </extension>


Set DAY mode:

  <extension name="Day mode example">
    <condition field="destination_number" expression="^9200$">
      <action application="answer"/>
      <action application="sleep" data="500"/>
      <action application="set" data="${global_setvar(sys_mode=DAY)}"/>
      <action application="playback" data="ivr/ivr-call_forwarding_has_been_cancelled.wav"/>>
      <action application="log" data="WARNING System has been put into [[[DAY mode]]] by ${caller_id_number}"/>
      <action application="hangup"/>
    </condition>
  </extension>


Set NITE mode:

  <extension name="Night mode example">
    <condition field="destination_number" expression="^9201$">
      <action application="answer"/>
      <action application="sleep" data="500"/>
      <action application="set" data="${global_setvar(sys_mode=NITE)}"/>
      <action application="playback" data="ivr/ivr-call_forwarding_has_been_set.wav"/>>
      <action application="log" data="WARNING System has been put into [[[NITE mode]]] by ${caller_id_number}"/>
      <action application="hangup"/>
    </condition>
  </extension>

See Also