> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> 將 Ayrshare 社群媒體 API 整合到你的 n8n 工作流程，以發布、排程與分析使用者的社群媒體帳號。

export const XByoNotice = () => <Info>
  <strong>Targeting X/Twitter?</strong> Starting March 31, 2026, all X operations require your own API credentials. After linking X via OAuth, include these 2 headers in your request:
  <br /><br />
  <code>X-Twitter-OAuth1-Api-Key</code> — Your API Key (Consumer Key)<br />
  <code>X-Twitter-OAuth1-Api-Secret</code> — Your API Key Secret (Consumer Secret)
  <br /><br />
  <strong>One-time setup per Ayrshare account.</strong> You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do <em>not</em> create a new app per customer.
  <br /><br />
  Not linked yet? See the <a href="/dashboard/connect-social-accounts/x-twitter-byo-keys">full setup guide</a> to connect your X account.
  <br /><br />
  Your keys are never logged or stored by Ayrshare.
</Info>;

## 概觀

[n8n](https://n8n.io) 是一個工作流程自動化平台，可讓你連結各種應用程式並協調流程（包括 AI 代理程式），可在雲端或自架環境使用。

Ayrshare 社群媒體 API 可整合到你的 n8n 工作流程，以管理使用者的社群媒體帳號。透過單一 API 呼叫即可發布到 Facebook、Instagram、LinkedIn、YouTube、TikTok、Pinterest、Reddit、Threads、Bluesky、Telegram、Google Business Profile、Snapchat 與 X，你不需要撰寫或維護各平台的 API 程式碼。

有兩種連接方式：

<ul class="custom-bullets">
  <li>**MCP Server（由代理程式驅動）。** 將 [Ayrshare MCP Server](/additional/mcp-action-server) 附加到 n8n 內建的 MCP Client Tool 節點，你的 AI Agent 就能獨立完成整個流程：草擬貼文、依每個網路的規則驗證、發布或排程，然後回讀分析資料。不需要自行代管，也不需要安裝社群節點。</li>
  <li>**REST API（固定工作流程）。** 對於非代理程式的確定性工作流程，可直接從 HTTP Request 節點呼叫 [Ayrshare REST API](/apis/overview)。</li>
</ul>

管理使用者的社群帳號需要 [Business 方案](/multiple-users/business-plan-overview)，但你也可以透過 Premium 方案，僅在請求標頭中使用 [API Key](/apis/overview#authorization) 就能同樣地管理自己的社群帳號。

## 如何連結

在 MCP 路徑中，**AI Agent** 節點是大腦。**MCP Client Tool** 子節點附加到它，連接到 Ayrshare MCP Server、探索可用工具，並將這些工具提供給代理程式。當代理程式採取行動時，該節點會將呼叫發送到 Ayrshare，由 Ayrshare 發布到各社群網路。

```
Trigger  ->  AI Agent (+ Chat Model)  ->  MCP Client Tool  ->  Ayrshare MCP Server  ->  social networks
```

<Note>
  請使用 **HTTP Streamable** 傳輸方式，而非 SSE。[n8n 指南](/additional/mcp-n8n) 詳細介紹傳輸方式、驗證與設定。
</Note>

## 指南

完整的 n8n 指南以 MCP 優先的路徑從頭到尾涵蓋：先決條件、設定 MCP Client Tool 節點、驗證優先的系統提示、實作範例（從聊天訊息草擬並發布、自動發布新內容、每週分析摘要）、透過子設定檔代表客戶執行動作、將人類保留在流程中、REST 備援方案，以及疑難排解。

<Card title="n8n + Ayrshare MCP 指南" icon="book-open" href="/additional/mcp-n8n" horizontal>
  將 n8n 的 AI Agent 連接到 Ayrshare MCP Server，跨你的社群網路發布、排程與分析，不需要各平台的 API 程式碼。
</Card>

<Card title="下載 n8n 起始工作流程" icon="download" href="/files/ayrshare-n8n-mcp-workflow.json" horizontal>
  可直接匯入的工作流程：Chat Trigger、AI Agent、Anthropic 聊天模型，以及預先配線並帶有驗證優先系統提示的 Ayrshare MCP 節點。
</Card>

## 發布到 X（前身為 Twitter）

<XByoNotice />

在 n8n 中，將 MCP Client Tool 節點的 **Authentication** 切換為 **Multiple Headers**，並在 `Authorization` 旁加入兩個 `X-Twitter-OAuth1-*` 標頭。請參閱 [連接與設定 → X/Twitter BYO 憑證](/additional/mcp-action-connect#xtwitter-byo-credentials)。

## 深入了解

<ul class="custom-bullets">
  <li>進一步了解 [n8n](https://n8n.io) 及其 [AI Agent](https://docs.n8n.io/advanced-ai/) 與 [MCP Client Tool](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/) 節點。</li>
  <li>參閱 [MCP Server 概觀](/additional/mcp-action-server) 了解伺服器是什麼以及它如何對應到 Ayrshare API。</li>
  <li>瀏覽 [工具目錄](/additional/mcp-action-tools) 依領域分組查看你的代理程式可呼叫的工具。</li>
  <li>閱讀 [連接與設定](/additional/mcp-action-connect) 了解端點、傳輸方式、驗證與設定檔目標的細節。</li>
</ul>
