IVR Example Lesson 5. Cancel a Reservation

If users don't want to make a reservation, they can also choose to cancel existing ones.

Existing Reservations

Add an element called TotalReservation to the MainMenu. If you collapse the SelectRoom element, your application should look like:

IVR software screenshot

In TotalReservation add a Call Java Method action called getTotal. This will call a Java method that will query a database for the number of rooms reserved by this caller. Write your own method if you wish. Fill in the information similar to below. Remember that the caller ID is saved in the variable, theUser.

Query database

Add another action for Set Variable Value. Make the name totalReservation and the value getTotal.result. This will save the number of reservations made.

If totalReservation is 0, transition this person to a NoReservation element. Otherwise, if totalReservation > 0, transition this person to a KeepOrCancel menu element. This element will handle cancellations.

Create element for cancellation

Keep or Cancel

KeepOrCancel will read out the first reservation. Add a variable in Incoming Call called iReservation with a value of 0. This will keep track of which reservation we are currently on. The first item starts at 0. First, retrieve it from the database with a Call Java Method action. Fill in the information similar to below if you are using our java files.

Call Java Method

Create and set three other variables.

Set up variables

For the prompt, it will read out the variables we just saved. Tell the caller the room and time of the reservation. We can put the variables into the prompts because actions are executed before prompts. Then, tell them to press 1 to cancel or 2 to continue.

Give caller option to cancel reservation

Now, create two prompt elements called DoCancel or TryNext. In DoCancel, create a Call Java action.

Call Java Action

Create a Set Variable action that saves doCancel.phone_number into a variable, thePhone. Then create a Log Message action.

Log the cancellation

In TryNext, increment iReservation.

Application So Far

To see the IVR application up until here, open room_reservation_step4.ivr in the package provided at the beginning of lesson 10.