Implement API for json based messages

See the ChatAPITest for examples