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:

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. You can 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.

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 equal to 0, the program will transition this person to the NoReservation element. Otherwise, if totalReservation is greater than 0, transition this person to a KeepOrCancel menu element. This element will handle cancellations.

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 the program is 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.

Create and set three other variables.

For the prompt, it will read out the variables we just saved. The program will 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.

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

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

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 this lesson.