Chuyển đến nội dung

Contact

client.contacts quản lý contacts — 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 contact có thể có các hội thoại, comments, files, và lịch sử hoạt động liên kết.


Schema

Contact

FieldTypeMô tả
object_namestring?Định danh loại đối tượng
idstringID duy nhất của contact
organization_idstringTổ chức sở hữu contact này
display_namestring?Tên hiển thị của contact
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

FieldTypeRequiredMô 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

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

ContactFile

FieldTypeMô 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)

Methods

MethodTypeScriptPythonMô tả
ListlistlistDanh sách contacts có phân trang
GetgetgetLấy contact theo ID
UpdateupdateupdateCập nhật trường contact
SearchsearchsearchTìm kiếm toàn văn contacts
Export CSVexportCsvexport_csvTải xuống tất cả contacts dưới dạng CSV
Get conversationsgetConversationsget_conversationsDanh sách hội thoại của contact
Get commentsgetCommentsget_commentsDanh sách comments nội bộ trên contact
Get filesgetFilesget_filesDanh sách files đính kèm với contact
Get activitiesgetActivitiesget_activitiesNhật ký hoạt động hội thoại
Upload avataruploadAvatarupload_contactsTải lên file cho contacts (avatar / import file)
List notificationslistNotificationslist_notificationsDanh sách thông báo cho người dùng hiện tại
Mark notifications readmarkNotificationsReadmark_notifications_readĐánh dấu thông báo đã đọc
Dismiss notificationdismissNotificationdismiss_notificationBỏ qua một thông báo
Dismiss all notificationsdismissAllNotificationsdismiss_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 contact 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);