2 API DOC
zelda edited this page 2026-01-30 18:17:19 +11:00

API Documentation

1. Get Conversations

URL: /conversations
Method: GET
Query Parameters: Pagination parameters (page, limit, etc.)

Response

{
  "message": "Thành công!",
  "status_code": 200,
  "data": [
    {
      "id": "19:uni01_clgxpvmvgzh7647hcq6s@thread.v2",
      "name": "System Bot",
      "type": "group",
      "created_at": "2025-08-07T01:08:44.920Z",
      "updated_at": "2025-08-07T01:08:44.920Z"
    }
  ],
  "timestamp": "2025-08-07T02:01:46.592Z",
  "current_page": 1,
  "from": 1,
  "to": 2,
  "last_page": 1,
  "per_page": 10,
  "total": 2
}

2. Get Conversation by ID

URL: /conversations/:id
Method: GET

Response

{
  "message": "Thành công!",
  "status_code": 200,
  "data": {
    "id": "19:uni01_clgxpvmvgzh7647hcq6sp5itg@thread.v2",
    "name": "General Discussion",
    "type": "group",
    "created_at": "2025-08-07T01:08:44.920Z",
    "updated_at": "2025-08-07T01:08:44.920Z",
    "messages": [
      {
        "id": "a326950b-679f-4e30-8d78-3e5bb05f464c",
        "name": "TeamBot",
        "message": "You're welcome! If you have any more questions or need assistance, feel free to ask.",
        "time": "2025-06-19T09:31:44.000Z",
        "time_raw": "1750325503714",
        "date_time": "1750325503714",
        "room_id": "19:uni01_clgxpvmvgzh7647hcq6sp5itg@thread.v2",
        "room_name": "General Discussion",
        "created_at": "2025-08-07T01:20:46.846Z",
        "updated_at": "2025-08-07T01:52:12.000Z"
      },
      {
        "id": "a9a78d1b-c564-4c75-a15e-ab872f09726e",
        "name": "TeamBot",
        "message": "Sample message here",
        "time": "2025-06-19T09:20:45.000Z",
        "time_raw": "1750324844593",
        "date_time": "1750324844593",
        "room_id": "19:uni01_clgxpvmvgzh7647hcq6sp5itglwcqbbmhdxbokme5battrjlvnra@thread.v2",
        "room_name": "General Discussion",
        "created_at": "2025-08-07T01:20:46.820Z",
        "updated_at": "2025-08-07T01:52:12.000Z"
      }
    ]
  },
  "timestamp": "2025-08-07T01:52:12.513Z"
}

3. Send Message

URL: /messages/send-message
Method: POST

Request Body

{
  "conversation_id": "19:abc123@thread.v2",
  "message": "Xin chào! Đây là tin nhắn mới."
}
Field Type Required Description
conversation_id string ID của cuộc trò chuyện cần gửi tin
message string Nội dung tin nhắn

Response

{
  "message": "Thành công!",
  "status_code": 200,
  "data": {
    "conversation": {
      "id": "19:@thread.v2",
      "name": "System bot",
      "type": "group",
      "created_at": "2025-08-07T01:08:44.913Z",
      "updated_at": "2025-08-07T01:08:44.913Z"
    },
    "data": {
      "message": "Xin chào! Đây là tin nhắn mới.",
      "conversation_id": "19:@thread.v2"
    }
  },
  "timestamp": "2025-08-07T01:52:02.553Z"
}

4. Reply Message

URL: /messages/reply-message
Method: POST

Request Body

{
  "conversation_id": "19:abc123@thread.v2",
  "message": "Đây là phản hồi",
  "time": 1754466808815
}
Field Type Required Description
conversation_id string ID của cuộc trò chuyện
message string Nội dung phản hồi
time number Timestamp (milliseconds) của tin nhắn gốc

Response

{
  "message": "Thành công!",
  "status_code": 200,
  "data": {
    "conversation": {
      "id": "19:@thread.v2",
      "name": "System Bot",
      "type": "group",
      "created_at": "2025-08-07T01:08:44.913Z",
      "updated_at": "2025-08-07T01:08:44.913Z",
      "messages": [
        {
          "id": "595b6276-b7bc-4b9f-9b36-c424fea024ef",
          "name": "Teams Bot",
          "message": "heheh\n8/6/2025, 9:11 AM\n😠\n\nhello",
          "time": "2025-08-06T07:53:29.000Z",
          "time_raw": "1754466808815",
          "date_time": "1754466808815",
          "room_id": "19:@thread.v2",
          "room_name": "Test",
          "created_at": "2025-08-07T01:15:39.815Z",
          "updated_at": "2025-08-07T01:15:39.815Z"
        }
      ]
    },
    "data": {
      "message": "test",
      "conversation_id": "19:@thread.v2",
      "time": 1754466808815
    }
  },
  "timestamp": "2025-08-07T01:51:54.367Z"
}

5. Get Messages

URL: /messages
Method: GET
Description: Lấy danh sách tin nhắn, hỗ trợ phân trang, sort, search và filter theo conversation.


Query Parameters

Parameter Type Description
page number Trang hiện tại
limit number Số bản ghi mỗi trang
sortBy string Sắp xếp, ví dụ: time_raw:DESC
search string Tìm kiếm theo nội dung message
filter.conversation.id string Lọc theo ID của conversation

Filter format

filter.<column>=$<operator>:<value>

Filter theo conversation

GET /messages?filter.conversation.id=$eq:19:abc123@thread.v2

Filter nhiều conversation

GET /messages?filter.conversation.id=$in:19:abc@thread.v2,19:def@thread.v2

Không thuộc conversation nào

GET /messages?filter.conversation.id=$isnull

Supported Operators

Operator Meaning
$eq Bằng
$ne Khác
$in Trong danh sách
$notin Không trong danh sách
$gt Lớn hơn
$gte Lớn hơn hoặc bằng
$lt Nhỏ hơn
$lte Nhỏ hơn hoặc bằng
$ilike Tìm kiếm text (không phân biệt hoa thường)
$isnull Null

Example Request

GET /messages?page=1&limit=10&sortBy=time_raw:DESC&filter.conversation.id=$eq:19:abc123@thread.v2

Response

{
  "message": "Thành công!",
  "status_code": 200,
  "data": [
    {
      "id": "a326950b-679f-4e30-8d78-3e5bb05f464c",
      "name": "TeamBot",
      "message": "Sample message",
      "time": "2025-06-19T09:31:44.000Z",
      "time_raw": "1750325503714",
      "room_id": "19:abc123@thread.v2",
      "created_at": "2025-08-07T01:20:46.846Z",
      "updated_at": "2025-08-07T01:52:12.000Z"
    }
  ],
  "current_page": 1,
  "per_page": 10,
  "total": 1
}