Conversation
client.conversations quản lý các luồng hội thoại giữa contacts và nhóm của bạn (hoặc AI agent). Mỗi hội thoại thuộc về một Channel và được liên kết với một Contact.
Schema
Conversation
| Field | Type | 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 Channel) |
contact_id | string | ID contact 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 |
Methods
| Method | TypeScript | Python | Mô tả |
|---|---|---|---|
| List | list | list | Danh sách hội thoại có phân trang |
| Get | get | get | Lấy hội thoại theo ID nội bộ |
| Get by conversation ID | getByConversationId | — | Lấy theo ID hội thoại công khai |
| Search | search | search | Tìm kiếm toàn văn trong đơn vị kinh doanh |
| Get views count | getViewsCount | get_views_count | Đếm hội thoại theo view/trạng thái |
| Create | create | create | Tạo hội thoại mới |
| Join | join | join | Tham gia hội thoại với tư cách thành viên nhóm |
| Leave | leave | leave | Rời khỏi hội thoại |
| Update status | updateStatus | update_status | Thay đổi trạng thái hội thoại |
| Update name | updateName | — | Đổi tên hội thoại |
| Init video call | initVideoCall | — | Bắt đầu cuộc gọi video trong hội thoại |
| Assign team member | assignTeamMember | — | Gán thành viên nhóm vào hội thoại |
| Remove team member | removeTeamMember | — | Xóa thành viên nhóm |
| Get invitable users | 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