client.channel 管理訊息頻道 — 聯絡人透過這些入口點與您的 AI 代理互動。支援的頻道類型:Web、WhatsApp、Facebook Messenger、Instagram、Email、WeChat、LINE。
結構定義
Channel
| 欄位 | 類型 | 說明 |
|---|
object_name | string? | 物件類型識別碼 |
id | string | 唯一頻道 ID |
name | string | 頻道顯示名稱 |
type | "web" | "facebook" | "whatsapp" | "instagram" | "wechat" | "line" | "email" | "wecom" | 頻道平台類型 |
organization_id | string | 所屬組織 |
business_unit_id | string? | 業務單位 ID |
is_active | boolean | 頻道是否啟用 |
config | object? | 頻道特定設定 |
created_at | string | ISO 8601 建立時間戳 |
updated_at | string | ISO 8601 更新時間戳 |
ChannelCredential
| 欄位 | 類型 | 說明 |
|---|
_id | string | 唯一憑證 ID |
type | string? | 憑證類型(例如 facebook、whatsapp) |
name | string? | 顯示名稱 |
方法
核心 CRUD
| 方法 | TypeScript | Python | 說明 |
|---|
| 列出頻道 | list | list | 列出所有頻道,可依類型篩選 |
| 取得頻道 | get | get | 依 ID 取得頻道 |
| 建立頻道 | create | create | 通用頻道建立 |
| 更新頻道 | update | update | 切換啟用狀態或更新設定 |
| 刪除頻道 | delete / deleteV3 | delete / delete_v3 | 刪除頻道 |
| 取得數量 | getCount | get_count | 頻道總數 |
依類型建立
| 方法 | TypeScript | Python | 說明 |
|---|
| 建立 Web | createWeb | create_web | Web 聊天頻道 |
| 建立 Facebook | createFacebook | create_facebook | Facebook Messenger 頻道 |
| 更新 Facebook | updateFacebook | update_facebook | 更新 Facebook 頻道設定 |
| 建立 Instagram | createInstagram | create_instagram | Instagram 頻道 |
| 建立 Email | createEmail | create_email | Email 頻道 |
| 建立 WeChat | createWechat | create_wechat | WeChat 頻道 |
| 建立 LINE | createLine | create_line | LINE 頻道 |
| 建立 WhatsApp | createWhatsApp | create_whatsapp | WhatsApp 頻道 |
| 更新 WhatsApp | updateWhatsApp | update_whatsapp | 更新 WhatsApp 設定 |
憑證
| 方法 | TypeScript | Python | 說明 |
|---|
| 取得 Facebook 粉絲專頁 | getFacebookPages | get_facebook_pages | 列出憑證的 Facebook 粉絲專頁 |
| 取得憑證 | getCredential | get_credential | 取得已儲存的憑證 |
| 更新憑證 | updateCredential | update_credential | 更新憑證 |
| 刪除憑證 | deleteCredential | delete_credential | 移除憑證 |
工作流程與團隊
| 方法 | TypeScript | Python | 說明 |
|---|
| 更新頻道工作流程 | updateChannelWorkflow | update_channel_workflow | 將 workflow 附加到頻道 |
| 刪除頻道工作流程 | deleteChannelWorkflow | delete_channel_workflow | 卸除 workflow |
| 列出可指派的團隊 | listAssignableTeams | list_assignable_teams | 可指派到此頻道的團隊 |
| 列出團隊觀察者 | listTeamObservers | list_team_observers | 團隊的觀察者 |
list / list
const channels = await client.channel.list({ type: "whatsapp" });
for (const ch of channels) {
console.log(ch.id, ch.name, ch.is_active);
channels = client.channel.list(type="whatsapp")
print(ch.id, ch.name, ch.is_active)
createWeb / create_web
const channel = await client.channel.createWeb({ name: "Website Chat" });
channel = client.channel.create_web("Website Chat")
createWhatsApp / create_whatsapp
const channel = await client.channel.createWhatsApp({
phone_number_id: "phone_number_id",
access_token: "whatsapp_access_token",
channel = client.channel.create_whatsapp({
"phone_number_id": "phone_number_id",
"access_token": "whatsapp_access_token",
createFacebook / create_facebook
const pages = await client.channel.getFacebookPages("credential_id");
const channel = await client.channel.createFacebook({
credential_id: "credential_id",
pages = client.channel.get_facebook_pages("credential_id")
channel = client.channel.create_facebook({
"page_id": pages[0]["_id"],
"credential_id": "credential_id",
createEmail / create_email
const channel = await client.channel.createEmail({
email: "support@example.com",
channel = client.channel.create_email({
"email": "support@example.com",
update / update
await client.channel.update("channel_id", { active: false });
client.channel.update("channel_id", {"active": False})