<?xml version="1.0" encoding="utf-8"?>
<!--
//  Copyright (C) 2007 Microsoft Corporation.  All rights reserved.
//  The xml file that describes the finite state machine.
-->
<FiniteStateMachine>
	<FsmModule>
	<!-- findMeSubscriber Manager ==========================================================================-->
		<FindMeSubscriberManager id = "findMeSubscriber" firstActivityId = "100">

			<!-- Uncaught exceptions -->
			<Transition event="quotaExceeded" action="disconnect" refId="100"/>
			<Transition event="xsoError" action="disconnect" refId="100"/>

			<!-- AS soon as the find-me call connects. We play a wave file and then a DTMF "D". 
			The wave file is needed sicne we want to send out some RTP before sending 
			DTMFs, else there might be DTMF issues with gateways. The "D" is needed so 
			that if the findme call for some reason goes back to UM server - then we dont 
			fall into a loop - rather UM server disconnects the call on getting a "D" -->
			<Menu id="100" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
				<Prompt type="wave" name="Silence-250ms.wav"/>
				<Transition event="noKey" action="SendDtmf" refId="100" />
				<Transition event="dtmfSent" action="null" refId="BeSilentForAWhile" />
				<Transition event="faxtone" action="disconnect" refId="100"/>
			</Menu>

			<!-- We play a small silence file between the DTMF and the acutal prompt 
			 to make the user experience better. Else the promtps dont sound good -->
			<Menu id="BeSilentForAWhile" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
				<Prompt type="silence" name="1s" />
				<Transition event="noKey" action="null" refId="PlayPrompt" />
				<Transition event="faxtone" action="disconnect" refId="BeSilentForAWhile"/>
			</Menu>

			<!-- we play the menu to the user. The user can select to hear it again , or to 
			accept the find-me call or to terminate findme. After playing all prompts we wait for
			"inputTimeout" secs to receive a DTMF response. If not received by then - then
			we take the timeout transition and make the next call. IF we receive a faxtone, 
			we disconnect this call and find-me with next number will continue -->
                        <!-- 83948, inputTimeout increased to 10 secs because previous value of 3 secs didn't give
                        the user enough time to make a selection --> 
			<Menu id="PlayPrompt" minDtmfSize="1" maxDtmfSize="1" dtmfInputValue="option"  inputTimeout="10">
				<Prompt type="statement" name="tuiThisIsACallFor" >
					<Prompt type="name" name="CalleeRecordName"/>
				</Prompt>
				<Prompt condition = "NOT IsNull(CallerRecordedName)" type="statement" name="tuiCallFrom" >
					<Prompt type="name" name="CallerRecordedName"/>
				</Prompt>
				<Prompt type="statement" name="tuiToAcceptPressOne" />
				<Prompt type="statement" name="tuiToRejectPressTwo" />
				<Prompt type="statement" name="tuiToHearAgainPressThree" />
				<Transition event="1" action="null" refId="FindMeAccepted"/>
				<Transition event="3" action="null" refId="PlayPrompt"/>
				<Transition event="2" action="TerminateFindMe" refId="FindMeTerminated"/>
				<Transition event="timeout" action="disconnect" refId="PlayPrompt"/>
				<Transition event="faxtone" action="disconnect" refId="PlayPrompt"/>
			</Menu>

			<!-- if the user decides to termiante find-me, we play him a prompt and then
			 terminate find-me -->
			<Menu id="FindMeTerminated" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
				<Prompt type="statement" name="tuiCallRejectedGoodBye" />
				<Transition event="noKey" action="disconnect" refId="FindMeTerminated" />
			</Menu>		

			<!-- if the user wantsto accept the find-me call, we play him a prompt and 
			try to do the transfer -->
			<Menu id="FindMeAccepted" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
				<Prompt type="statement" name="tuiConnecting" />
				<Transition event="noKey" action="AcceptFindMe" refId="Hold"/>
			</Menu>

			<!-- played to the user whiel he is waiting for the transfer to happen -->
			<Menu id="Hold" minDtmfSize="0" maxDtmfSize="0" dtmfInputValue="option">
				<Prompt type="wave" name="ComfortNoise.wav"/>
				<Transition event="noKey" action="null" refId="Hold"/>
			</Menu>
		
		</FindMeSubscriberManager>
	</FsmModule>
</FiniteStateMachine>
