OzML IVR

In this guide you can see different ways of making an Interactive Voice Response (IVR) in your Ozeki Phone System using an OzML script. Below you can see an OzML script and three ways of using it.

How to select the Text to speech language

1. Create the IVR script in OzML

The following OzML scripts demonstrate 3 examples for using an IVR system. You can see how to play an audio file into the phone call, how to use text-to-speech, what happens if a user presses a button and even how to send SMS or e-mail messages. The 'Simple' and 'Advanced' examples can be used with IVR Extension, SQL OzML and HTTP OzML as well. For testing the 'Professional' example please use HTTP OzML.

Simple IVR menu example:

<Response> 
	<UserInput Timeout="5" Repeat="true"> 
		<InitialCommands> 
			<Speak>
				Hello, you called Ozeki Phone System IVR.
				For more information please press 1.
				To transfer the call to an employee please press 2.
			</Speak>
		</InitialCommands> 
		<Inputs> 
			<Input Key="1"> 
				<Speak>
					To set up this OzML response, you have 3 options.
					You could add new IVR Extension.
					You could use HTTP API with an API Extension.
					Or you could add new SQL OzML Extension.
				</Speak>
			</Input> 
			<Input Key="2"> 
				<BlindTransfer>2000</BlindTransfer> 
			</Input> 
		</Inputs> 
	</UserInput> 
</Response>

Advanced IVR menu example:

<Response>
	<UserInput Timeout="5" Repeat="true">
		<InitialCommands>
			<Play>welcome.wav</Play>
			<Speak>
				The conversation will be recorded for privacy reasons.
				For more information about banking services press 1.
				For account balance information in SMS message press 2.
				To subscribe e-mail newsletter press 3.
				To call with our customer representative press 4.
				To leave a message press 5.
			</Speak>
		</InitialCommands>
		<Inputs>
			<Input Key="1">
				<UserInput Timeout="5" Repeat="true">
					<InitialCommands>
						<Speak>
							For retail banking information please press 1.
							For corporate banking information please press 2.
							For private banking information please press 3.
						</Speak>
					</InitialCommands>
					<Inputs>
						<Input Key="1">
							<Speak>
								We offer several financial solutions for retailers...
							</Speak>
						</Input>
						<Input Key="2">
							<Speak>
								We offer several financial solutions for companies...
							</Speak>
						</Input>
						<Input Key="3">
							<Speak>
								We offer several financial solutions for individuals...
							</Speak>
						</Input>
					</Inputs>
				</UserInput>
			</Input>
			<Input Key="2">
				<SendSms Recipient="+062554670">
					Account balance: 2.000 USD
				</SendSms>
				<Hangup></Hangup>
			</Input>
			<Input Key="3">
				<SendEmail Recipient="info@yourcompany.com">
					You have successfully subscribed to our newsletter.
				</SendEmail>
				<Hangup></Hangup>
			</Input>
			<Input Key="4">
				<BlindTransfer>2000</BlindTransfer>
			</Input>
			<Input Key="5">
				<Speak>
					Record your 10 second message
				</Speak>
				<Record FinishedUrl="http://yourapp.com/record_finished.php" 
					    FinishDigits="1" Format="wav">
				</Record>
				<UserInput Timeout="5" Repeat="true">
					<InitialCommands>
						<Speak>
							Press 1 to send it as e-mail.
						</Speak>
					</InitialCommands>
					<Inputs>
						<Input Key="1">
							<SendEmail Recipient="info@yourcompany.com" 
							           Attachment="recorded.wav">
							           Subject="Recorded audio">
								Your recorded message has been sent to your e-mail.
							</SendEmail>
						</Input>
					</Inputs>
				</UserInput>
			</Input>
		</Inputs>
	</UserInput>
</Response>

Professional IVR menu example:

//*************************************************************************************/
// This file will be executed when the call is connected.
// Filename: incomingcall.php
//*************************************************************************************/
<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <UserInput ForwardToUrl="http://yourapp.com/dtmf_received.php" 
   		      digits="4" timeout="10" repeat="true">
    	<InitialCommands> 
       		<Speak>Please enter your 4 digits PIN code.</Speak>
		</InitialCommands>
	</UserInput>
</Response>

//*************************************************************************************/
// This file will be executed when DTMF input is received.
// dtmf_received.php
//*************************************************************************************/
<?php
	$dtmfdigits = $_REQUEST['DtmfDigits'];
	$sql = mysql_query('SELECT id FROM account WHERE pincode LIKE "' . $dtmfdigits . '";');
	$row = mysql_fetch_assoc($sql);

	if(mysql_num_rows($sql) == 1) {
		$response = "<GoTo>http://yourapp.com/members_area.php?accountid=
					                   " . $row['id'] . "</GoTo>";
	}
	else {
		$response = "<UserInput ForwardToUrl="http://yourapp.com/dtmf_received.php" 
					             digits="4" timeout="10" repeat="true">";
		$response .= "<InitialCommands>";
		$response .= "<Speak>";
		$response .= "The PIN code you entered is invalid. Please give it again.";
		$response .= "Please enter your 4 digits PIN code again.";
		$response .= "</Speak>";
		$response .= "</InitialCommands>";
		$response .= "</UserInput>";
	}
?>

<?xml version="1.0" encoding="UTF-8"?>
<Response>
	<?php
	echo $response;
	?>
</Response>

//*************************************************************************************/
// This file will be executed when the PIN code is accepted.
// members_area.php
//*************************************************************************************/
<?php
	$accountid = $_REQUEST['accountid'];
	$sql = mysql_query('SELECT balance FROM account WHERE id = "' . $accountid . '";');
	$row = mysql_fetch_assoc($sql);
?>

<?xml version="1.0" encoding="UTF-8"?>
<Response>
	<UserInput Timeout="5" Repeat="true"> 
		<InitialCommands> 
			<Speak>
				The pin code you entered is verified.
				Account balance, press 1.
				To call with our customer representative, press 2.
			</Speak>
		</InitialCommands> 
		<Inputs> 
			<Input Key="1"> 
				<Speak>
					<?php
					echo $row['balance'];
					?>
				</Speak>
			</Input> 
			<Input Key="2"> 
				<BlindTransfer>2000</BlindTransfer> 
			</Input> 
		</Inputs> 
	</UserInput> 
</Response>

Code example 1 - IVR menu with OzML

This is a simple OzML exapmle of using IVR extension. The code starts with speaking the 3 sentences between the <InitialCommands></InitialCommands> nodes repeatedly with a 5 second delay (Timeout=”5”) and scans the pressed numbers at the same time.

If you press the button 1, you will hear more information about the Ozeki Phone System IVR.
By pressing 2, you will be transfered to an added number (in this case this number is 2000) with the command. The BlindTransfer command is used to connect two phones together. If the connection is established, the phone which connected the phones together will leave the conversation.

You can find more command descriptions and more things to know about the OzML language on our OzML reference book page.

This is an advanced OzML exapmle of using IVR extension. The code starts with playing a .wav audio file welcome messeage with the <Play> OzML command. After that it speaks 6 sentences between the <InitialCommands></InitialCommands> nodes repeatedly with a 5 second delay (Timeout=”5”) and scans the pressed numbers at the same time. The system warnings you that the converstation will be recorded.

By pressing 1, you enter a lower menu, which starts with a new <UserInput command> just like the first one. The only difference is we set a BackKey which is a DTMF key to return to the upper menu level if this UserInput command is nested in another UserInput command. In this case, the BackKey is the '*' button. The speak engine speaks 3 menu sentences and you can press buttons 1, 2 and 3 to reach the options. If you press button 1 in this menu option, you will hear retail bank informations saying by the speak engine. By pressing 2 and 3 corporate and private bank informations will be read by the speak engine. And we can return to an upper menu level by pressing the '*' button.

In the first menu if you press the button 2, an SMS will be sent to '+062554670' number containing your account balance. You can send an sms by using the command Ozeki Phone System OzML language <SendSms> command. In this example, we set Recipient which is the destination phone number and we added the text message. And finish the call with the <Hangup> command.

By pressing 3, you can subscribe e-mail newsletter. We added the destination address of the e-mail which is ”info@yourcompany.com” and the e-mail text to send: „You have successfully subscribed to our newsletter”.

By pressing 4, you will be blind transferred to a customer representative on number 2000. The BlindTransfer command is used to connect two phones together. If the connection is established, the phone which connected the phones together will leave the conversation.

By pressing 5, you can record a message with the <Record> OzML command. The Record command records the voice of the current call. The finished URL is where the RecordCompleted notification is sent and if you press the button 1 you can finish the recording. And if you press the button 1 again you can send this record to an e-mail address.

2. Host the script

Option 1: Use your PBX

Incoming calls can easily be routed to an IVR Extension. You only need to give an Extension phone number and use an OzML script. If a call is forwarded to that IVR Extension, the caller person could listen to the IVR menu that is in the OzML Script. Learn more

ivr extension
Figure 1 - IVR Extension

Option 2: Use your database

SQL OzML makes it possible to create a new IVR from your other IT system. Ozeki Phone System receives a call from any extension or outside line, then select an OzML Script from the SQL database. Then the Ozeki Phone System will load the IVR menu to the caller. Learn more

sql ozml
Figure 2 - SQL OzML

Option 3: Use your webserver

Ozeki Phone System makes it easy to connect it to other IT systems through HTTP API. An OzML script can be placed on an own website. It can be given with the Ozeki Phone System HTTP API which website’s content the Ozeki Phone System should ask for in case of an incoming call. Learn more

http ozml
Figure 3 - HTTP OzML

More information