Communication with the phone application running on the physical phone is via a digium.phone object. The phone app sends events to your custom app when certain events happen, for example on an incoming call. You can see the full list of events the phone app can send on the doc page for digium.event
Communicating with external servers is via the NetRequest object which is very similar to XMLHttpRequest.
If you want to control the phone from your web page, you’ll need to have the phone poll your server for commands to execute via NetRequest. You can also use standard long polling techniques.