The composite aggregation is a way to paginate over all buckets of a complex aggregation. It doesn't allow custom sort. If you want a list of messages collapsed by user and sorted by most recent you can use field collapsing:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-collapse.html
GET my_index/_search
{
"collapse" : {
"field" : "user",
},
"sort": [ {"timestamp": "desc" } ]
}
The query will return the most recent message by user and you can paginate over the results using from.