<?xml version="1.0" encoding="utf-8"?>
<!--
//  Copyright (C) 2006 Microsoft Corporation.  All rights reserved.
//  The xml file that describes the finite state machine.
-->
<FiniteStateMachine>
	<FsmModule>
		<!-- Check whether the pilot# info greeting is enabled, and interruptible -->
		<Menu id="infoGreetingMenu" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Condition value="pilotNumberInfoAnnouncementEnabled AND (pilotNumberInfoAnnouncementInterruptible)">
				<Prompt condition="NOT pilotNumberWelcomeGreetingEnabled" type="wave" name="earcon.wav"/>
				<Prompt condition="pilotNumberWelcomeGreetingEnabled" type="varwave" name="pilotNumberWelcomeGreetingFilename"/>
				<Prompt type="varwave" name="pilotNumberInfoAnnouncementFilename"/>
			</Condition>
			<!-- if info greeting was interruptible, we already played it in this menu. go to pilot# main menu -->
			<Condition value="pilotNumberInfoAnnouncementEnabled AND (pilotNumberInfoAnnouncementInterruptible)">
				<Transition event="noKey" refId="101" action="null"/>
			</Condition>
			<!-- 
				if info greeting was not interruptible, to to menu to play the greeting in 
				an uninterruptible manner.
			-->
			<Condition value="pilotNumberInfoAnnouncementEnabled AND (NOT pilotNumberInfoAnnouncementInterruptible)">
				<Transition event="noKey" refId="infoGreetingNonInterruptibleMenu" action="null"/>
			</Condition>
			<!-- if info announcement is not enabled, go straight to main menu -->
			<Transition condition="NOT pilotNumberInfoAnnouncementEnabled" event="noKey" action="null" refId="101"/>
		</Menu>

		<!-- play info announcement uninterruptible -->
		<Menu id="infoGreetingNonInterruptibleMenu" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option" uninterruptible="true">
			<Prompt condition="NOT pilotNumberWelcomeGreetingEnabled" type="wave" name="earcon.wav"/>
			<Prompt condition="pilotNumberWelcomeGreetingEnabled" type="varwave" name="pilotNumberWelcomeGreetingFilename"/>
			<Prompt type="varwave" name="pilotNumberInfoAnnouncementFilename"/>
			<Transition event="noKey" refId="101" action="null"/>
		</Menu>

		<!-- Wecome to Exchange Unified Messaging -->
		<Menu id="101" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Prompt condition="IsNull(ocFeature) AND (NOT pilotNumberInfoAnnouncementEnabled) AND (NOT pilotNumberWelcomeGreetingEnabled)" type="wave" name="earcon.wav"/>
			<Prompt condition="IsNull(ocFeature) AND (NOT pilotNumberInfoAnnouncementEnabled) AND pilotNumberWelcomeGreetingEnabled" type="varwave" name="pilotNumberWelcomeGreetingFilename"/>

			<Transition event="noKey" action="validateCaller" heavyaction="true" refId="102" />
			<Transition event="mailboxFound" condition="NOT skipPinCheck" refId="104" action="getName" heavyaction="true"/>
			<Transition event="mailboxFound" condition="skipPinCheck" refId="handleSkipPinLogon" action="null"/>
			<Transition event="mailboxNotSupported" action="PrepareForTransferToServer" heavyaction="false" refId="HandleMailboxNotSupported"/>
			<Transition event="noMoreServers" action="null" refId="HandleMailboxNotSupportedFailure"/>
			<!-- do not handle faxtone here, We need a mailboxFound transition before accepting faxtones (See 104) -->
			<Transition event = "umdiagnosticCall" refId = "6000" action = "null"></Transition>
			<Transition event="xsoError" refId="119" action="null"/>		
		</Menu>

		<CallTransfer id="HandleMailboxNotSupported" type="blindTransferToHost" numberType="variable" number="targetPhoneNumber">
			<Transition event="transferFailed" action="null" refId="HandleMailboxNotSupportedFailure"/>
		</CallTransfer>

		<Menu id="HandleMailboxNotSupportedFailure" minDtmfSize="0" maxDtmfSize="0">
			<Prompt type="statement" name="tuiMailboxNotSupported"/>
			<Prompt type="statement" name="tuiCallBackLater"/>
			<Transition event="noKey" action="disconnect" refId="HandleMailboxNotSupported"/>
		</Menu>

		<!-- Pilot number menu  -->
		<Menu id="102" minDtmfSize="extension" maxDtmfSize="extension" dtmfInputValue="extension" interDigitTimeout="5" inputTimeout="20">
			<Prompt condition="NOT GlobalActivityManager:ConsumerDialPlan" type="statement" name="tuiAccessMailbox"/>
			<Prompt condition="GlobalActivityManager:ConsumerDialPlan" type="statement" name="tuiAccessMailboxNumber"/>
			<Prompt condition="contactSomeoneEnabled" type="statement" name="tuiContactSomeone"/>

			<Transition event="anyKey" action="validateMailbox" heavyaction="true" refId="107"/>
			<Transition event="mailboxFound" action="getName" heavyaction="true" refId="104"/>
			<Transition event="maxInvalidMailbox" action="null" refId="108"/>
			<Transition event="mailboxNotSupported" action="PrepareForTransferToServer" heavyaction="false" refId="HandleMailboxNotSupported"/>
			<Transition event="noMoreServers" action="null" refId="HandleMailboxNotSupportedFailure"/>
			<Transition event="xsoError" refId="119" action="null"/>
			<!-- 
				As we are expecting minDtmf=maxDtmf=extension any input with digits<extension will trigger 
				a timeout event. Call validateMailbox to take care of the failure count and generate
				the necessary auto events. If no input was present in the buffer, just play the default
				"are you still there?" message.
			-->
			<Transition event="timeout" condition="NOT IsNull(lastInput)" action="validateMailbox" heavyaction="false" refId="107"/>

			<!-- handle #. If no default AA or extension are configured, go to directory search -->
			<Transition condition="contactSomeoneEnabled" event="#" action="handleCallSomeone" refId="300"/>
			<!-- default AA found, and it was a DTMF AA, transition to DTMF AA menu -->
			<Transition event="validDtmfAutoAttendant" refId="900" action="null"/>
			<!-- default AA found, and it was a Speech AA, transition to Speech AA menu -->
			<Transition event="validSpeechAutoAttendant" refId="2000" action="null"/>
			<!-- default operator extension was found. Do a call transfer to that extension -->
			<Transition event="runCallExtension" action="null" refId="950"/>
			<!-- do not handle faxtone here, We need a mailboxFound transition before accepting faxtones (See 104) -->
			<Transition event = "umdiagnosticCall" refId = "6000" action = "null"></Transition>
			<!-- If tuiPromptEditingEnabled is enabled jump to the prompt provisioning section -->
			<Transition event = "#*" condition="tuiPromptEditingEnabled" refId="PromptProvisioningLogon" action="setPromptProvContext"/>
		</Menu>

		<!-- Played if the entered mailbox is not valid -->
		<Menu id="107" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Transition condition="(lastInput NE @#) OR (NOT contactSomeoneEnabled)" event="noKey" action="null" refId="102"/>
			<Transition condition="(lastInput EQ @#) AND contactSomeoneEnabled" event="noKey" action="handleCallSomeone" refId="300"/>
			<Prompt condition="GlobalActivityManager:DialPlanType NE @E164 AND ((lastInput NE @#) OR (NOT contactSomeoneEnabled))" type="statement" name="tuiInvalidMailbox">
				<Prompt type="digit" name="lastInput"/>
			</Prompt>
			<Prompt condition="GlobalActivityManager:DialPlanType EQ @E164 AND ((lastInput NE @#) OR (NOT contactSomeoneEnabled))" type="statement" name="tuiInvalidMailboxPhone">
				<Prompt type="digit" name="lastInput"/>
			</Prompt>
		</Menu>
		<Menu id="108" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Prompt type="statement" name="tuiInvalidMailbox">
				<Prompt type="digit" name="lastInput"/>
			</Prompt>
			<Prompt type="statement" name="tuiSorryTryAgainLater"/>
			<Transition event="noKey" refId="108" action="disconnect"/>
		</Menu>

		<!-- Goodbye Prompt -->
		<Menu id="118" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Prompt type="statement" name="tuiGoodbye"/>
			<Transition event="noKey" action="disconnect" refId="118"/>
		</Menu>	
		<!-- Mailbox error prompt -->
		<Menu id="119" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
			<Prompt type="statement" name="tuiMailboxUnavailable"/>
			<Transition event="noKey" action="disconnect" refId="119"/>
		</Menu>

		<!-- call transfer from pilot# menu when transferring to default operator in dialplan -->
		<CallTransfer id="950" type="blindTransferToPhone" numberType="variable" number="targetPhoneNumber">
			<Transition event="transferFailed" action="null" refId="951"/>
		</CallTransfer>

		<Menu id="951" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option" >
			<Prompt type="statement" name="tuiTransferFailed"/>
			<Transition event="noKey" refId="102" action="null"/>
		</Menu>

		<!-- Prompt Provisioning module -->
		<FsmImport href = "PromptProvisioning.fsm"/>
	</FsmModule>
</FiniteStateMachine>

