IVR Example Lesson 2. Authenticate Caller
First, we are going to create a menu that checks the caller ID with a database.
Create Main Menu
Create an initial welcome element, with a prompt, for callers. We are going to use this element to authenticate callers. Phone numbers have to be pre-registered in the database because callers are authenticated based on caller ID.
![Customize a welcome message for callers](../images/ivr-welcome-element.jpg)
Authenticate Phone Number
To check the database, we will add an action to the initial element's properties. Create a Database Operation action for the Welcome element and enter in the SQL statement below:
SELECT * FROM user_profile WHERE phone_number = '${__VG__CALLER_ID_NUMBER__}'
![Specify authorized callers](../images/ivr-database-action-room.jpg)
Now that you have gotten information from the database, we need to save it. To access the returned information use: action_variable.column_name.row_index. Where action_name is the name of the Database Operation; column_name is the name of the column in the database table, and row_index is the returned row you want to access. For this IVR application, the database will most likely return one row. row_index starts from 1.
Save the user's phone number and email, as shown below.
![Retrieve user information from database](../images/ivr-welcome-actions.jpg)
![IVR software screenshot](../images/ivr-authorized-screen.jpg)
If the phone number is in the database, theUser.rows will be greater than 0.
![Phone call menu](../images/ivr-main-menu.jpg)
If the database does not contain this phone number, theUser.rows will return 0. Then the application will tell them to use an authorized phone number to call in.
![Deny unauthourized callers](../images/ivr-not-authorized.jpg)
Application So Far
To see the IVR application up until here, open room_reservation_step1.ivr in the package provided at the beginning of lesson 10.