Added and Fixed chat function in chat API. Tested