azu / gmail-to-notion

Google Apps Script: Search Gmail and record the search results in Notion.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gmail to Notion

定期的にGmailを検索し、検索結果をNotionに記録するGoogle Apps Script.

Search Gmail periodically and record the search results in Notion.

graph TD;
  GAS-->|Search|Gmail;
  Gmail-->|Search Result|GAS;
  GAS-->|Record|Notion;

ユースケース

  • 特定のラベルをつけたメールを検索し、その結果をNotionに記録する
  • Record the search results of emails with specific labels in Notion

Setup

  1. claspでGoogle Apps Scriptのプロジェクトを作成する
npm ci
npx clasp login
npx clasp create --rootDir ./dist
cp appsscript.json ./dist/
touch .env
  1. .envファイルを作成し、以下のように設定する
    • op runで読み込んで利用することを想定している
# Search Query
SEARCH_QUERY="{label:A OR label:B}"
# Notion Token
NOTION_TOKEN="secret_XXXXXXXXXXX"
NOTION_DATABASE_ID="xxxxxxxxxxxxxxxxxxxxx"
NOTION_PROJECTS_ID="xxxxxxxxxxxxxxxxxxxxx"
# 送信したメールを記録するかどうか
IS_SAVE_IN_SENT=true
  1. npm run deployでデプロイする
npm run deploy

仕組み

  • 検索して、その結果をNotionに記録
  • 一度記録したものは、再度記録しない

Notionのデータベース構造

  • src/notion.tsを参照して変更する
  • プロパティ
    • タスク名
    • Projects
    • URL
    • Tags
      • Multi-selectのタグ
      • Gmail::<ラベル名>の形式で記録される

License

MIT

About

Google Apps Script: Search Gmail and record the search results in Notion.

License:MIT License


Languages

Language:TypeScript 89.5%Language:JavaScript 10.5%