---
title: "无代码工作流 Handoff"
description: "将 Twexapi MCP AI Agent结果导入 n8n、Zapier、Make 与 Pipedream。"
---

多数无代码平台不必自行运行 MCP 会话。可靠模式是：由具备 MCP 能力的AI Agent采集数据，再将结构化 JSON handoff 给工作流。

## 前置条件

- Twexapi API 密钥
- 已连接 `https://api.twexapi.io/mcp` 的 MCP  capable AI Agent或框架
- 来自 n8n、Zapier、Make、Pipedream 或内部工作流运行器的 webhook URL
- 目标系统，如 Sheets、Airtable、Notion、Slack、CRM 或数据库

## 推荐流程

1. **通过支持 MCP 的 Agent 采集数据**

    使用 Claude Code、Cursor、Codex CLI、LangChain、Pydantic AI 或其他已连接 `https://api.twexapi.io/mcp` 的 MCP 客户端。

2. **返回规范化严格 JSON**

    要求AI Agent返回含 ID、游标、路由名与行的稳定 schema。

3. **推送至无代码平台**

    将 JSON POST 到 n8n、Zapier、Make、Pipedream 或内部工作流运行器的 webhook。

4. **按需通过 REST API 补充数据**

    定时或大批量作业可用 `Authorization: Bearer YOUR_API_KEY` 直接调用 Twexapi REST。

## 可复制粘贴的AI Agent prompt

```txt
Use Twexapi MCP to search recent X/Twitter posts about "AI agents".
Call explore first, then twexapi_request.
Return only valid JSON with:
{
  "route_used": "...",
  "query": "AI agents",
  "has_more": true,
  "next_cursor": "...",
  "tweets": [
    {
      "tweet_id": "...",
      "author_username": "...",
      "created_at": "...",
      "text": "...",
      "like_count": 0,
      "reply_count": 0,
      "retweet_count": 0
    }
  ]
}
Do not call write endpoints.
```

## 工作流映射

| JSON 字段 | 常见目标 |
| --- | --- |
| `tweet_id` | 数据库主键、去重键、CRM 备注引用 |
| `author_username` | CRM 账号字段、Slack 消息标签 |
| `created_at` | 排序键与报告时间戳 |
| `next_cursor` | 下次定时运行的工作流状态 |
| `route_used` | 审计日志与调试字段 |

## 结果 handoff

保持工作流载荷小而稳定。除非另行归档，勿将完整原始响应传给 Slack 消息、CRM 备注或电子表格行。

| 行类型 | 必填字段 |
| --- | --- |
| 推文搜索 | `tweet_id`、`text`、`author_username`、`created_at`、`public_url`、`route_used` |
| 资料查询 | `user_id`、`username`、`name`、`description`、`followers_count`、`verified` |
| 趋势行 | `name`、`rank`、`query`、请求的 `country`、请求的 `topic` |
| 分页 | `has_more`、`next_cursor`、原始查询或源 ID |
| 写计划 | `action`、`endpoint`、`preview`、`requires_human_confirmation` |

## 配方：AI Agent研究到 webhook

1. 将 AI Agent连接到 Twexapi MCP。
2. 用上述 prompt 要求严格 JSON。
3. 将 JSON POST 到工作流 webhook。
4. 用工作流工具的迭代或循环步骤遍历 `tweets`。
5. 按 `tweet_id` upsert 行。

## 配方：定时续跑

每日作业：首次运行由AI Agent辅助，后续运行保持确定性：

1. 存储 `route_used`、请求参数与 `next_cursor`。
2. 用 `Authorization: Bearer YOUR_API_KEY` 通过 Twexapi REST 运行定时调用。
3. `has_more` 为 false 或工作流达到行上限时停止。
4. 仅当选定端点或查询需变更时，将异常交回AI Agent。

## 测试清单

- 确认 webhook 收到有效 JSON，而非 Markdown。
- 确认用 `tweet_id` 或 `user_id` 去重。
- 确认 `next_cursor` 保存在聊天历史外。
- 确认写操作以计划形式表示，直至人工批准。
- 确认 API 密钥、cookie 与 auth token 从未发送到用户可见目标。
