postmessage api

fixed bugs;
return promise reject instead of throw for some cases;
added postmessage api for bots;