Chuyển đến nội dung

Liên hệ

client.contacts quản lý các liên hệ — khách hàng tiềm năng, khách hàng, hoặc người dùng giao tiếp qua các kênh của bạn. Mỗi liên hệ có thể có các hội thoại, comments, files, và lịch sử hoạt động liên kết.


Schema

Contact

TrườngKiểuMô tả
object_namestring?Định danh loại đối tượng
idstringID duy nhất của liên hệ
organization_idstringTổ chức sở hữu liên hệ này
display_namestring?Tên hiển thị của liên hệ
emailstring?Địa chỉ email
phone_numberstring?Số điện thoại
avatar_urlstring?URL ảnh đại diện
created_atstringISO 8601 thời gian tạo
updated_atstringISO 8601 thời gian cập nhật

UpdateContactInput

TrườngKiểuBắt buộcMô tả
namestringCập nhật tên hiển thị
emailstringCập nhật địa chỉ email
phonestringCập nhật số điện thoại

ContactComment

TrườngKiểuMô tả
_idstringID duy nhất của comment
textstring?Nội dung comment
created_atstring?ISO 8601 thời gian tạo

ContactFile

TrườngKiểuMô tả
_idstringID duy nhất của file
namestring?Tên file
urlstring?URL tải xuống
sizenumber?Kích thước file (bytes)

Phương thức

Phương thứcTypeScriptPythonMô tả
Danh sáchlistlistDanh sách liên hệ có phân trang
LấygetgetLấy liên hệ theo ID
Cập nhậtupdateupdateCập nhật trường liên hệ
Tìm kiếmsearchsearchTìm kiếm toàn văn trên các liên hệ
Xuất CSVexportCsvexport_csvTải xuống tất cả liên hệ dưới dạng CSV
Lấy hội thoạigetConversationsget_conversationsDanh sách hội thoại của liên hệ
Lấy commentgetCommentsget_commentsDanh sách comments nội bộ trên liên hệ
Lấy filegetFilesget_filesDanh sách files đính kèm với liên hệ
Lấy hoạt độnggetActivitiesget_activitiesNhật ký hoạt động hội thoại
Tải lên avataruploadAvatarupload_contactsTải lên file cho liên hệ (avatar / import file)
Danh sách thông báolistNotificationslist_notificationsDanh sách thông báo cho người dùng hiện tại
Đánh dấu thông báo đã đọcmarkNotificationsReadmark_notifications_readĐánh dấu thông báo đã đọc
Bỏ qua thông báodismissNotificationdismiss_notificationBỏ qua một thông báo
Bỏ qua tất cả thông báodismissAllNotificationsdismiss_all_notificationsXóa tất cả thông báo

list / list

const page = await client.contacts.list({ limit: 50, skip: 0 });
for (const contact of page.data) {
console.log(contact.id, contact.display_name, contact.email);
}

const results = await client.contacts.search({
q: "alice@example.com",
limit: 10,
});

update / update

const contact = await client.contacts.update("contact_id", {
name: "Alice Smith",
email: "alice@example.com",
phone: "+84912345678",
});

getConversations / get_conversations

const conversations = await client.contacts.getConversations("contact_id", {
channelTypes: "whatsapp,web",
});

getComments / get_comments

const comments = await client.contacts.getComments("contact_id", {
limit: 20,
skip: 0,
});

getActivities / get_activities

Trả về nhật ký hoạt động cho một hội thoại liên kết với liên hệ này.

const activities = await client.contacts.getActivities("conversation_id");

listNotifications / list_notifications

const page = await client.contacts.listNotifications({ limit: 20, skip: 0 });
for (const n of page.data) {
console.log(n);
}

markNotificationsRead / mark_notifications_read

await client.contacts.markNotificationsRead(["notif_id_1", "notif_id_2"]);

uploadAvatar / upload_contacts

const formData = new FormData();
formData.append("file", avatarBlob, "avatar.png");
const result = await client.contacts.uploadAvatar(formData);
console.log(result.url);