Greet Caller by Name in ASP.net
[HttpPost]
public ActionResult GreetCaller(string notificationName, string callLegID,
string caller, string apiExtension)
{
IDictionary<string, string> phoneBook = new Dictionary<string, string>();
phoneBook["+12345671"] = "John";
phoneBook["1001"] = "Kevin";
phoneBook["+12345675"] = "Jack";
var callerName = "Sir or Madame";
if (phoneBook.ContainsKey(caller))
callerName = phoneBook[caller];
return Content(
"<Response>" +
"<Speak>Hello " + callerName + "!</Speak>" +
"</Response>", "text/xml");
}
Code example 1
- Greeting the caller by using a phonebook
IN MORE DETAILS
- When your application receives a call, you will get a Request with all of the call details.
- Fill an associative array with telephone numbers and names.
- In this associative array (phonebook) we are looking for the Caller parameter of the Request.
- After that, send back the response OzML to the caller.