Now that you have successfully written your first Voice API, we will modify the code to make is more personalized we will include caller name in greeting.
For example: “Hello Bob”
// contacts array will List everyone your contacts
$contacts = array(
// if the caller is known, then greet them by name
// otherwise, just identify them as another caller
if(!$name = $contacts[$_REQUEST['From']])
$name = "there";
// now greet the caller
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
<Say>Hello <?php echo $name ?>.</Say>
In the code above we started off by creating an array $contact. In this array we have listed all the known contacts with their phone number and name. When the call comes in from parameter will be triggered and look in the $contact array to see if we have the phone number in our contacts. If the phone number is located in the contacts then the code will greet the caller with name (like Hello Bob) else it will treat the caller unknown and respond “Hello There”.
Key word used = Say Say Reads the text and convert’s that to audio and play to the caller.
Wohooo!!!! You successfully completed the step and identified your caller by name!!!
Sounds good, now let's. Let's collect users response and so you can transfer call to the right person.