SuperAPI AI 工具集

telnyx-sip-integrations-javascript

编程与开发

查看项目

更新于 10-16 05:24

技能介绍

用途

本技能面向使用 Telnyx 平台进行 SIP 中继集成的 JavaScript 开发者,提供基于 Telnyx Node.js SDK 的接口调用示例,用于管理通话录音、媒体存储、Dialogflow 集成以及外部连接等能力。

安装与初始化

安装命令:

npm install telnyx

初始化方式:

import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

文档中所有示例均假设 client 已按上述方式初始化。

错误处理

所有 API 调用都可能因网络错误、限流(429)、校验错误(422)或认证错误(401)而失败。生产代码中应始终处理错误。示例展示了如何区分 Telnyx.APIConnectionError、Telnyx.RateLimitError 和 Telnyx.APIError,并针对 429 使用指数退避重试。常见错误码包括:401 无效 API 密钥、403 权限不足、404 资源未找到、422 校验错误、429 限流。

分页

列表方法返回自动分页迭代器,可使用 for await (const item of result) { ... } 自动遍历所有页面。

主要能力

自定义存储凭据

支持检索、创建、更新、删除自定义存储凭据,后端类型为 gcs、s3 或 azure。对应接口:

  • GET /custom_storage_credentials/{connection_id}
  • POST /custom_storage_credentials/{connection_id}
  • PUT /custom_storage_credentials/{connection_id}
  • DELETE /custom_storage_credentials/{connection_id}

Dialogflow 连接

支持检索、创建、更新、删除与 CallControl 连接关联的 Dialogflow 连接,用于保存 Dialogflow 凭据供其他 Telnyx 服务使用。对应接口:

  • GET /dialogflow_connections/{connection_id}
  • POST /dialogflow_connections/{connection_id}
  • PUT /dialogflow_connections/{connection_id}
  • DELETE /dialogflow_connections/{connection_id}

外部连接(External Connections)

外部连接用于通过 Mission Control Portal 中的 External Voice Integrations 与 Telnyx 合作伙伴配置 SIP 中继集成。支持列表、创建、检索、更新、删除。创建时 external_sip_connection 和 outbound 为必填,external_sip_connection 枚举值为 zoom、operator_connect。删除可能因号码占用、连接处于活动状态或为 Operator Connect 连接而被阻止;移除 Operator Connect 集成需联系 Telnyx 支持。对应接口:

  • GET /external_connections
  • POST /external_connections
  • GET /external_connections/{id}
  • PATCH /external_connections/{id}
  • DELETE /external_connections/{id}

日志消息

支持列出所有外部连接的日志消息、检索单条日志消息、忽略(dismiss)日志消息。对应接口:

  • GET /external_connections/log_messages
  • GET /external_connections/log_messages/{id}
  • DELETE /external_connections/log_messages/{id}

市政地址与位置

支持列出 Microsoft Teams 的市政地址和位置、检索单个市政地址、更新位置的静态紧急地址。对应接口:

  • GET /external_connections/{id}/civic_addresses
  • GET /external_connections/{id}/civic_addresses/{address_id}
  • PATCH /external_connections/{id}/locations/{location_id}

电话号码

支持列出、检索、更新与外部连接关联的电话号码。对应接口:

  • GET /external_connections/{id}/phone_numbers
  • GET /external_connections/{id}/phone_numbers/{phone_number_id}
  • PATCH /external_connections/{id}/phone_numbers/{phone_number_id}

Release 请求

当更改当前位于 Microsoft Teams 上的电话号码的 connection_id 时,会自动创建 Release。支持列出和检索 Release 请求。对应接口:

  • GET /external_connections/{id}/releases
  • GET /external_connections/{id}/releases/{release_id}

Upload 请求

支持列出和创建面向 Microsoft Teams 的 Upload 请求。创建时 civic_address_id 与 location_id 只能提供其一,不能同时提供。对应接口:

  • GET /external_connections/{id}/uploads

适用场景

适用于需要在 JavaScript/Node.js 应用中通过 Telnyx SDK 配置和管理 SIP 中继集成、存储凭据、Dialogflow 连接、外部语音集成(如 Zoom、Operator Connect)、Teams 相关地址与号码管理的开发者。

限制

资料未提供收费、价格、平台支持范围、性能指标或具体使用步骤的额外说明。部分接口(如创建 Upload 请求)的完整示例在资料中未给出。