跳到正文

面向开发者

将 Telofia 接入您已在使用的系统

通过 REST API 读取通话、转写文本、预约和联系人;事件一发生即收到签名 Webhook;让助手在通话中查询您系统里的实时数据;只需一行代码,即可在网站上添加语音助手。

REST API 和 Webhook 包含在所有套餐中,自 Line 起;更高套餐的限额更高。免费试用期间可获得测试权限:1 个 API 密钥,每分钟 20 次请求。

API 基础 URL
https://telofia.com/api/v1
curl · 测试密钥
curl https://telofia.com/api/v1/me \
  -H "Authorization: Bearer tf_live_…"
200 OK
{
  "object": "account",
  "id": "1f2e3d4c-5b6a-4789-8a7b-6c5d4e3f2a1b",
  "name": "Smile Dental",
  "timezone": "Europe/Warsaw",
  "locale": "en",
  "country": "PL",
  "currency": "PLN",
  "status": "active",
  "plan": {
    "id": "team",
    "billing_cycle": "month",
    "trial_ends_at": null,
    "period_start": "2026-10-01T00:00:00Z",
    "period_end": "2026-11-01T00:00:00Z",
    "recording_history_days": 365
  },
  "minutes": {
    "included": 3000,
    "extra": 100,
    "total": 3100,
    "used": 412.5,
    "remaining": 2687.5
  },
  "api_key_id": "2a3b4c5d-6e7f-4a8b-9c0d-1e2f3a4b5c6d",
  "scopes": [
    "read:calls",
    "read:appointments",
    "read:contacts",
    "read:tasks"
  ],
  "limits": {
    "plan": "team",
    "requests_per_minute": 180,
    "requests_per_day": 50000,
    "max_api_keys": 10,
    "max_webhook_endpoints": 10
  }
}

快速入门

两分钟发出第一个请求

  1. 1

    创建 API 密钥

    在管理后台进入“开发者 → API 密钥”,为密钥命名并选择权限范围。密钥(tf_live_…)只显示一次,请妥善保存到您的密钥管理工具中。

  2. 2

    测试连接

    调用 GET /me。任何有效密钥均可使用,返回您的账户、密钥的权限范围以及套餐限额。

  3. 3

    读取数据或订阅事件

    获取通话、预约和联系人列表,或在“开发者 → Webhook”下添加接收端点,实时接收事件。

curl · 测试密钥
curl https://telofia.com/api/v1/me \
  -H "Authorization: Bearer tf_live_…"
JavaScript:分页获取所有已预约的通话
const API = "https://telofia.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.TELOFIA_API_KEY}` };

// All calls booked since 1 October, page by page
let cursor = null;
while (true) {
  const url = new URL(`${API}/calls`);
  url.searchParams.set("outcome", "booked");
  url.searchParams.set("since", "2026-10-01T00:00:00Z");
  url.searchParams.set("limit", "100");
  if (cursor) url.searchParams.set("cursor", cursor);

  const res = await fetch(url, { headers });
  if (res.status === 429) {
    // rate limited: wait for the number of seconds in Retry-After, then retry the same page
    await new Promise((r) => setTimeout(r, Number(res.headers.get("Retry-After") ?? 1) * 1000));
    continue;
  }
  if (!res.ok) throw new Error((await res.json()).error.message);

  const page = await res.json();
  for (const call of page.data) console.log(call.started_at, call.from, call.summary);
  if (!page.has_more) break;
  cursor = page.next_cursor;
}

REST API v1

通过 HTTPS 访问通话、预约和联系人

JSON 进,JSON 出。每个请求均通过 API 密钥认证,并受套餐限额约束。请求会记录在管理后台(方法、路径、状态和时间——绝不记录请求或响应内容)。

身份验证

在“API 密钥”中创建密钥,并将其作为 Bearer 令牌发送。密钥以 tf_live_ 开头,且仅属于一个账户。

Authorization: Bearer tf_live_…

分页

列表端点按稳定的顺序最多返回 limit 条数据(1–100,默认 25)。当 has_more 为 true 时,请将 next_cursor 原样作为 cursor 传入(筛选条件保持不变)以获取下一页。无效的游标会返回 400 invalid_request。

错误

错误使用标准 HTTP 状态码,并返回包含类型和可读消息的 JSON 正文。

{ "error": { "type": "…", "message": "…" } }

端点

  • GET/me权限范围: 任意密钥

    获取当前账户

    返回该 API 密钥所属的账户。适合用作“测试连接”调用。

  • GET/assistants权限范围: 任意密钥

    助手列表

    返回您的助手及其语言、状态和已分配的电话号码。筛选通话时,可将其 id 用作 assistant_id。

  • GET/assistants/{id}权限范围: 任意密钥

    获取助手

    返回一个助手及其语言、状态和电话号码。如果具有 read:assistants(或 write:assistants)权限范围,还会返回提示词:instructions、greeting、company_profile 和 updated_at。

  • PATCH/assistants/{id}权限范围: write:assistants

    更新助手提示词

    修改指令、问候语或公司简介。未提供的字段保持不变。限制与控制台一致:指令最多 40,000 个字符,公司简介最多 10,000 个字符,问候语 5–600 个字符,且必须说明来电者正在与 AI 通话(否则返回 400,code 为 ai_disclosure)。每次修改都会保存到助手的版本历史中(来源为 API),并从下一次通话起生效。无论您如何设置指令,平台的诚信规则(AI 披露、录音提示)始终适用。

  • GET/phone-numbers权限范围: 任意密钥

    电话号码列表

    返回您账户的电话号码,包含国家/地区、类型、状态以及接听该号码的助手。

  • GET/calls权限范围: read:calls

    通话列表

    按时间从新到旧返回通话,不含通话转写。演示通话不会被包含。

  • GET/calls/{id}权限范围: read:calls

    获取通话

    返回一次通话,包含完整通话转写以及通话期间预约的所有预约。

  • GET/calls/{id}/recording权限范围: read:calls

    获取通话录音

    返回用于在线播放和下载该通话 MP3 录音的签名链接,有效期 1 小时(立体声:来电者在左声道,助手在右声道)。早于您套餐录音保存期限的录音会返回 403 plan_required 及 recording_history_days;没有录音的通话会返回 404。

  • GET/appointments权限范围: read:appointments

    预约列表

    按开始时间顺序返回即将到来的预约(默认从当前时间起)。

  • GET/appointments/{id}权限范围: read:appointments

    获取预约

    您账户中的一个预约。

  • POST/appointments/{id}/cancel权限范围: write:appointments

    取消预约

    取消即将到来的预约,将其从已连接的 Google 日历中移除,并发送 appointment.canceled Webhook。calendar_sync 字段表示日历是否已更新。

  • POST/appointments/{id}/reschedule权限范围: write:appointments

    预约改期

    将即将到来的预约改到新的时间。如果该时间与其他预约或已连接日历中的忙碌时段冲突,则返回 409。未提供 ends_at 时,时长保持不变。会发送 appointment.rescheduled Webhook。

  • GET/contacts权限范围: read:contacts

    联系人列表

    按时间从新到旧返回来电者。助手会在多次通话之间记住他们。

  • GET/contacts/{id}权限范围: read:contacts

    获取联系人

    返回一个联系人,包含姓名、电子邮件、标签、备注,以及姓名和电子邮件的来源(call、system 或 manual)。

  • POST/contacts权限范围: write:contacts

    创建联系人

    添加联系人(例如来自您的 CRM),以便助手知道来电者的姓名。通过 API 保存的姓名和电子邮件来源标记为 manual,助手不会覆盖。如果电话号码已存在,则返回 409 及 contact_id。会发送 contact.created Webhook。

  • PATCH/contacts/{id}权限范围: write:contacts

    更新联系人

    修改姓名、电子邮件、备注或屏蔽标记。未提供的字段保持不变,null 表示清空该字段。修改后的姓名或电子邮件来源会标记为 manual,因此助手不会覆盖。电话号码不可更改。

  • GET/tasks权限范围: read:tasks

    任务列表

    按时间从新到旧返回来自通话的回电请求、留言和其他任务。

  • GET/tasks/{id}权限范围: read:tasks

    获取任务

    您账户中的一个任务。

  • PATCH/tasks/{id}权限范围: write:tasks

    更新任务

    将任务状态设置为 open、done 或 dismissed,例如在您的团队已回电给客户之后。

  • POST/conversions权限范围: write:calls

    上报购买

    您的商店、CRM 或自动化流程(例如通过 n8n 转发的 WooCommerce 订单 Webhook)上报客户的一次购买。归因方式:call_id 或 phone(最近 14 天内与该号码的最近一次对话)。匹配成功的购买会作为“购买”计入收入,该通话的结果将变为 purchase(“成交”)。相同的 order_id 只会记录一次。

  • POST/calls/outbound权限范围: write:calls

    创建外呼

    您的助手使用您的企业号码,按您给定的目标呼叫一个人,类似新客引导序列中的一个步骤。通话会立即发出,或在 call_at 指定的时间发出,且始终在通话时段内(周一至周六 9:00–20:00,按您账户的时区;超出时段会顺延到下一个允许的时间,call_at 会显示实际时间)。如果无人接听,最多尝试 3 次,每次间隔 2 小时。返回 202,通话状态为 scheduled。错误:400 consent_missing、invalid_phone、number_not_callable、international 或 invalid_call_at;409 opted_out(对方要求不再来电)、already_scheduled(附带 existing_id)、assistant_not_live、over_quota 或 no_outbound_number;429 daily_outbound_limit 及 limit(默认每 24 小时 200 次通话)。结果会通过 call.completed 和 outbound_call.finished Webhook 送达,并附带您的 external_id。

  • GET/calls/outbound/{id}权限范围: write:calls

    获取外呼

    计划外呼的状态:scheduled、dialing、done(附带该对话的 call_id)、failed(last_error,例如所有尝试后仍为 no_answer)或 canceled。也可使用 Webhook 中新客引导和回电通话的 callback_id 查询。

  • DELETE/calls/outbound/{id}权限范围: write:calls

    取消外呼

    取消通过 API 创建且仍处于计划状态的外呼。可放心重复调用(已取消时返回 200)。当通话正在拨号或已结束,或属于新客引导通话时,返回 409 not_cancelable(请改用 POST /api/outreach/unenroll 移除该联系人)。

  • GET/messages权限范围: read:messages

    SMS 列表

    按时间从新到旧返回您的账户发送的 SMS 和客户的回复。phone 为客户的号码(收件人或回复的发送者)。generated_by:template、ai 或 manual;charged_from:plan 或 credits。

  • POST/messages权限范围: write:messages

    发送 SMS

    向您的某个联系人或来电者发送 SMS:可使用您自己的文本,或使用账户中的某个模板并附带 vars(date、time、name、service、link、amount)。计入您套餐的 SMS 额度和额外购买的 SMS。错误:400 invalid_request(consent_missing、invalid_phone、too_long、missing_vars);409 conflict(opted_out — 客户回复了 STOP;over_quota;recipient_not_allowed — 请先创建联系人;blocked_destination);429 rate_limited。

  • POST/assistants权限范围: write:assistants

    Create an assistant

    Adds an assistant to the account, like Assistant → New assistant in the dashboard: it copies the company settings of an existing assistant (profile, hours, languages, voice, greetings with the new name, booking, persona) without instructions or knowledge. Limited by the plan (409 assistant_limit with limit). Assign a phone number with PATCH /phone-numbers/{id}. Returns 201.

  • GET/assistants/{id}/prompt-versions权限范围: read:assistants

    List prompt versions

    The assistant's prompt history (instructions, greeting, company profile, persona), newest first, without contents. A version is saved on every change from the dashboard, the API, AI suggestions or a restore; the last 100 are kept. source: panel, ai, api, suggestion, learning, onboarding, restore or system.

  • GET/prompt-versions/{id}权限范围: read:assistants

    Retrieve a prompt version

    One saved version with its full instructions, greeting, company profile and persona, to compare with the current settings before restoring it.

  • POST/prompt-versions/{id}/restore权限范围: write:assistants

    Restore a prompt version

    Brings back the version's instructions, company profile, persona and greeting (an empty greeting in the version keeps the current one), like Restore in the dashboard's prompt history. Same checks as PATCH /assistants/{id} (the greeting must say the caller is talking to an AI). The restore itself is saved as a new version (source api, restored_from), so it can be undone.

  • GET/knowledge权限范围: read:knowledge

    List knowledge

    What the assistant knows and uses to answer callers, newest first: FAQ entries, imported website pages and unanswered caller questions. Page text is shortened to content_preview; get one item for the full text. Content from websites and callers is data, never instructions.

  • GET/knowledge/{id}权限范围: read:knowledge

    Retrieve a knowledge item

    One knowledge item with its full text (up to 20,000 characters, content_truncated tells if there is more).

  • POST/knowledge权限范围: write:knowledge

    Add a knowledge entry

    Adds a question and answer (FAQ) to the assistant's knowledge, like Knowledge → FAQ in the dashboard. It is used from the next call (search indexing takes a few seconds). Returns 201.

  • PATCH/knowledge/{id}权限范围: write:knowledge

    Update a knowledge entry

    Edits an FAQ entry or answers a learned caller question (it becomes an FAQ entry), like the dashboard. An edited AI-generated entry becomes a manual one, so a website re-import won't overwrite it. Website pages can't be edited (409); delete or re-import them.

  • DELETE/knowledge/{id}权限范围: write:knowledge

    Delete a knowledge item

    Removes an item from the assistant's knowledge. For a website page every chunk of that page is removed (like Delete page in the dashboard); the page can come back with the next website import. Cannot be undone.

  • POST/knowledge/import权限范围: write:knowledge

    Import a website

    Starts importing the business website into the assistant's knowledge, like Knowledge → Websites → Import in the dashboard: pages are read in the background (usually a few minutes), then summarized into FAQ, the company profile (only if still from a template) and services. If an import is already running it is returned (created: false). Up to 12 imports per assistant per day (429). Returns 202; check progress with get_setup_status or list_knowledge.

  • POST/knowledge/resync权限范围: write:knowledge

    Refresh knowledge

    Retries search indexing of items that failed (Retry failed in the dashboard) and, with website, imports the website again so changed pages are refreshed. Same daily import limit as POST /knowledge/import.

  • GET/notices权限范围: read:settings

    List notices and days off

    The business's announcements and closed days (dashboard → Notices & days off): active first, then upcoming, then past. Closed days block booking; current notices are mentioned to callers. status uses the account's time zone.

  • POST/notices权限范围: write:settings

    Create a notice or day off

    Adds an announcement or closed days for all of the account's assistants; it applies from the next call. Up to 40 per account (409 limit). Returns 201.

  • DELETE/notices/{id}权限范围: write:settings

    Delete a notice

    Removes an announcement or days off; the assistant stops using it from the next call.

  • GET/voices权限范围: 任意密钥

    List voices

    The voice catalog the assistant can use, like the voice picker in the dashboard: name, gender, character, languages and a preview recording. Use id as voice_id in PATCH /assistants/{id}.

  • GET/setup-status权限范围: read:settings

    Get setup status

    A launch checklist built from the account's real settings: plan, the assistant's readiness to go live (company, name, voice, language, AI greeting, instructions or profile), live status, phone number, whether real inbound calls arrive (forwarding works), calendar for booking, knowledge, website import, transfer rules and the last Launch Check. Each item has status ok, missing, warning or info, whether it is required to answer calls, and how to fix it.

  • GET/website-agent权限范围: read:settings

    Get the website agent

    The AI agent on the business's website, like dashboard → Widget: the chat/voice widget (enabled, allowed domains, greeting, look, public key and the install snippet to paste before </body>) and page actions (the assistant reads the page, navigates, points at and clicks elements, fills forms and adds to the cart; allowed says whether the plan includes them), with links to the dashboard, the live demo and the paid setup service. The widget settings are created with defaults on first use.

  • PATCH/website-agent权限范围: write:settings

    Update the website agent

    Changes the website agent like saving dashboard → Widget: send only what changes. Domains are normalized (a full URL becomes its domain); enabling the widget without a domain returns 400 domains_required; enabling page actions outside the plan returns 403 plan_required (page_actions_unavailable). The public key and the look stay in the dashboard. Changes apply to new widget conversations. Returns the updated settings.

  • PATCH/phone-numbers/{id}权限范围: write:settings

    Route a phone number to an assistant

    Chooses which of the account's assistants answers calls to one of its numbers and/or sets the number's name (label, e.g. the clinic or location it belongs to); send at least one of the two. It applies from the next call: when one assistant answers several numbers or the number has a name, the assistant is told which number the caller dialled (e.g. to book at that location). Changing the assistant works only on numbers already assigned to the account (status assigned); getting or porting numbers is done in the dashboard.

权限范围

每个密钥拥有创建时选择的权限范围。权限范围之后无法更改,需要更多权限时请创建新密钥。密钥缺少所需权限范围时,端点会返回 403 insufficient_scope。GET /me、/assistants 和 /phone-numbers 可使用任何有效密钥访问。

  • read:calls读取通话、摘要和转写文本
  • read:appointments读取预约
  • write:appointments取消和改期预约
  • read:contacts读取联系人
  • write:contacts创建和更新联系人
  • read:tasks读取任务和回电请求
  • write:tasks更新任务状态
  • write:calls发起外呼电话,并查询和取消外呼
  • read:messages读取 SMS 消息和客户回复
  • write:messages向您的联系人发送 SMS
  • read:assistants读取助手的完整设置、提示词历史和语音
  • write:assistants更改助手设置、创建助手、恢复提示词版本
  • read:knowledge读取助手的知识库(常见问题、网站页面)
  • write:knowledge添加、编辑和删除知识库内容,导入网站
  • read:settings读取公告、休息日、设置清单和网站 AI 代理设置
  • write:settings管理公告和休息日,将电话号码分配给助手,配置网站 AI 代理

错误

  • 400invalid_request — 缺少参数或参数无效
  • 401unauthorized — API 密钥缺失、无效或已被吊销
  • 403insufficient_scope — 密钥缺少该端点所需的权限范围;plan_required — 账户没有有效套餐,或录音早于套餐的录音保存期限
  • 404not_found — 您的账户中不存在该对象
  • 409conflict — 时间已被占用、预约无法更改、已存在使用该电话号码的联系人,或无法发起外呼(code:opted_out、already_scheduled、assistant_not_live、over_quota、no_outbound_number、not_cancelable)
  • 429rate_limited — 请求过多;请在 Retry-After 响应头指定的时间后重试
  • 500server_error — 我们这边出现了问题
  • 503service_unavailable — 临时性问题;请在 Retry-After 响应头指定的时间后重试

完整的 API 参考(含参数和示例响应)见管理后台“开发者 → API 参考”。

Webhook

实时推送到您服务器的事件

在管理后台添加 https 端点并选择事件,一旦有事件发生,我们会立即以 POST 方式发送带签名的 JSON 数据。“发送测试”会投递您所选第一个事件的示例,便于在 Zapier 或 Make 中映射字段。

事件

  • call.completed通话已结束

    摘要、结果、情绪倾向、通话转写、联系人和预约;外呼通话还包含序列或 API 请求(callback_id、external_id、outreach)。

  • call.started通话开始

    通话已接听(呼入、外呼或网页通话)。

  • appointment.booked预约成功

    助手已创建一个预约。

  • appointment.canceled预约已取消

    预约已通过电话或 API 取消。

  • appointment.rescheduled预约已改期

    预约已改到新的时间(包含原时间)。

  • task.created已创建回电 / 任务

    来电者请求回电或留下了任务。

  • contact.created新联系人

    首次来电者已保存为联系人。

  • outbound_call.finished外呼通话已结束

    计划中的外呼(API、新客引导序列或回电)已完成或失败——所有尝试后仍无人接听时同样会触发。

每次投递的请求头

  • Telofia-Signature签名:t=<unix 时间>,v1=<HMAC-SHA256 hex>
  • Telofia-Event事件类型,例如 appointment.booked
  • Telofia-Delivery唯一投递 ID
  • User-AgentTelofia-Webhooks/1.0 · 标识我们的 Webhook 发送方

投递与重试

  • 请在 10 秒内返回任意 2xx 状态码。不会跟随重定向。
  • 投递失败后将在 1 分钟、5 分钟、30 分钟、2 小时、6 小时和 12 小时后重试(共 7 次,约 21 小时)。
  • 同一事件可能重复送达。请使用事件 id 去重。
  • 仅接受公开的 https 地址。连续失败 50 次后,端点将被暂停,管理后台会说明原因。
  • 管理后台保存带状态码和响应的投递日志,并支持手动重试投递。
投递示例:call.completed
{
  "id": "evt_3f9a1c7e5b2d4f6a8c0e1b3d5f7a9c1e",
  "type": "call.completed",
  "created_at": "2026-10-01T09:17:45Z",
  "account_id": "1f2e3d4c-5b6a-4789-8a7b-6c5d4e3f2a1b",
  "data": {
    "id": "5b1f0c6e-2a8d-4f3e-9d51-7c0a4e2b9f10",
    "object": "call",
    "assistant_id": "0e6f4c8a-3b2d-4a1e-8f7c-5d9b2a1c3e4f",
    "phone_number_id": "4d3c2b1a-0f9e-4d8c-b7a6-958473625140",
    "contact_id": "9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
    "direction": "inbound",
    "status": "completed",
    "from": "+48601234567",
    "to": "+48221234567",
    "started_at": "2026-10-01T09:14:03Z",
    "ended_at": "2026-10-01T09:17:41Z",
    "duration_sec": 218,
    "summary": "Anna Kowalska booked a first consultation for Friday 10:00.",
    "outcome": "booked",
    "sentiment": "positive",
    "tags": [
      "new-customer"
    ],
    "has_recording": true,
    "end_reason": "caller_hangup",
    "page_url": null,
    "page_title": null,
    "continued_from": null,
    "intake": [
      {
        "key": "address",
        "label": "Adres",
        "value": "ul. Lipowa 5, Katowice"
      }
    ],
    "callback_id": null,
    "external_id": null,
    "outreach": null,
    "callback_return": false,
    "caller_spoke": true,
    "caller_words": 6,
    "transcript": [
      {
        "role": "caller",
        "text": "I'd like to book a consultation this week.",
        "at": 4.1
      }
    ],
    "contact": {
      "id": "9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
      "object": "contact",
      "phone": "+48601234567",
      "name": "Anna Kowalska",
      "name_source": "call",
      "email": "anna.kowalska@example.com",
      "email_source": "call",
      "notes": null,
      "tags": [
        "customer"
      ],
      "blocked": false,
      "calls_count": 3,
      "last_call_at": "2026-10-01T09:14:03Z",
      "created_at": "2026-08-12T15:02:11Z"
    },
    "appointments": [
      {
        "id": "c3d2e1f0-a9b8-4c7d-8e6f-5a4b3c2d1e0f",
        "object": "appointment",
        "call_id": "5b1f0c6e-2a8d-4f3e-9d51-7c0a4e2b9f10",
        "contact_id": "9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
        "customer_name": "Anna Kowalska",
        "customer_phone": "+48601234567",
        "customer_email": "anna.kowalska@example.com",
        "service": "First consultation",
        "starts_at": "2026-10-03T08:00:00Z",
        "ends_at": "2026-10-03T08:30:00Z",
        "status": "booked",
        "external_id": "google:7h3k9s2l1m0n",
        "notes": "Allergic to nuts",
        "arrival_window_start": null,
        "arrival_window_end": null,
        "arrival_window_label": null,
        "created_at": "2026-10-01T09:16:20Z"
      }
    ]
  }
}

验证签名. 每次投递都包含 Telofia-Signature 请求头,格式为 t=timestamp,v1=signature。请使用您的签名密钥对“timestamp.raw_body”计算 HMAC-SHA256,并与 v1 比较。请拒绝时间戳早于 5 分钟的请求。

Node.js · 验证签名
import crypto from "node:crypto";

// Express: app.post("/webhook", express.raw({ type: "application/json" }), handler)
export function verify(rawBody, signatureHeader, secret) {
  // Telofia-Signature: t=1727774265,v1=5f2c…
  const parts = Object.fromEntries(signatureHeader.split(",").map((p) => p.split("=")));
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  const given = Buffer.from(parts.v1 ?? "");
  // timingSafeEqual needs buffers of the same length
  return fresh && given.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), given);
}
Python · 验证签名
import hmac, hashlib, time

def verify(raw_body: bytes, signature_header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in signature_header.split(","))
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw_body, hashlib.sha256).hexdigest()
    fresh = abs(time.time() - int(parts["t"])) < 300
    return fresh and hmac.compare_digest(expected, parts.get("v1", ""))
接收端示例(Express)
import express from "express";
import { verify } from "./verify.js";

const app = express();
const seen = new Set(); // use your database in production

app.post("/telofia/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const raw = req.body.toString("utf8");
  if (!verify(raw, req.get("Telofia-Signature") ?? "", process.env.TELOFIA_WEBHOOK_SECRET)) return res.sendStatus(401);

  const event = JSON.parse(raw);
  if (seen.has(event.id)) return res.sendStatus(200); // retried delivery, already handled
  seen.add(event.id);

  if (event.type === "appointment.booked") {
    const a = event.data;
    console.log("New booking:", a.customer_name, a.service, a.starts_at);
  }
  res.sendStatus(200); // answer with 2xx within 10 seconds
});

app.listen(3000);

稳定值

通话(API 和 call.* Webhook)以及外呼(outbound_call.finished、/calls/outbound)中的这些值是稳定的约定:我们可能新增值,但不会更改或删除这些值。未接听、占线或被拒绝的外呼尝试不会生成通话,因此不会有 call.completed:最后一次尝试后,您会收到 last_error 为 no_answer 的 outbound_call.finished。由语音信箱接听的通话视为已接听(通常是结果为 other 的短通话)。

通话状态

in_progress
通话进行中。
completed
对方与助手进行了通话。
missed
无人说话,或助手无法接听(见 end_reason)。
failed
因出错,通话无法处理。

通话结果

booked
已预约。
transferred
通话已转接给真人。
message
已记录留言、回电请求、订单或待跟进事项。
info
对方已获得所需信息,无需其他操作。
spam
垃圾电话、电话营销或已屏蔽的号码。
other
其他情况,例如非常短的通话或语音信箱。
order
对话中记录了一笔订单(例如商店购物车);购买尚未确认。由数据库根据“order”任务设置。
purchase
已确认的成交:客户在对话后完成了购买(商店网站上的购买、POST /v1/conversions),或支付了通话中产生的付款。优先于其他结果,即使购买发生在通话数天之后。

通话结束原因(end_reason)

caller_hangup
对方挂断了电话。
caller_hangup_greeting
外呼通话:对方在问候语期间或刚结束时就挂断,未说一句话(通话不超过 45 秒)。此时 caller_spoke 为 false。
agent_hangup
助手道别后结束了通话。
transferred
通话已转接给真人。
silence
长时间沉默后结束。
max_duration
已达到最长通话时长。
spam
已作为垃圾电话结束。
blocked
该号码已在联系人中被屏蔽。
busy
账户的所有线路都处于占线状态。
over_quota
通话分钟数已用完。
trial_expired
免费试用已结束。
inactive
没有有效套餐。
assistant_not_live
助手已暂停。
no_assistant
没有助手接听此号码。
ai_budget
因临时限制,通话未使用 AI 处理;已通知团队回电。
error
技术错误导致通话结束。

外呼状态

scheduled
等待到预定时间(或下一次尝试)。
dialing
正在拨号。
done
已接听;call_id 指向该对话。
failed
所有尝试后仍未接听,或无法拨出(见 last_error)。
canceled
已取消(通过 API、该联系人已从序列中移除,或序列已关闭)。

外呼 last_error

no_answer
无人接听(包括占线或被拒绝)。
failed
拨打时助手不可用(套餐、分钟数或已暂停)。
no_result
15 分钟内没有通话结果。
expired
通话延迟超过 2 小时,因此未拨出。
outside_window
已顺延到下一个通话时段(状态仍为 scheduled)。
dial_error
电话网络拒绝了该通话(以 dial_<reason> 形式发送)。
over_quota
通话分钟数已用完。
inactive
没有有效套餐。
assistant_not_live
助手已暂停。
no_outbound_number
没有可用于外呼的企业号码。
canceled_by_api
已通过 DELETE /calls/outbound/{id} 取消。
unenrolled
该联系人已从序列中移除(POST /api/outreach/unenroll)。
opt_out
对方要求不要再给他来电。
replaced
已被发往同一号码的较新回电替代。
voicemail
通话转到了语音信箱;该步骤最早在 3 天后重试。
greeting_hangup
对方在问候语期间未说话就挂断了;该步骤将重试。

通过 MCP 获取实时数据

让助手在通话中查询您系统里的数据

连接远程 MCP 服务器(Model Context Protocol),例如您的商品目录、库存、预约或订单系统。助手可使用哪些只读工具和资源,完全由您决定。

提前学习

适用于很少变化的内容,如价目表、产品说明或政策条款。所选资源和只读工具会每隔 1 至 168 小时或按需导入助手的知识库。通话中无延迟。

通话中实时查询

适用于会变化的内容:库存、可预约时间、订单状态。助手在对话中调用工具,并先说一句“请稍等,我查一下”。如果您的服务器约 2.5 秒内未响应,助手会表示目前无法确认,并提出由您的团队跟进。

您需要准备

  • 可通过 https 访问的 MCP 服务器(Streamable HTTP,例如 https://mcp.example.com/mcp;较旧的 HTTP+SSE 服务器会自动识别)。
  • 认证方式:无、Bearer 令牌或自定义请求头(如 X-API-Key)。密钥经加密(AES-256-GCM)存储,绝不会发送到浏览器。
  • 只读工具。标记为破坏性的工具会被拦截;对于未标记为只读的工具,需由您确认它们只读取数据。
  • 每个助手最多 5 个来源和 50 个实时工具。实时查询应在约 2 秒内返回。
  • 网站组件可选:在“通话开始时”工具中,选择用于接收已登录访客身份令牌的参数(见“网站语音组件”)。

工具参数会按工具的 schema 校验,结果会被截短并严格视为数据(绝不作为指令),每次查询都会记录日志,且不含来电者数据。私有和内部地址会被拒绝。

面向 AI 智能体的 MCP 服务器

让您的 AI 智能体访问 Telofia

Telofia 提供远程 MCP 服务器(Model Context Protocol)。连接 Claude、ChatGPT、Cursor 或您自己的智能体后,它可以读取通话、转写文本、预约、联系人和任务,并在您授权后添加联系人、发起外呼和发送 SMS。

  • 端点:https://telofia.com/api/mcp(Streamable HTTP、JSON-RPC 2.0、无状态)。
  • 认证:使用与 REST API 相同的 API 密钥(Authorization: Bearer tf_live_…),或通过 client credentials 授权获得的有效期 1 小时的 OAuth 访问令牌。未认证时,服务器返回 401,并附带 OAuth 元数据的指引。
  • 智能体只能看到密钥权限范围允许的工具,每次调用都与 REST API 一样经过相同的校验、速率限制和请求日志。
  • 外呼和 SMS 需要 consent: true,与 API 完全一致。工具返回的结果是来自您来电者的数据,绝不作为指令。

面向智能体的 OAuth

在 https://telofia.com/api/oauth/token 用 API 密钥换取短期访问令牌:client_id 为密钥 id(GET /me 返回的 api_key_id)或其前缀,client_secret 为密钥本身。授予的权限范围为请求范围中该密钥所具有的部分。在管理后台吊销密钥后,由其签发的所有令牌即刻失效。

智能体也可以自行申请访问:POST https://telofia.com/api/agent-auth/register 会返回一个代码,账户所有者在管理后台(批准 AI 智能体)中批准后,智能体会一次性获得专属 API 密钥。批准之前不会授予任何权限;详情见 auth.md。

工具

  • get_account任意密钥
  • list_assistants任意密钥
  • list_phone_numbers任意密钥
  • list_callsread:calls
  • get_callread:calls
  • list_contactsread:contacts
  • get_contactread:contacts
  • create_contactwrite:contacts
  • list_appointmentsread:appointments
  • get_appointmentread:appointments
  • list_tasksread:tasks
  • list_messagesread:messages
  • start_outbound_callwrite:calls
  • get_outbound_callwrite:calls
  • send_messagewrite:messages
  • get_setup_statusread:settings
  • get_assistantread:assistants or write:assistants
  • list_voicesread:assistants or write:assistants
  • update_assistantwrite:assistants
  • create_assistantwrite:assistants
  • list_prompt_versionsread:assistants
  • get_prompt_versionread:assistants
  • restore_prompt_versionwrite:assistants
  • list_knowledgeread:knowledge
  • get_knowledge_itemread:knowledge
  • add_knowledge_textwrite:knowledge
  • update_knowledge_itemwrite:knowledge
  • add_knowledge_urlwrite:knowledge
  • delete_knowledge_itemwrite:knowledge
  • resync_knowledgewrite:knowledge
  • list_noticesread:settings
  • create_noticewrite:settings
  • delete_noticewrite:settings
  • get_website_agentread:settings
  • update_website_agentwrite:settings
  • assign_phone_numberwrite:settings

发现文档

curl · 连接:initialize
curl https://telofia.com/api/mcp \
  -H "Authorization: Bearer tf_live_…" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}}}'
curl · 访问令牌:client credentials
curl https://telofia.com/api/oauth/token \
  -u "<api_key_id>:tf_live_…" \
  -d grant_type=client_credentials \
  -d scope="read:calls read:contacts"

网站语音组件

一行代码,把助手放到您的网站上

访客点击按钮,即可在浏览器中与接听您电话的同一个助手通话。网页通话消耗您的套餐分钟数,无需电话通信费用。

Office 起

  • 约 21 KB,无依赖,隔离在 Shadow DOM 中,您网站的样式不会影响它。
  • 使用页面语言(<html lang>)或您通过 data-lang="de" 指定的语言。
  • 实时字幕;若麦克风被禁用,访客可输入文字,助手以语音回答。
  • 可将组件限制在您自己的域名,仅在这些网站上启动。
嵌入代码(密钥可在管理后台找到)
<script src="https://telofia.com/widget.js" data-key="tfw_…" async></script>
JavaScript API
// optional: open the widget from your own button
document.querySelector("#talk-to-us").addEventListener("click", () => window.TelofiaWidget?.open());
// open and start right away: { mode: "voice" } or { mode: "chat" } (text only, no microphone)
window.TelofiaWidget?.open({ mode: "chat" });

window.TelofiaWidget?.close();   // close the panel
window.TelofiaWidget?.destroy(); // remove the widget from the page

使用了严格的内容安全策略(CSP)?请允许 script-src https://telofia.com https://cdn.jsdelivr.net、connect-src https://telofia.com wss://*.livekit.cloud https://*.livekit.cloud 以及 media-src blob:。

已登录用户(身份令牌)

访客在您的网站上已登录时,助手无需询问邮箱即可知道对方是谁。

  • 由您的服务器为已登录用户签发短期有效的签名令牌(例如 HMAC,有效期 15 分钟)。切勿在浏览器中放置邮箱地址或用户 ID:任何人都可以在控制台中输入他人的信息。
  • 随时调用 TelofiaWidget.identify({ token });再次调用会替换令牌,identify(null) 会清除令牌。在 widget.js 加载之前,可设置 window.TelofiaIdentity = { token, expires_at }:它会在对话开始时被读取,已过期的令牌会被忽略。
  • 在管理后台中,为任意实时 MCP 工具选择身份令牌参数——可以是查询类、执行操作类,或您的“通话开始时”工具。Telofia 只会将令牌原样传给该参数,绝不存储或显示,也不会出现在转写文本、摘要、Webhook 和日志中;助手也看不到它。
  • 8 至 400 个字符:字母、数字及 . _ ~ + / = -(例如 base64url)。请在过期前刷新,例如每 10 分钟一次。由您的 MCP 服务器验证;无效或过期的令牌应得到与无令牌相同的结果。电话通话和不带令牌的对话照常工作。
身份令牌
// signed-in user: a short-lived, signed token issued by YOUR server (never an e-mail or user ID)
const { token, expires_at } = await fetch("/api/telofia-identity").then((r) => r.json());

window.TelofiaIdentity = { token, expires_at };       // read when the conversation starts, also before widget.js loads
window.TelofiaWidget?.identify({ token, expires_at }); // replaces the token at any time

// refresh before it expires (e.g. every 10 minutes); on sign-out:
window.TelofiaIdentity = null;
window.TelofiaWidget?.identify(null);

聊天模式与自定义按钮

从您自己的界面——按钮、菜单或 3D 场景中的前台——以语音或文字聊天方式打开助手。

  • data-launcher="none" 会隐藏悬浮按钮:面板只能通过您的代码调用 TelofiaWidget.open() 打开,并通过 close() 关闭。焦点会回到原来的位置(例如您的游戏 canvas)。close() 只是隐藏面板,对话会继续;TelofiaWidget.endCall() 或 close({ end: true }) 才会结束对话(组件保留)。
  • open({ mode: "voice" }) 或 open({ mode: "chat" }) 会打开面板并立即开始对话。data-mode="chat" 会将聊天设为开始按钮的默认模式。
  • 聊天模式从不请求麦克风:访客输入文字,助手以文字回复。助手相同,知识和工具也相同。
  • 所有方法在组件加载完成前即可调用:调用会进入队列,待组件就绪后执行。即使在 widget.js 加载之前,也可以将它们加入 window.TelofiaWidget = { q: [["open", { mode: "chat" }]] }。
自定义按钮与聊天模式
<!-- no floating button: the panel opens only from your code -->
<script src="https://telofia.com/widget.js" data-key="tfw_…" data-launcher="none" data-mode="chat" async></script>

<script>
  // calls made before widget.js has loaded are queued and run when it starts
  window.TelofiaWidget = window.TelofiaWidget || { q: [] };
  const telofia = (method, ...args) =>
    window.TelofiaWidget.q ? window.TelofiaWidget.q.push([method, ...args]) : window.TelofiaWidget[method](...args);

  // e.g. the reception desk in your 3D gallery
  document.querySelector("#talk").addEventListener("click", () => telofia("open", { mode: "voice" })); // asks for the microphone
  document.querySelector("#chat").addEventListener("click", () => telofia("open", { mode: "chat" }));  // text only, no microphone

  // later:
  // TelofiaWidget.close();   hide the panel (the conversation continues)
  // TelofiaWidget.isOpen();  true | false
  // TelofiaWidget.state();   { ready, open, mode, call: "idle" | "connecting" | "active", agent_state }
  // TelofiaWidget.init({ launcher: false, mode: "chat", lang: "de" }); // the same options in code
</script>

事件

在您的页面上响应对话——助手说话时让头像动起来、显示您自己的聊天气泡,或记录通话。

  • 每个事件都是名为 telofia:<name> 的 window CustomEvent,也可以通过 TelofiaWidget.on(name, fn) / off(name, fn) 监听。
  • ready { key, assistant, available } · open · close · call_started { mode, roomName } · call_ended { reason } · agent_state { state: listening | thinking | speaking } · error { code }
  • speaking { speaking, level }:助手声音的强度,范围 0 到 1,说话时每秒最多 20 次,speaking 每次变化时也会触发——即使访客偏好减少动态效果。
  • message { role: agent | user, text, final, id }:文本逐步到达(final: false)和完整文本(final: true),用于您自己的聊天界面。tool:见下方的页面端工具。一次发言 = 一个 id:同一 id 会收到多个事件,最终文本带 final: true——请按 id 合并。
通过 telofia:speaking 驱动头像动画
const avatar = document.querySelector("#receptionist");

// { speaking: boolean, level: 0..1 } — up to 20 times per second while the assistant speaks
window.addEventListener("telofia:speaking", (e) => {
  avatar.classList.toggle("talking", e.detail.speaking);
  avatar.style.setProperty("--mouth", e.detail.level); // e.g. scale the mouth or a glow
  // Unity WebGL: unityInstance.SendMessage("Receptionist", "SetVoiceLevel", e.detail.level);
});

// the same events through the widget API (name with or without the "telofia:" prefix)
TelofiaWidget.on("call_started", ({ mode, roomName }) => console.log("started", mode, roomName));
TelofiaWidget.on("call_ended", ({ reason }) => console.log("ended", reason)); // user | disconnected | …
TelofiaWidget.on("agent_state", ({ state }) => console.log(state));           // listening | thinking | speaking
TelofiaWidget.on("message", ({ role, text, final }) => final && console.log(role, text)); // your own chat UI
TelofiaWidget.on("error", ({ code }) => console.warn("Telofia:", code));      // rate_limited, assistant_offline, …

页面上下文

告诉助手访客所在的位置——正在浏览哪个展厅、门店或产品——这样助手无需追问即可回答。

  • TelofiaWidget.setContext({ … }) 或在 script 标签上使用 data-context='{"gallery":"POL"}';setContext(null) 会清除上下文。对话期间,新的上下文会连同当前页面地址和标题立即传给助手(无刷新跳转后同样如此);否则将用于下一次对话。
  • 最多 20 个键(小写字母、数字和 _,须以字母开头);值:不超过 200 个字符的文本、数字或 true/false,总计最多 2000 字节。无效的上下文会被忽略并在控制台给出警告,保留之前的上下文。
  • 在助手指令中使用 {{context.gallery}}、{{context.store}} 等;助手也会将上下文视为关于页面的信息。
  • 您的 MCP 服务器会在 Telofia-Context 请求头中收到它(紧凑 JSON,非 ASCII 字符以 \uXXXX 表示,最多 1000 字节——超出时只保留能放下的键,优先保留 secret_ 开头的键),与 Telofia-Call-Id 并列。请将其视为不可信输入:它由访客的浏览器设置。以 secret_ 开头的键(如 secret_session)只会发送到您的 MCP 服务器:助手看不到它们,它们不会被存储、记录或显示,如果您的服务器回传其中某个键,会被替换为 [secret]。
页面上下文
// what the visitor is looking at; used by the next conversation
TelofiaWidget.setContext({ gallery: "POL", store: "Lumi Shoes", floor: 2, logged_in: true });
TelofiaWidget.setContext(null); // clear

// or on the script tag: data-context='{"gallery":"POL"}'

// assistant instructions:
//   The visitor is in gallery {{context.gallery}}, at the store {{context.store}}.

// every live lookup on your MCP server during that conversation carries:
//   Telofia-Call-Id: 5b1f0c6e-…
//   Telofia-Context: {"gallery":"POL","store":"Lumi Shoes","floor":2,"logged_in":true}
// (non-ASCII as \uXXXX — JSON.parse restores it; set by the visitor's browser, so treat it as untrusted)

页面端工具

让助手在访客的浏览器中执行操作——展示店铺、打开商品、查看购物车——通过您在页面上注册的函数实现。

  • TelofiaWidget.registerTools([...]):最多 10 个工具,包含 name(小写字母、数字、_)、description(功能及使用时机,最多 500 个字符)以及 parameters(object 类型的 JSON Schema,最多 4000 字节)。该列表对下一次对话生效。
  • 当助手调用工具时,将运行您的 handler(args, { waitForUser })(可返回值或 Promise),并触发 telofia:tool 事件,其中包含 name、args、respond(result)、reject(error) 和 waitForUser()。以第一个答复为准。
  • 请在 9 秒内答复,否则助手会得知工具未响应。如果操作需要访客参与(例如确认付款),请先调用 waitForUser():助手会告知正在等待,您最多有 29 秒。结果最大为 15,000 字节的 JSON;未知工具会被拒绝。
  • 参数由 AI 模型生成:请像对待任何用户输入一样进行校验,凡需访客确认的操作,切勿在未征得确认的情况下执行。
页面端工具
TelofiaWidget.registerTools([
  {
    name: "show_store",
    description: "Moves the visitor's view to a store in the gallery. Use it when they ask where a store is.",
    parameters: { type: "object", properties: { store_id: { type: "string" } }, required: ["store_id"] },
    // runs in the visitor's browser; the returned value (or Promise) goes back to the assistant
    handler: async ({ store_id }) => {
      await gallery.flyTo(String(store_id)); // your code — validate arguments like any user input
      return { shown: true };
    },
  },
  { name: "cart_count", description: "Number of items in the visitor's cart.", parameters: { type: "object", properties: {} } },
]);

// or answer from an event listener — the first answer wins; no answer within 9 s = "timeout"
window.addEventListener("telofia:tool", (e) => {
  const { name, args, respond, reject } = e.detail;
  if (name === "cart_count") respond({ items: cart.length });
});

同一页面上的多个助手

每个助手都有自己的小组件密钥。无需刷新页面即可在它们之间切换——例如在总前台与某家店铺专属助手之间切换。

  • TelofiaWidget.switchTo({ key }) 会结束当前对话,移除小组件,并使用另一个密钥重新启动;紧随其后调用的 open() 会等到新助手就绪。上下文(setContext)、工具(registerTools)和监听器(on)会保留,无需重新注册;如果另一个助手需要不同的上下文(例如 place),只需更改上下文即可。
  • 您的事件监听器、页面上下文和工具都会保留;每个密钥各自保存对话恢复状态。请将您的域名添加到每个密钥的允许域名中。
  • TelofiaWidget.destroy() 会彻底移除小组件:包括界面、监听器、对话以及已保存的恢复状态。
切换助手
const RECEPTION = "tfw_…"; // widget key of the gallery reception
const STORE = "tfw_…";     // widget key of a store's own assistant

document.querySelector("#store-desk").addEventListener("click", () => {
  TelofiaWidget.switchTo({ key: STORE }); // ends the conversation, reloads the widget with the other assistant
  TelofiaWidget.open({ mode: "voice" });  // queued until the new assistant is ready
});

TelofiaWidget.on("ready", ({ key, assistant }) => console.log("now:", assistant, key === RECEPTION ? "reception" : "store"));

TelofiaWidget.destroy(); // remove the widget completely (interface, listeners, conversation, resume state)

电话引导设置

新客户注册后,自动收到欢迎电话

当有人在您的系统中注册时,将其加入外呼序列。助手会使用您的企业号码致电,帮助对方上手,并在几天后再次回访。电话会在序列的外呼时段内拨出:默认为周一至周六,按您所在时区的 9:00 至 20:00,也可按您设定的日期和时段执行。

POST/api/outreach/enroll

使用控制台中的序列密钥(tlo_…)进行身份验证,可作为 Bearer 令牌,或放在 X-Telofia-Key 请求头中。每个序列都有各自的密钥。

请求体

  • phonestring必填
    电话号码,建议使用 E.164 格式。国内号码将按您账户所在国家/地区的区号解析。
  • consenttrue必填
    必须为 true:此人已同意接听电话联系,例如在您的注册表单中。
  • namestring选填
    姓名,最多 120 个字符。
  • emailstring选填
    电子邮箱地址。
  • contextstring选填
    助手需要了解的此人信息,最多 1,000 个字符(例如其所选套餐)。
  • external_idstring | number选填
    此人在您系统中的 ID(字符串或数字)。相同 ID 只会登记一次。
curl
curl -X POST "https://telofia.com/api/outreach/enroll" \
  -H "Authorization: Bearer tlo_…" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+48601234567","name":"Anna Kowalska","email":"anna@example.com","context":"Signed up today, Start plan","external_id":"user_123","consent":true}'
201 Created
{
  "ok": true,
  "enrollment_id": "8f7e6d5c-4b3a-4c2d-9e1f-0a9b8c7d6e5f",
  "external_id": "user_123",
  "status": "active",
  "next_call_at": "2026-10-09T10:20:00Z",
  "limits": {
    "per_day": 500,
    "remaining_today": 499
  }
}

回复

  • 201:已登记。enrollment_id、external_id、status、next_call_at(首次通话时间)、intro_sms_at(首次通话前短信的发送时间,或 null)以及 limits { per_day, remaining_today }
  • 200:已登记过(external_id 相同,或该号码在此序列中正在进行),并带有 duplicate: true
  • 400:invalid_request、invalid_phone 或 consent_required
  • 401: invalid_key
  • 409:sequence_disabled、consent_missing 或 opted_out(此人要求不再接听电话)
  • 429:limit,已达到序列的每日登记上限(每 24 小时 500 位新用户;响应体中包含 limit)。rate_limited:使用此密钥每分钟请求超过 120 次(见 Retry-After 响应头)

外呼时段:在控制台中为每个序列设置日期和 7:00 至 21:00 之间的时间范围。如果无人接听,助手会在这些时段内最多尝试 3 次,每次间隔 2 小时。

通话前短信:序列中启用该功能后(在控制台中设置),对方会收到一条来自助手外呼号码的简短短信,默认在首次通话前 20 分钟发送(5–120 分钟)。如果首次通话时间更早,则会顺延,以确保短信始终先发出,且在外呼时段内。短信发送失败(对方回复了 STOP、短信额度已用完)绝不会阻止通话。每条短信都计入您的短信额度,并显示在控制台的“短信”中。

问候语:在控制台中,您可以为每个步骤(或整个序列的默认设置)设定通话的第一句话——可以是固定文本,可使用变量 {first_name}、{first_name_vocative}(波兰语呼格,例如 Krystianie)、{assistant_name}、{brand}(助手设置中通话所用的公司名称)和 {name},并可为没有姓名的注册设置单独版本——也可以选择由助手根据姓名、上下文、该步骤目标以及“通话开始时”工具的结果自行组织第一句话。如果文本中没有说明,系统始终会在第一句话中加上这是 AI 助手来电以及通话会被录音的告知。

将某人移出序列

POST/api/outreach/unenroll

当某人不再需要电话时(例如完成首单后,或已取消),请使用同一密钥停止其序列。已安排的通话会立即取消。正在进行的通话不会被中断,但之后不会再有后续通话。

  • external_id | enrollment_id | phone必填
    以下三者中恰好提供一个:external_id(与登记时发送的一致)、enrollment_id(来自登记响应)或 phone。
  • reason选填
    可选的原因,最多 200 个字符,会记录在您账户的审计日志中。
  • 200:已停止(changed: true),或已结束:status 为 stopped、completed 或 failed(changed: false)。可安全重复调用。
  • 400:invalid_request(未提供标识符或提供了多个)或 invalid_phone
  • 401: invalid_key
  • 404:not_found,此序列中没有该登记记录
  • 429: rate_limited
curl
curl -X POST "https://telofia.com/api/outreach/unenroll" \
  -H "Authorization: Bearer tlo_…" \
  -H "Content-Type: application/json" \
  -d '{"external_id":"user_123","reason":"first_sale"}'
200 OK
{
  "ok": true,
  "enrollment_id": "8f7e6d5c-4b3a-4c2d-9e1f-0a9b8c7d6e5f",
  "external_id": "user_123",
  "status": "stopped",
  "changed": true
}

Webhook 中的通话结果

来自序列的通话,其 call.started 和 call.completed 包含 callback_id、external_id 和 outreach { sequence_id, enrollment_id, external_id, step }(呼入通话中这些值均为 null)。未接通的尝试不会生成通话,因此没有 call.completed:最后一次尝试后,您会收到 status 为 failed、last_error 为 no_answer 的 outbound_call.finished。同一步骤的重试算作一个结果。call.completed 还包含 caller_spoke 和 caller_words(对方说了多少个词)。如果对方接听后在问候语期间或刚结束时一言不发就挂断,end_reason 为 caller_hangup_greeting。如果对方在我们尝试致电后的 3 天内回拨企业号码,该呼入通话会带有 callback_return: true,并具有与其所回拨通话相同的 callback_id、external_id 和 outreach。来自网站小组件的通话,direction 为 widget,并带有 page_url 和 page_title(通话所在页面)以及 continued_from(页面刷新后的上一段通话);控制台中的浏览器测试,direction 为 web。通话期间发往您 MCP 服务器的每个请求都带有 Telofia-Call-Id 请求头(与通话 ID 相同),电话通话中还带有 Telofia-Caller,序列或 API 发起的通话中带有 Telofia-Outreach-External-Id。

序列通话的 call.completed
{
  "id": "5b1f0c6e-2a8d-4f3e-9d51-7c0a4e2b9f10",
  "object": "call",
  "assistant_id": "0e6f4c8a-3b2d-4a1e-8f7c-5d9b2a1c3e4f",
  "phone_number_id": "4d3c2b1a-0f9e-4d8c-b7a6-958473625140",
  "contact_id": "9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
  "direction": "outbound",
  "status": "completed",
  "from": "+48732127980",
  "to": "+48601234567",
  "started_at": "2026-10-01T09:14:03Z",
  "ended_at": "2026-10-01T09:17:41Z",
  "duration_sec": 218,
  "summary": "Jan added the company name and tax ID; asked for a call tomorrow at 10:00 about payments.",
  "outcome": "message",
  "sentiment": "positive",
  "tags": [],
  "has_recording": true,
  "end_reason": "agent_hangup",
  "page_url": null,
  "page_title": null,
  "continued_from": null,
  "intake": [
    {
      "key": "address",
      "label": "Adres",
      "value": "ul. Lipowa 5, Katowice"
    }
  ],
  "callback_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "external_id": "crm-evt-1842",
  "outreach": {
    "sequence_id": "11111111-1111-4111-8111-111111111111",
    "enrollment_id": "8f7e6d5c-4b3a-4c2d-9e1f-0a9b8c7d6e5f",
    "external_id": "crm-evt-1842",
    "step": 1
  },
  "callback_return": false,
  "caller_spoke": true,
  "caller_words": 112
}

日历、CRM 与自动化

无需编码的连接器

  • Google Calendar

    助手会查看真实空闲情况,并在您的日历中预约、改期和取消预约。仅读取忙碌时段,绝不读取事件标题。

  • Zapier、Make 和 n8n

    控制台中提供分步指南。基于 Webhook 和 API 构建,所有套餐均包含。

套餐与限额

您需要哪种套餐

按账户设置的限额:每分钟请求数(同样按密钥计算,滑动窗口)和每日请求数(UTC)。超出限额时,您会收到 429 rate_limited 及 Retry-After 响应头。

套餐请求数 / 分钟请求数 / 天API 密钥Webhook
免费试用(测试权限)201,00011
Line302,00022
Desk6010,00055
Office18050,0001010
Network600200,0002520

网站语音小组件:自 Office 套餐起提供。

需要更高的限额?请联系我们,我们可为您的账户提高限额。

抢先体验:成为最早让 AI 接电话的企业之一。

准备好开始对接了吗?

开始免费试用,创建测试 API 密钥,几分钟内即可发送第一个请求。所有套餐均包含 API,自 Line 起。