Skip to content

Gmail to Notion Forwarder - #21

Draft
pollenjp wants to merge 1 commit into
mainfrom
claude/brave-edison-yx29p1
Draft

Gmail to Notion Forwarder#21
pollenjp wants to merge 1 commit into
mainfrom
claude/brave-edison-yx29p1

Conversation

@pollenjp

Copy link
Copy Markdown
Member

概要

Gmail で受信したメールを Notion に自動転送するシステムを実装しました。

実装内容

Google Apps Script (gas/)

  • main.gs: Gmail メールを Notion に転送するロジック
    • 指定ラベル(ToNotion)のメールを自動検出
    • メール内容を Notion ページとして作成
    • 処理済みメールに星をつけてラベルを削除
  • appsscript.json: GAS プロジェクト設定(OAuth スコープ、トリガー設定)
  • .clasp.json.example: clasp CLI の設定テンプレート

Terraform (terraform/)

  • Google Secret Manager で API キーを安全に管理
  • Notion API キーと Database ID をシークレットとして保存
  • サービスアカウント作成(今後の拡張用)
  • 秘密鍵へのアクセス権限設定

CI/CD (.github/workflows/)

  • deploy-gas.yml: GAS 自動デプロイパイプライン
    • gas/ ディレクトリへの push で自動トリガー
    • clasp で Apps Script にプッシュ
    • Slack 通知対応(オプション)

セットアップ手順

  1. GAS 初期設定

    cd gmail-notion-forwarder-2026-06-25/gas
    cp .clasp.json.example .clasp.json
    # Script ID を設定
    clasp push
  2. Terraform で秘密鍵管理

    cd terraform
    cp terraform.tfvars.example terraform.tfvars
    # Notion API キーと Database ID を設定
    terraform init
    ·t·erraform a·pply
  3. GAS トリガー設定

    • Google Apps Script エディタで forwardEmailsToNotion 関数を時間ベーストリガーに設定

主な機能

  • ✅ Gmail ラベルで対象メールを選別
  • ✅ Notion Database への自動作成
  • ✅ メール内容をリッチテキストで保存
  • ✅ スクリプト プロパティで API キー管理
  • ✅ テスト関数で動作確認可能
  • ✅ ログ出力で監視可能

ドキュメント

次のステップ

  • GitHub Actions シークレット設定(CLASP_CONFIG, CLASP_CREDENTIALS)
  • Notion Database 構造作成(Subject, From, Received Date, Gmail Thread ID)
  • テストデプロイ
  • エラーハンドリング拡張(Slack 通知など)

Generated by Claude Code

Implemented automated email forwarding from Gmail to Notion using Google Apps Script.
Includes IaC setup with Terraform for secret management and CI/CD pipeline with GitHub Actions.

Structure:
- gas/: Google Apps Script implementation with email-to-Notion conversion
- terraform/: Secret Manager setup for API credentials
- .github/workflows/: Automated deployment pipeline

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NottkoeepaQWTNEqAWKbNK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants