composio-gmail

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gmail via Composio

通过Composio使用Gmail

Environment

环境配置

bash
COMPOSIO_API_KEY      # API key
COMPOSIO_USER_ID      # Entity ID (required for all requests)
COMPOSIO_CONNECTIONS  # JSON with .gmail connection ID
bash
COMPOSIO_API_KEY      # API密钥
COMPOSIO_USER_ID      # 实体ID(所有请求均需提供)
COMPOSIO_CONNECTIONS  # 包含.gmail连接ID的JSON数据

Core Pattern

核心调用模式

bash
CONNECTION_ID=$(echo $COMPOSIO_CONNECTIONS | jq -r '.gmail')

curl -s "https://backend.composio.dev/api/v3/tools/execute/ACTION_NAME" \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "connected_account_id": "'$CONNECTION_ID'",
    "entity_id": "'$COMPOSIO_USER_ID'",
    "arguments": {}
  }' | jq '.data'
bash
CONNECTION_ID=$(echo $COMPOSIO_CONNECTIONS | jq -r '.gmail')

curl -s "https://backend.composio.dev/api/v3/tools/execute/ACTION_NAME" \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "connected_account_id": "'$CONNECTION_ID'",
    "entity_id": "'$COMPOSIO_USER_ID'",
    "arguments": {}
  }' | jq '.data'

Quick Start

快速开始

IMPORTANT: Choose the right action!
  • User says "draft" or "prepare" → Use
    GMAIL_CREATE_DRAFT
    (saves to Drafts folder)
  • User says "send" → Use
    GMAIL_SEND_EMAIL
    (sends immediately)
bash
undefined
重要提示:选择正确的操作!
  • 用户提及“草稿”或“准备”→ 使用
    GMAIL_CREATE_DRAFT
    (保存至草稿文件夹)
  • 用户提及“发送”→ 使用
    GMAIL_SEND_EMAIL
    (立即发送)
bash
undefined

CREATE DRAFT (saves to Drafts folder for user to review/send)

创建草稿(保存至草稿文件夹供用户查看/发送)

curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_CREATE_DRAFT"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": { "to": "recipient@example.com", "subject": "Subject line", "body": "Email body text" } }' | jq
curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_CREATE_DRAFT"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": { "to": "recipient@example.com", "subject": "Subject line", "body": "Email body text" } }' | jq

SEND EMAIL (sends immediately - always include agent tag)

发送邮件(立即发送 - 务必包含agent标识)

curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_SEND_EMAIL"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": { "to": "recipient@example.com", "subject": "Subject line", "body": "Email body text\n\n--\nSent by '"$AGENT_NAME"'" } }' | jq
curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_SEND_EMAIL"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": { "to": "recipient@example.com", "subject": "Subject line", "body": "Email body text\n\n--\nSent by '"$AGENT_NAME"'" } }' | jq

List recent messages

列出最近的邮件

curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_LIST_MESSAGES"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": {"max_results": 10} }' | jq
undefined
curl -s "https://backend.composio.dev/api/v3/tools/execute/GMAIL_LIST_MESSAGES"
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json"
-d '{ "connected_account_id": "'$CONNECTION_ID'", "entity_id": "'$COMPOSIO_USER_ID'", "arguments": {"max_results": 10} }' | jq
undefined

All Actions

所有操作

See references/actions.md for complete API reference including:
  • Messages: send, list, search, get, reply
  • Labels: list, add/remove from messages
  • Drafts: create
查看references/actions.md获取完整API参考,包括:
  • 邮件:发送、列出、搜索、获取详情、回复
  • 标签:列出、为邮件添加/移除标签
  • 草稿:创建

Discover Actions

查看可用操作

bash
curl -s "https://backend.composio.dev/api/v2/actions?apps=gmail" \
  -H "x-api-key: $COMPOSIO_API_KEY" | jq '.items[] | {name, description}'
bash
curl -s "https://backend.composio.dev/api/v2/actions?apps=gmail" \
  -H "x-api-key: $COMPOSIO_API_KEY" | jq '.items[] | {name, description}'