Just a thought, you may way to look in to Asterisk. While it does a lot more than what you've mentioned, it has a very nice interface for doing so. It has a nifty little feature called "AGI" scripts, which are similar to CGI scripts in that it will execute a program every time it gets a phone call, then provides a nice interface for that script to communicate with the caller.