connect 是做什麼的?
使用 Composio CLI 將 Codex 連接到任何應用程式。別再只是產生關於你能做什麼的文字——直接從 Shell 中實際執行它。
何時使用此技能
當你需要 Codex 執行以下操作時,請使用此技能:
- 發送那封郵件,而不是起草它
- 建立那個議題,而不是描述它
- 發布那則訊息,而不是建議它
- 更新那個資料庫,而不是解釋如何做
改變了什麼
| 沒有 Connect | 有 Connect |
|---|---|
| 「這裡是郵件草稿...」 | 發送郵件 |
| 「你應該建立一個議題...」 | 建立議題 |
| 「把這個發布到 Slack...」 | 發布它 |
| 「把這個加入 Notion...」 | 加入它 |
支援的應用程式
超過 1000 個整合,包括:
- 郵件: Gmail, Outlook, SendGrid
- 即時通訊: Slack, Discord, Teams, Telegram
- 開發: GitHub, GitLab, Jira, Linear
- 文件: Notion, Google Docs, Confluence
- 資料: Sheets, Airtable, PostgreSQL
- 客戶關係管理: HubSpot, Salesforce, Pipedrive
- 儲存: Drive, Dropbox, S3
- 社交媒體: Twitter, LinkedIn, Reddit
設定
1. 安裝 Composio CLI
curl -fsSL https://composio.dev/install | bash
2. 登入
composio login
composio whoami
這會開啟瀏覽器進行驗證,並讓你選擇預設組織和專案。在自動化流程中使用 -y 跳過提示。
3. 連結你需要的工具箱
composio link github
composio link gmail
composio link slack
每個指令會引導一次 OAuth,然後連線就會持續存在。
完成。Codex 現在可以直接從 Shell 驅動任何已連接的應用程式。
核心工作流程
- 知道工具代號? →
composio execute - 不知道代號? →
composio search - 需要釐清輸入? →
composio execute --get-schema或--dry-run - 工具箱未連接? →
composio link <工具箱名稱>然後重試 - 需要多個步驟? → 使用
composio run執行工作流程,使用composio proxy執行原始 API 呼叫
範例
探索工具
composio search "create a github issue"
composio search "send an email" --toolkits gmail
在呼叫前檢查輸入
composio tools info GITHUB_CREATE_ISSUE
composio execute GITHUB_CREATE_ISSUE --get-schema
composio execute GITHUB_CREATE_ISSUE --dry-run -d '{"owner":"acme","repo":"app","title":"Bug"}'
發送電子郵件
composio execute GMAIL_SEND_EMAIL -d '{
"recipient_email": "[email protected]",
"subject": "已發布!",
"body": "v2.0 已上線,如有問題請告訴我"
}'
建立 GitHub 議題
composio execute GITHUB_CREATE_ISSUE -d '{
"owner": "my-org",
"repo": "repo",
"title": "行動版超時錯誤",
"labels": ["bug"]
}'
發布到 Slack
composio execute SLACK_SEND_MESSAGE -d '{
"channel": "engineering",
"text": "部署完成 - v2.4.0 已上線"
}'
平行執行呼叫
composio execute --parallel \
GMAIL_FETCH_EMAILS -d '{"max_results": 2}' \
GITHUB_GET_THE_AUTHENTICATED_USER -d '{}'
使用 composio run 鏈接動作
composio run '
const issues = await search("github issues labeled bug this week");
const summary = issues.map(i => `- ${i.title}`).join("\n");
await execute("SLACK_SEND_MESSAGE", {
channel: "bugs",
text: `本週的錯誤:\n${summary}`
});
'
從檔案載入可重複使用的工作流程:
composio run --file ./workflow.ts -- --repo composiohq/composio
原始 API 存取 (proxy)
當沒有專用工具時,直接呼叫已驗證的 API:
composio proxy https://gmail.googleapis.com/gmail/v1/users/me/profile \
--toolkit gmail
composio proxy https://gmail.googleapis.com/gmail/v1/users/me/drafts \
--toolkit gmail -X POST -H 'content-type: application/json' \
-d '{"message":{"raw":"..."}}'
運作原理
- 你要求 Codex 做某事
- Codex 選擇一個代號,透過
composio search或先前知識 - CLI 檢查連線,如果缺少則提示
composio link - 動作執行,對真實 API 發出請求並將 JSON 回傳至 stdout
設定
全域旗標:
--log-level <all|trace|debug|info|warning|error|fatal|none>--help查看各指令的文件
環境變數:
COMPOSIO_API_KEY- 驗證憑證(為非互動式使用設定)COMPOSIO_BASE_URL- 自訂 API 端點COMPOSIO_SESSION_DIR- 覆寫成果儲存位置COMPOSIO_DISABLE_TELEMETRY=true- 選擇退出遙測
型別安全 SDK(選用)
當你想從應用程式而非 Shell 呼叫工具時,產生型別化的客戶端程式碼:
composio generate ts # TypeScript 型別
composio generate py # Python 型別
旗標:-o <目錄>、--toolkits <清單>、--compact、--transpiled、--type-tools。
疑難排解
Not logged in→ 執行composio loginConnection required for <工具箱名稱>→ 執行composio link <工具箱名稱>- 未知的代號 →
composio search "<你想要的>"或composio tools list <工具箱名稱> - 錯誤的輸入 →
composio execute <代號> --get-schema然後--dry-run - 動作失敗 → 在目標應用程式中檢查權限
完整參考文件:docs.composio.dev/docs/cli