Answer from Milen solves the technical side of the question. But there is also a problem of interactions.
Let's assume you have trigger that does things over TCPIP. This means that the query that launched the trigger can take a long time (think network issues, service issues, firewalls).
Usually much better solution is to store information in some kind of queue, and addition of service, which checks the queue (perhaps using NOTIFY/LISTEN feature of PostgreSQL), and does what's necessary over TCP/IP - with proper handling of long connections, retries and so on.
If you'd be inclined to use such mechanism, you might want to check pgq from SkyTools.