跳到內容

Channel

client.channel 管理訊息頻道 — 聯絡人透過這些入口點與您的 AI 代理互動。支援的頻道類型:Web、WhatsApp、Facebook Messenger、Instagram、Email、WeChat、LINE


Schema

Channel

FieldType說明
object_namestring?物件類型識別碼
idstring唯一頻道 ID
namestring頻道顯示名稱
type"web" | "facebook" | "whatsapp" | "instagram" | "wechat" | "line" | "email" | "wecom"頻道平台類型
organization_idstring所屬組織
business_unit_idstring?業務單位 ID
is_activeboolean頻道是否啟用
configobject?頻道特定配置
created_atstringISO 8601 建立時間戳
updated_atstringISO 8601 更新時間戳

ChannelCredential

FieldType說明
_idstring唯一憑證 ID
typestring?憑證類型(例如 facebookwhatsapp
namestring?顯示名稱

Methods

Core CRUD

MethodTypeScriptPython說明
List channelslistlist列出所有頻道,可依類型篩選
Get channelgetget依 ID 取得頻道
Create channelcreatecreate通用頻道建立
Update channelupdateupdate切換啟用狀態或更新配置
Delete channeldelete / deleteV3delete / delete_v3刪除頻道
Get countgetCountget_count頻道總數

Per-type Creation

MethodTypeScriptPython說明
Create WebcreateWebcreate_webWeb 聊天頻道
Create FacebookcreateFacebookcreate_facebookFacebook Messenger 頻道
Update FacebookupdateFacebookupdate_facebook更新 Facebook 頻道配置
Create InstagramcreateInstagramcreate_instagramInstagram 頻道
Create EmailcreateEmailcreate_emailEmail 頻道
Create WeChatcreateWechatcreate_wechatWeChat 頻道
Create LINEcreateLinecreate_lineLINE 頻道
Create WhatsAppcreateWhatsAppcreate_whatsappWhatsApp 頻道
Update WhatsAppupdateWhatsAppupdate_whatsapp更新 WhatsApp 配置

Credentials

MethodTypeScriptPython說明
Get Facebook pagesgetFacebookPagesget_facebook_pages列出憑證的 Facebook 粉絲專頁
Get credentialgetCredentialget_credential取得已儲存的憑證
Update credentialupdateCredentialupdate_credential更新憑證
Delete credentialdeleteCredentialdelete_credential移除憑證

Workflow & Teams

MethodTypeScriptPython說明
Update channel workflowupdateChannelWorkflowupdate_channel_workflow將 workflow 附加到頻道
Delete channel workflowdeleteChannelWorkflowdelete_channel_workflow卸除 workflow
List assignable teamslistAssignableTeamslist_assignable_teams可指派到此頻道的團隊
List team observerslistTeamObserverslist_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);
}

createWeb / create_web

const channel = await client.channel.createWeb({ name: "Website Chat" });
console.log(channel.id);

createWhatsApp / create_whatsapp

const channel = await client.channel.createWhatsApp({
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({
page_id: pages[0]._id,
credential_id: "credential_id",
});

createEmail / create_email

const channel = await client.channel.createEmail({
name: "Support Inbox",
email: "support@example.com",
});

update / update

await client.channel.update("channel_id", { active: false });