跳转到内容

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 });