JS callbacks are used to establish communication between Messenger application and your web site. For example add a user to friends list, report a user, etc. Flash object calls relevant JS functions with parameters.
You can redefine these functions in Messenger.htm file and add custom code to perform the required action. In most cases you will have to use AJAX to do that.