you can write scripts to access databases and/or web services on remote machines etc in just about any scripting language (php, perl, etc) and call them from your dial plan using the AGI() command
if you are starting out and want some simple code to give you the idea, try Nerd Vittles Weather:
it is a little AGI script which ask the user for an airport code, goes to the national weather service site and gets the weather for that airport and reads it to the user. You can then play with it and connect it to databases and build more complex applications.