client.channel 管理消息渠道 — 联系人通过这些入口点与您的 AI 代理互动。支持的渠道类型:Web、WhatsApp、Facebook Messenger、Instagram、Email、WeChat、LINE。
Schema
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? | 显示名称 |
方法
核心增删改查
| 方法 | 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 | 将工作流绑定到渠道 |
| 删除渠道工作流 | deleteChannelWorkflow | delete_channel_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})