Hội thoại
client.conversations quản lý các luồng hội thoại giữa các liên hệ và nhóm của bạn (hoặc AI agent). Mỗi hội thoại thuộc về một Kênh và được liên kết với một Liên hệ.
Schema
Conversation
| Trường | Kiểu | Mô tả |
|---|---|---|
object_name | "conversation" | Bộ phân biệt loại đối tượng |
id | string | ID duy nhất của hội thoại |
organization_id | string | Tổ chức sở hữu hội thoại này |
business_unit_id | string | ID đơn vị kinh doanh |
channel_id | string | Kênh mà hội thoại này thuộc về |
channel_type | string | Loại nền tảng kênh (xem Kênh) |
contact_id | string | ID liên hệ được liên kết |
status | string | Trạng thái hội thoại (vd: open, resolved) |
name | string | Tên hiển thị của hội thoại |
timestamp | string | ISO 8601 thời gian của tin nhắn gần nhất |
users | SimpleUser[] | Thành viên nhóm hiện đang trong hội thoại này |
Phương thức
| Phương thức | TypeScript | Python | Mô tả |
|---|---|---|---|
| Danh sách | list | list | Danh sách hội thoại có phân trang |
| Lấy | get | get | Lấy hội thoại theo ID nội bộ |
| Lấy theo ID hội thoại | getByConversationId | — | Lấy theo ID hội thoại công khai |
| Tìm kiếm | search | search | Tìm kiếm toàn văn trong đơn vị kinh doanh |
| Đếm theo view | getViewsCount | get_views_count | Đếm hội thoại theo view/trạng thái |
| Tạo | create | create | Tạo hội thoại mới |
| Tham gia | join | join | Tham gia hội thoại với tư cách thành viên nhóm |
| Rời | leave | leave | Rời khỏi hội thoại |
| Cập nhật trạng thái | updateStatus | update_status | Thay đổi trạng thái hội thoại |
| Cập nhật tên | updateName | — | Đổi tên hội thoại |
| Bắt đầu cuộc gọi video | initVideoCall | — | Bắt đầu cuộc gọi video trong hội thoại |
| Gán thành viên nhóm | assignTeamMember | — | Gán thành viên nhóm vào hội thoại |
| Xóa thành viên nhóm | removeTeamMember | — | Xóa thành viên nhóm |
| Lấy người dùng có thể mời | getInvitableUsers | — | Danh sách người dùng có thể mời |
list / list
const page = await client.conversations.list({ type: "open", q: "billing", limit: 20, skip: 0,});for (const conv of page.data) { console.log(conv.id, conv.name, conv.status);}page = client.conversations.list(type="open", q="billing", limit=20, skip=0)for conv in page.get("data", []): print(conv["id"], conv.get("name"), conv.get("status"))search / search
const results = await client.conversations.search({ businessUnitId: "bu_id", q: "refund request", limit: 10,});results = client.conversations.search( business_unit_id="bu_id", q="refund request", limit=10,)create / create
const conversation = await client.conversations.create({ channel_id: "channel_id", contact_id: "contact_id",});console.log(conversation.id);conversation = client.conversations.create()print(conversation["id"])join / join
await client.conversations.join({ conversation_id: "conversation_id" });client.conversations.join({"conversation_id": "conversation_id"})updateStatus / update_status
await client.conversations.updateStatus({ conversation_id: "conversation_id", status: "resolved",});client.conversations.update_status({ "conversation_id": "conversation_id", "status": "resolved",})assignTeamMember
await client.conversations.assignTeamMember({ conversation_id: "conversation_id", user_id: "agent_user_id",});# Không có sẵn trong Python SDKleave / leave
await client.conversations.leave({ conversation_id: "conversation_id" });client.conversations.leave({"conversation_id": "conversation_id"})getByConversationId
const conversation = await client.conversations.getByConversationId("public_conversation_id");console.log(conversation.id, conversation.status);# Không có sẵn trong Python SDKgetViewsCount / get_views_count
const counts = await client.conversations.getViewsCount({ type: "open" });console.log(counts);counts = client.conversations.get_views_count(type="open")print(counts)updateName
await client.conversations.updateName({ conversation_id: "conversation_id", name: "VIP Support Thread",});# Không có sẵn trong Python SDKremoveTeamMember
await client.conversations.removeTeamMember({ conversation_id: "conversation_id", user_id: "agent_user_id",});# Không có sẵn trong Python SDKgetInvitableUsers
const users = await client.conversations.getInvitableUsers("conversation_id");for (const u of users) { console.log(u._id, u.name);}# Không có sẵn trong Python SDKinitVideoCall
const result = await client.conversations.initVideoCall({ conversation_id: "conversation_id",});console.log(result.conversation);# Không có sẵn trong Python SDK