Contact
client.contacts 管理聯絡人 — 透過您的頻道進行通訊的潛在客戶、客戶或使用者。每個聯絡人可以有連結的對話、評論、檔案和活動歷史。
Schema
Contact
| Field | Type | 說明 |
|---|---|---|
object_name | string? | 物件類型識別碼 |
id | string | 唯一聯絡人 ID |
organization_id | string | 所屬組織 |
display_name | string? | 聯絡人顯示名稱 |
email | string? | 電子郵件地址 |
phone_number | string? | 電話號碼 |
avatar_url | string? | 個人資料圖片 URL |
created_at | string | ISO 8601 建立時間戳 |
updated_at | string | ISO 8601 更新時間戳 |
UpdateContactInput
| Field | Type | Required | 說明 |
|---|---|---|---|
name | string | 更新顯示名稱 | |
email | string | 更新電子郵件地址 | |
phone | string | 更新電話號碼 |
ContactComment
| Field | Type | 說明 |
|---|---|---|
_id | string | 唯一評論 ID |
text | string? | 評論內容 |
created_at | string? | ISO 8601 建立時間戳 |
ContactFile
| Field | Type | 說明 |
|---|---|---|
_id | string | 唯一檔案 ID |
name | string? | 檔案名稱 |
url | string? | 下載 URL |
size | number? | 檔案大小(位元組) |
Methods
| Method | TypeScript | Python | 說明 |
|---|---|---|---|
| List | list | list | 分頁的聯絡人列表 |
| Get | get | get | 依 ID 取得聯絡人 |
| Update | update | update | 更新聯絡人欄位 |
| Search | search | search | 跨聯絡人全文搜尋 |
| Export CSV | exportCsv | export_csv | 以 CSV 下載所有聯絡人 |
| Get conversations | getConversations | get_conversations | 列出聯絡人的對話 |
| Get comments | getComments | get_comments | 列出聯絡人的內部評論 |
| Get files | getFiles | get_files | 列出附加到聯絡人的檔案 |
| Get activities | getActivities | get_activities | 對話活動日誌 |
| Upload avatar | uploadAvatar | upload_contacts | 上傳檔案到聯絡人(頭像 / 檔案匯入) |
| List notifications | listNotifications | list_notifications | 列出目前使用者的通知 |
| Mark notifications read | markNotificationsRead | mark_notifications_read | 將通知標記為已讀 |
| Dismiss notification | dismissNotification | dismiss_notification | 關閉單一通知 |
| Dismiss all notifications | dismissAllNotifications | dismiss_all_notifications | 清除所有通知 |
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);}page = client.contacts.list(limit=50, skip=0)for contact in page.get("data", []): print(contact["id"], contact.get("display_name"), contact.get("email"))search / search
const results = await client.contacts.search({ q: "alice@example.com", limit: 10,});results = client.contacts.search("alice@example.com")update / update
const contact = await client.contacts.update("contact_id", { name: "Alice Smith", email: "alice@example.com", phone: "+84912345678",});contact = 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",});conversations = client.contacts.get_conversations( "contact_id", channel_types="whatsapp,web",)getComments / get_comments
const comments = await client.contacts.getComments("contact_id", { limit: 20, skip: 0,});comments = client.contacts.get_comments("contact_id", limit=20, skip=0)getActivities / get_activities
傳回與此聯絡人關聯的對話活動日誌。
const activities = await client.contacts.getActivities("conversation_id");activities = client.contacts.get_activities("conversation_id")listNotifications / list_notifications
const page = await client.contacts.listNotifications({ limit: 20, skip: 0 });for (const n of page.data) { console.log(n);}page = client.contacts.list_notifications(limit=20, skip=0)markNotificationsRead / mark_notifications_read
await client.contacts.markNotificationsRead(["notif_id_1", "notif_id_2"]);client.contacts.mark_notifications_read()uploadAvatar / upload_contacts
const formData = new FormData();formData.append("file", avatarBlob, "avatar.png");const result = await client.contacts.uploadAvatar(formData);console.log(result.url);with open("avatar.png", "rb") as f: result = client.contacts.upload_contacts(files={"file": f})print(result)